Open Terrain Generator (OTG)

Open Terrain Generator (OTG)

10M Downloads

Some performance hot spots on client side that could maybe use optimizing

Corosauce opened this issue ยท 2 comments

commented

Following up from your suggestion from other ticket, here's what I had found some weeks ago.

Possible issue 1:

You have an optifine specific fix but it seems the calls for getStackTrace are quite expensive, found this i had saved:

screenshot_20190202_175542

Its with OTG and optifine installed, the line of code in question: https://github.com/PG85/OpenTerrainGenerator/blob/1.12-OTG%2B/platforms/forge/src/main/java/com/pg85/otg/forge/dimensions/WorldProviderOTG.java#L65-L78

Not currently sure if theres any better way to deal with it, just figured id point it out.

Possible issue 2:

Might just be nickpicking at this point, a lot of code being run just to see if hasSkyLight is true, very possible other method calls have this similar type of issue:

screenshot_20190202_180215

Caching more things might help this one.

I could have sworn I had one about rendering items on mobs, where it'd go down to World.getLightBrightness then into your classes but I can't find anything saved on that, it was a lot of mobs being rendered so might not have been anything worth worrying about.

Thats all I got!

commented

Yeah was with v6, and still using it as of today looks like. Sounds like we need to update! Good to hear.

My steps for visualvm are usually just to use CPU in the Sampler tab. If its a problem I can detect when it's happening in game, I'll time the starting of the CPU sampling with when the issue occurs. If I can't time it right, I usually just leave it running from minutes to an hour to help less obvious issues get enough cpu time to show up in the results.

Once I've done either of those steps, I'll stop the profiling and hit the snapshot button in the same tab. Then I can use Total Time % and Total Time columns to quickly dig down to see where the work is being done.

Sometimes I'll check the Thread CPU Time subtab in samplers while its running to see if theres any threads doing lots of work too, recently spotted an issue with the discord integration mod doing 100% cpu in main menu on its own thread by checking that.

Memory issues are more difficult to track down. Haven't used that one much recently but if I get runaway memory issues you can usually spot lots of instance creation of mods using Memory sampler, and if needed, making a snapshot and combing through references of objects etc.

commented

Hey @Corosauce, thanks for the data!

I assume you were using OTG 1.11.2 v9 or 1.12.2 v6 with these tests? For v7 I was able to remove the optifine hack, so that should be solved. The return values for methods in the OTGWorldProvider can't really be permanently cached as they can change during the game, I'd have to force it to clear the cache whenever a value is changed, which is a bit impractical atm. I have done some optimising for the worldprovider methods though, so hopefully for v7 they won't cause significant lag.

Tbh, what I'm especially curious about is performance for world creation / pregeneration :D. So creating a new BB world and letting it pregenerate with a radius of 50 or so. That's something I still have to do for v7 (dev version available on the discord btw for Forge, lots of new features). I've used visualVM a few times before to track down performance issues but I get the feeling I could be using it far more effectively. If you've got any useful tips/resources for me or would like to help profiling OTG v7, please let me know :). And thanks again!