FabricMC / fabric-loom

Gradle build system plugin used to automate the setup of a minecraft mod development environment.
MIT License
226 stars 194 forks source link

Decompiler cache #1021

Closed modmuss50 closed 4 months ago

modmuss50 commented 6 months ago

This is an issue to keep track of ideas around a cache for decompiler outputs. The idea is to cache each class after running gen sources so that any future runs dont need to decompile the entire game when only a few classes have changed. The cache should be global (shared between all projects)

  1. Generate a hash of the current decompiler including:
    • Decompiler version, likely by hashing the classpath? (But not including minecraft libraries?)
    • Custom options
  2. Generate a hash for every (none inner) class in in the input jar, it should take into account the following:
    • The decompiler hash
    • The file hash
    • All inner classes file hashes
  3. Split the input jar into 2, a jar to decompile and jar containing the classes that wont be decompiled.
    • Add the jar containing the classes that wont be decompiled to the decompiler classpath.
    • Decompile the input jar
  4. Store the newly decompiled classes in the cache
  5. Generate a file output jar containing all of the sources and resources
  6. Prune the cache
    • Each entry in the cache should have a last used timestamp, files that have not been used recently should be removed.
    • Have a max size? 256MB? maybe changed this based on how much free disk space there is?
    • Max age, remove any files that havent been used in a while (30 days?)

Questions:

Juuxel commented 6 months ago

Should the cache be specific to the loom version? e.g 1.5 and 1.6 wont use the same cache? If so how would we clean up the older versions? If not what do we do if a loom update wants to change the format of the cache?

AFAIK Gradle itself has a separate version for the cache itself, so we could have a fabric-loom/decompiler-cache/v1/... and change the version later if needed.

modmuss50 commented 6 months ago

AFAIK Gradle itself has a separate version for the cache itself, so we could have a fabric-loom/decompiler-cache/v1/... and change the version later if needed.

Thats a good idea 👍

modmuss50 commented 4 months ago

Done!