Skip to content

Conversation

@jrahman
Copy link
Member

@jrahman jrahman commented Aug 26, 2025

Significantly improve Azurite performance under heavy metadata lookup workloads. The issue here is that the LokiJS library only supported indexed access to data on the first predicate of a $and or $or clause. This is documented in the LokiJS code here.

The existing Azurite LokiMetadata store code used properties like accountName as the first property in the filter. The impact is that the find() and findOne() calls only performed an indexed lookup on the accountName. There is usually only a single account, so all blobs/queues/messages are returned, and the remaining filters/properties are applied by running a linear scan over all values in the result set. You can see the performance impact in the following CPU profile taken from a copy of Azurite running without this optimization:

image

The fix here moves the properties names that have higher selectivity to the first position in the filter object. By doing so, when LokiJS evaluates the filter object, the first (high selectivity) property is used for the initial indexed (fast) lookup which quickly prunes out nearly all of the entries in the collection. Only a few entries are left to be scanned over to compute the final result.

The impact here is substantial, in a test framework using Azurite, an initial load process took 12.5 seconds previously, and after this change only took about 9 seconds. This performance improvement only required re-ordering some fields here in the find()/findOne() API calls.

@jrahman
Copy link
Member Author

jrahman commented Aug 26, 2025

@microsoft-github-policy-service agree company="Microsoft"

@blueww blueww requested a review from edwin-huber August 26, 2025 08:43
@blueww
Copy link
Member

blueww commented Aug 26, 2025

@XiaoningLiu , @EmmaZhu
Would you please help to look at this PR?
The code change is simple, just change the Loki query parameters order.

@EmmaZhu
Would you please also help to look at the test failure here, it can be repro with Node 22.18.0?

@jrahman
Would you please also add change log?

Copy link
Collaborator

@edwin-huber edwin-huber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Looks good to me.

@jrahman
Copy link
Member Author

jrahman commented Aug 26, 2025

@blueww I have updated the change log with a note about the performance improvements here.

@blueww
Copy link
Member

blueww commented Sep 3, 2025

@jrahman

Thanks for the contribution!

The PR is approved now.
But the PR check failure, since we still have a pipeline issue need to fix before merge the PR.
We are working on this.
Thanks for you understanding!

@jrahman
Copy link
Member Author

jrahman commented Sep 18, 2025

Hi @blueww any updates on merging this change? We have active issues with our testing infrastructure because Azurite performance with metadata operations is a bit slow. We're looking to get this change merged to improve our test stability.

@blueww
Copy link
Member

blueww commented Sep 18, 2025

The PR merge is currently blocked by the pipeline issue.
@EmmaZhu , could you share the progress to fix the pipeline issue?

@jrahman
Copy link
Member Author

jrahman commented Sep 22, 2025

Hi @EmmaZhu any updates on the pipeline fixes? Looking at the repo, the last merged PR was several months ago. Also, this PR would greatly improve our local testing setup that uses Azurite.

@blueww blueww merged commit adc7ace into Azure:main Oct 22, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants