MinecraftForge / ForgeFlower

Forge's modifications to FernFlower. Fixing various bugs/inconsistencies. Main Repo: https://github.com/MinecraftForge/FernFlower
Apache License 2.0
80 stars 44 forks source link

Cache file data to reduce lock contention #116

Closed zml2008 closed 2 years ago

zml2008 commented 2 years ago

Zip file instances lock on all reads, so we should try to load everything we need into memory all at once, rather than reading multiple times

This does have some negative impact on base memory usage, but reduces allocations from file reads quite a bit, so it's probably about a wash on that front.

These changes knock about 10s off the runtime to decompile 1.18.2 (~40s to ~30s) on my machine (Ryzen 7 3800x, win 11, 64gb ram, SSD), with no change to the output.

Further work on true lazy loading of classes is upcoming, but this was a change with way lower impact, and where my work started so I pulled it out on its own.

Some reports from JFR that led to these changes:

Original

image

image

image

After introducing the ZipFile cache (step 1)

image

image

image

After caching data in the LazyLoader link (step 2)

(yes, this abuses LazyLoader, but LazyLoader is dumb and I don't care)

image

image

image