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

Memory usage improvements for transform cache #336

Merged
merged 3 commits into from
Jul 28, 2023

Conversation

embeddedt
Copy link
Contributor

This PR implements some basic optimizations to the transform cache memory usage that are simple and should not break anything.

The first change involves changing the internals hider transformation logic to read the class bytes from disk twice instead of storing them in a map, thus avoiding storing all class bytes in RAM at once. I checked and this didn't seem to regress transform cache build times meaningfully compared to 0.2.0-beta.4.

I also added a new system property, loader.zipfs.use_temp_file, which allows bypassing the Java ZipFileSystem logic of storing all files being written to the ZIP in RAM. Unfortunately this introduces a fairly hefty performance penalty to building the transform cache (presumably due to all the IO going to temporary files on disk first) so it can't be enabled by default. I still think it's a worthwhile tunable to offer as it only impacts launches in which the transform cache needs to be rebuilt.

Additionally, I took the opportunity to fix an annoying bug where the transform cache cannot be recreated correctly if incomplete, due to FileAlreadyExistsException being thrown elsewhere in the code. I chose the simplest solution of just deleting the old incomplete file before proceeding.

This allows the BlanketCon 23 testing pack to be launched on 700MB of RAM.

This avoids storing data in memory but slows down cache building,
so we gate it behind a system property that's off by default
@AlexIIL
Copy link
Contributor

AlexIIL commented Jul 28, 2023

This looks good, thanks!

@AlexIIL AlexIIL merged commit bd1630f into QuiltMC:develop Jul 28, 2023
1 check passed
AlexIIL added a commit that referenced this pull request Jul 28, 2023
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.

2 participants