-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
json destructor quite slow #3583
Comments
Performance is not a strong focus of this library, so generally, the answer to "Can X be done faster?" is yes. I halved the runtime of the destructor without too much effort, but I have to think about this more carefully before submitting a PR. |
I'm going to wait for #3575 to be closed, as that PR touches the same functions and I don't want to deal with the inevitable merge conflicts. As a preview, here are the respective call graphs of the current destruction implementation (destroy by flattening) and a simple and obvious optimization (destroy by iterative traversal). The number of calls is reduced from ~14e6 to ~6e6, about halving the time taken to destroy |
impressive! |
Just checking, is this still preserving the non-recursive nature of the destroy operation? |
Of course. I hate recursion with passion. :-) |
I assumed so based on the call counts, but I just wanted to check before you got too far down the path, because the current non-recursive implementation is due to a past stack overflow issue destroying deeply nested |
@falbrechtskirchinger Do you happen to (still?) have a branch with this modification? |
Description
I was running
patch
over a ~100Mb repodata file and noticed that it was slow due to copying and destroying the entire object multiple times.I am quite curious if the performance of
destroy()
could be improved? On my computer, it takes roughly 1 second to parse the file and create the json object, but also 0.5 seconds to destroy the json object.Reproduction steps
Download a large JSON file, such as https://conda.anaconda.org/conda-forge/linux-64/repodata.json (
curl --compressed https://conda.anaconda.org/conda-forge/linux-64/repodata.json
)and run the following code:
Expected vs. actual results
destruction should have minimal runtime cost
Minimal code example
No response
Error messages
No response
Compiler and operating system
clang 12, macOS
Library version
3.10.5
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: