-
-
Notifications
You must be signed in to change notification settings - Fork 91
Optimize XmlJSON: Cache name -> node mappings #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AbeJellinek
wants to merge
4
commits into
Juris-M:master
Choose a base branch
from
AbeJellinek:optimize-xmljson
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0a9d105 to
19e4422
Compare
Contributor
|
Thanks for the investigation and fix. We hadn't encountered serious performance impacts in our tests ahead of merging the Chicago update, so apologies for not catching this problem ahead of that merge |
Author
|
No worries! Let me know if this needs anything. |
Contributor
|
Zotero 8 beta startup: Before: After: |
dstillman
added a commit
to zotero/zotero
that referenced
this pull request
Aug 7, 2025
dstillman
added a commit
to zotero/citeproc-js-server
that referenced
this pull request
Aug 7, 2025
Contributor
|
This looks good to me. Will remove the logging @AbeJellinek mentioned and merge tomorrow or Saturday |
dstillman
added a commit
to zotero/zotero
that referenced
this pull request
Aug 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've seen some serious performance issues in Zotero since the recent CMOS style updates - as long as 10 seconds to initialize citeproc-js and generate a citation. I did some profiling, and it seems like the major bottleneck was
CSL.XmlJSON#getNodesByName(). It gets called repeatedly during initialization, often with the same arguments (in my testing, 4250 calls with only 11 uniquenamearguments). Before this PR, it had to perform a full recursive tree walk every time, which ended up accounting for the majority of the initialization time.This PR implements a cache that allows that function to avoid repeating work. The first time
#getNodesByName()is called with amyjsonargument that it hasn't seen before (including as a subtree of another tree), it walks the whole tree and caches name mappings. Mappings are propagated upwards so every node's cache includes mappings for itself and all its descendants.In my testing, this reduces the time to initialize
CSL.Engineindemo.jsfrom 450 ms to 200 ms in Firefox (55% faster), and from 300 ms to 115 ms in Chrome (62% faster).Tests all pass on my machine.
59a11cb can be dropped before merge to go back to APA and remove the new logging in
demo.js. I kept those changes in this PR so it's easier to test.