Jump to content

Lag Problem - Seeking Clever Solutions


Draco18s

Recommended Posts

I'll be blunt, while my code is at fault, its not the code that's the problem, so none of that will be here.  I'll describe the behavior and give you, the reader, an opportunity to see if you can figure out what the problem is before revealing it at the bottom of this post.

 

The situation:

1) I have a custom finite fluid block.  Two actually, but the only difference between them is their fluid densities: one floats the other sinks (and a conversion from the latter to the former as it mixes with air).  I've added a few extra interactions to its updateTick function, but nothing serious.  A little volume balancing so that it flows farther along straight surfaces (like a real liquid would) and checking adjacent blocks for fire sources.

2) This block spawns in the word using COG in a vein formation, relatively common, but still less than COG's default coal distribution (coal was my template).

3) After only a few minutes, my frame rate drops to less than 1 FPS (more like 4 SPF) with upwards of 80% of the processing taken up in Minecraft's lighting update function.  My computer is by no means a piece of junk, but it's also four years old (Phenom II 1090T).

 

Take a minute to think about what could cause this, then take a hint if you'd like, or go straight to the answer.

Hint 1:

 

The block is highly flammable

 

Hint 2:

 

 

The actual problem and my question asking how to solve it:

 

COG is placing veins of my flammable gas such that it can intersect cave, ravine, or mineshaft corridors, causing it to spill out, encounter lava or torches, catching on fire, and starting a massive cascade frame-rate-failure as the hundreds of fires spread, die, and cause lighting updates as the gas flows, catches, burns off, and explodes.

 

I would like to retain the volatile nature of my block, as it presents a very dangerous hazard underground, but I would like to find a way to not have so many "leaks" as a result of worldgen.

 

One "solution" would be to encase the veins in stone, replacing all other blocks, such that the gas can't leak into mineshafts.

[1/26/2015 2:50:09 PM] Keybounce: Challenge: Find 5 flaws with this idea.

Or: it's a bad solution because any time the gas vein intersected anything there would be an ugly case around it.

 

I've also considered ignoring the fire-starter-adjacency code for a few thousand ticks, letting the gas flow and leak, hoping to stabilize before it catches on fire, but in a good percentage of cases, that won't actually fix anything, just delay it.

 

Is there a Third Option I'm not seeing?

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Instead of encasing the vein in stone, you could just check to make sure that all the blocks around it are not liquids (other than yours) and are full size blocks. This way the gas couldn't spread outside of a vein unless a player (or something else) broke into the vein.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

Except that I'm not the one placing the block.  COG is.  I can't say "make sure this block is surrounded on all sides."  COG has a lot of rules, but no adjacency checks.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

One "solution" would be to encase the veins in stone, replacing all other blocks, such that the gas can't leak into mineshafts.

 

Well then your "solution" wouldn't work either.

 

Is there anyplace, (e.g. GitHub) that I can look at your ore generation code?

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

You mean the COG config xml?

https://github.com/Draco18s/HarderStuff/blob/master/main/resources/cog_config/UndergroundHazards.xml

 

And actually that solution is easy.  Cog does that with diamond veins: it puts lava on the inside using the same vein seed and a smaller diameter.

 

Uhm, maybe make a copie BlockB of your BlockA

BlockB is not flammable and the block that spawns, when you collect BlockB it drops BlockA

 

taddaaaa :D

 

Yeah no.  Because two things:

1) the block is not collectable and

2) the 'blockB' is not dangerous and that's the whole point.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Ok, mby check in the onBlockPlaced method of your super dangerous block for fire sources around

aaaaaaand remove them?

 

Nope.  Because:

 

# = stone

8 = quanta of fluid

t = torch

. = air

f = fire

 

Worlgen does this:

############

#88.......t#

############

My block isn't near a torch, your suggested code removes nothing.

Block updates happen:

############

#844......t#

############

And some more:

############

#6442.....t#

############

And some more until...

############

#22222222.t#

############

Then finally

############

#222222211t#

############

Oops, now it catches fire

############

#22222221ft#

############

 

I don't mind that the veins occasionally intersect caves (one seed was really fucking awesome as a result).  Its more a problem of frequency (and even then more a problem of running into an abandoned mineshaft, not a cave).  The gas can spread really far and expand quite a lot before it encounters a torch or lava block, setting the entire system on fire (one spot I investigated had three veins all pouring into the same ravine where some lava was and there was just fire everywhere, I couldn't get a clean shot of it though showing just how massive the blaze was).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh, and by "spreads really far" I mean it.

 

I set up a vault and passageway system.  Here's how far it spread using the default ooze-like rules:

Wool block on top is how far the floaty lighter-than-air flow gets (there's one in the ground for the heavier stuff).

width=800 height=449http://s16.postimg.org/c7skdqyqt/2015_01_06_16_00_22.png[/img]

With my rules it escapes.  Here's a shot of the surface as it flows down the tunnel, look at how uniform it is:

The entire passage is filled with the heavier liquid.

width=800 height=449http://s16.postimg.org/8a5aocbxh/2015_01_07_17_20_13.png[/img]

I've also got (optional) rules to allow it to slip past (open) doors, signs, and ladders.

 

This stuff is a serious hazard while mining.  And I want it to remain that way.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I dont really know bout COG

 

No, you don't.  Go away.  You're not helping.

 

COG runs absolutely last, and then some.  I had to submit a pull request to COG so I could actually run some code after it modified a chunk.

 

AND running "even more later" doesn't even solve the problem; fucking hell.  A ∩ B == B ∩ A

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Hi

 

Perhaps you could apply your "fire-starter-adjacency" delay in a different way, i.e. add a check to ensure that no more than one (or a few) veins catch fire within any given time period - or perhaps only veins which are within a certain radius of the player.

 

Alternatively you could suspend fire-starter-adjacency until your code (eg in a tick handler, or the first time the gas is checked for spreading) has a chance to sweep through the generated areas and eliminate undesirable "leaks", perhaps by solidifying the blocks of the gas exposed to the air (maybe it slowly polymerises?)

 

-TGG

Link to comment
Share on other sites

Ok, so using the same test seed I've been playing with before:

 

Default settings, etc. etc: 41% total tick time spent in checkLight

Half volume of gas placed in the world: 20%

Gas cannot burn or none in world: < 0.1%

Player within 32 blocks (not moving): 7%

 

32 blocks is the same distance at which I scan the area around the player for lava in order to spawn semi-short-lived volcanic fumes.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.