Skip to content
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

Fix auxlib.logz.stringify excess memory allocation #13628

Merged
merged 2 commits into from
Feb 29, 2024

Conversation

mbargull
Copy link
Member

@mbargull mbargull commented Feb 27, 2024

Description

This addresses the excess resource usage observed in gh-13541.

Essentially, the whole repodata.json is parsed via requests.Response.json and then dumped into a formatted string -- with both parts allocating multiple GB in RAM for large channels like conda-forge.
All this happens in a context only for (intended) debug logging output which is meant to constrain the log message length (and in turn memory usage); the proposed changes just apply the intended size constraints.

(It only handles the severe run time impact but doesn't fix the underlying cause for gh-13541.)

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • [ ] Add / update outdated documentation?

Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Feb 27, 2024
Copy link

codspeed-hq bot commented Feb 27, 2024

CodSpeed Performance Report

Merging #13628 will create unknown performance changes

Comparing mbargull:fix-auxlib-stringify-contenxt_max_len (85dc7b4) with main (1f63bef)

Summary

⚠️ No benchmarks were detected in both the base of the PR and the PR.

Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
@dholth
Copy link
Contributor

dholth commented Feb 27, 2024

This is concerning. It would be better to never instantiate response.text for example the jlap / repodata.json.zst code tries to stream the response directly to disk. Thanks for working on this!

@mbargull
Copy link
Member Author

It would be better to never instantiate response.text for example the jlap / repodata.json.zst code tries to stream the response directly to disk.

Yes, ideally we'd always stream this.
As is, the code calling stringify also uses requests.Response.text, so this should not pose much impact.
I.e., there are multiple places for us to replace whenever we get to using streaming for all repodata.json handling.

@jezdez
Copy link
Member

jezdez commented Feb 27, 2024

This reminds me that we need to find a way to track memory usage in the performance tracking somehow.

@kenodegard kenodegard merged commit 13fe6fe into conda:main Feb 29, 2024
80 checks passed
@jezdez jezdez mentioned this pull request Mar 11, 2024
58 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants