Jump to content

Optimizing worldgen XYZ directions


moronwmachinegun

Recommended Posts

Hello,
  I am looking at orevein generation performance in GT5U.  Currently I am seeing numbers around 100-300ms to fill an orevein. 

I have pulled the logic into a standalone test harness, and it seems to run fairly fast, about 600uS to fill a vein (without 
any minecraft-related function calls, just randomization and loop control). I have optimized that a little, shaving off about 
60uS, but that's clearly not where the major culprit is located.

 

I was wondering if anyone has done any performance comparisons on how to step through a chunk.  Based on my read of
https://minecraft.gamepedia.com/Chunk_format it seems like doing a full Y layer at a time is the most CPU cache-friendly 
since you wouldn't jump up and down between sections.  Also, it would be ideal to order XZ so that the memory accesses
are linear and won't cause cache collisions (TMI: http://www.aristeia.com/TalkNotes/ACCU2011_CPUCaches.pdf). The current code
does looping as

  • for X
    • for Z
      • for Y

so there might be some benefit to swapping Y to the outermost loop. And possibly a benefit to swapping order of X and Z.

 

It might all be re-arranging deck chairs on the Titanic though.  My suspicion is that the major time-sink is turning the victim block into a tile entity. I'm going to try adding some measurement code to see how much of the overall time is spent doing that.  If that's the case, there isn't much to really do except lower the number of blocks converted by making veins smaller, reducing their density, or optimizing World.setBlock().

 

Also, if anyone has a more fleshed-out command line test harness for worldgen, that would be great (a fake chunk would be awesome). The variance when
testing in-game is so high it's hard to tease out if improvements actually matter.  If not, can someone point me to the Chunk class file so I can make a better simulation?

Thanks for any help!

Edited by moronwmachinegun
  • Like 1
Link to comment
Share on other sites

6 hours ago, moronwmachinegun said:

 If not, can someone point me to the Chunk class file so I can make a better simulation?

 

You should have the Minecraft and Forge source code available in the forgeSrc-<version> referenced library, so you can either browse to the Chunk class inside of it or use your IDE's Navigate To Class (IDEA, Ctrl+N)/Open Type (Eclipse, Ctrl+Shift+T) feature to open the Chunk class directly.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

  • 2 weeks later...

Well, I decided i didn't want to have to re-implement half of Minecraft just so I could set a XYZ value, so I just make my fake "chunk" be an array of ints.  I have placed my "fake" oregen command-line simulation code up on my Github at https://github.com/richardhendricks/GT-standalone-oregen if it is of interest to anyone.

 performancetest.java has the basic skeleton of what I needed.  There are a couple of sample tests in there, one using a non-chunkified worldgen to generate ores, one using a chunkified worldgen that remembers generated oreveins in a hashtable, and a chunkifed GT stone boulder generator that has random XYZ dimensions skewed towards making skinny pipes instead of bland round balls. The printout is very primitive, just a text printout of the chunks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.