Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Enable caching of classes compiled by Janino  (Read 1938 times)

Kiloman

  • Ensign
  • *
  • Posts: 35
    • View Profile
Enable caching of classes compiled by Janino
« on: October 27, 2013, 11:25:12 PM »

Some folks have noticed that the startup time (particularly with mods enabled) can be pretty lengthy. Have you considered providing a cache for compiled scripts for use with Janino's CachingJavaSourceClassLoader? Perhaps with a file size/modification time or other heuristic to selectively re-compile classes on demand?

I know, mod authors that have weighty code should probably just use a real IDE and compile their code into JARs instead of relying on Janino, but still - I'm curious what sort of difference it would make on startup time in general.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24114
    • View Profile
Re: Enable caching of classes compiled by Janino
« Reply #1 on: October 28, 2013, 01:10:41 PM »

Thanks for pointing me to that - I think I looked at it a long time ago, but at that point it didn't matter (since compilation was overshadowed by the loading time for other resources - the compilation is done in parallel, btw, so as long as it takes less time than image/sound loading, how long it takes literally doesn't matter). And then I promptly forgot about it. But now that there are more scripts, even in vanilla compilation can take longer than resource loading - although that probably depends on the hard drive speed.

Gave it a whirl just now, seems good, though there were a few potential pitfalls. For example, multiple mods overriding the same plugin would mean there's a cached version of the file, and the mod with the latest timestamp on the .java file would win out, *even if disabled*. Ended up creating separate cache directories for each mod to get around that.

One other potential issue is that the initial startup now takes a bit longer. (Because it's writing all those files to disk, presumably? Or the caching compiler simply takes longer.). Subsequent starts are faster, though, as expected.

I'm curious - if you don't have a solid state drive, could you let me know if the compilation step in vanilla is actually exceeding the length of the other resource loading? The way to tell would be if it hangs with the loading bar at 100% for a while, and if you're tailing the log, you'll see entries about scripts being loaded flying by when it's at 100%.

The reason I'm asking mentioned SSD vs not is because that's going to speed up the loading of the images and sounds drastically, while script compilation likely isn't IO-bound. In a non-SSD use case, which is more common/makes more sense to optimize for, there's a better chance for script compilation to be a non-consideration (due to being done in parallel and having more time due to slower image/sound loading), in which case the hit to the initial startup time wouldn't be worth it.
Logged

Kiloman

  • Ensign
  • *
  • Posts: 35
    • View Profile
Re: Enable caching of classes compiled by Janino
« Reply #2 on: October 28, 2013, 08:55:40 PM »

I have a desktop with SSD, and a laptop with a traditional spinning disk. I'll give them both a try and see where it's pausing. Could probably try launching the game off the media disk on the desktop too. Wonder if there's a good way to force files out of cache on Windows...
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: Enable caching of classes compiled by Janino
« Reply #3 on: November 05, 2013, 02:12:50 AM »

Just reporting that there is a 10-15 seconds delay between slider filling itself and game moving to main menu in my case. Though this is with Ironclads mod which is a huge monstrosity that surpasses all and everything in terms of... well... everything related to stability and resource consumption.

Oh, btw. It would be nice to have the loading progress bar when creating a new game just to show the newcomers that the mod didn`t die loading freezing the whole system :)
« Last Edit: November 05, 2013, 02:14:34 AM by Okim »
Logged