Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Lag Problem - Seeking Clever Solutions
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Draco18s

Lag Problem - Seeking Clever Solutions

By Draco18s, January 27, 2015 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted January 27, 2015

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:

 

width=800 height=449http://s21.postimg.org/9wf5pz9uf/2015_01_24_19_49_00.png[/img]

 

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?

 

  • Quote

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.

Share this post


Link to post
Share on other sites

shadowfacts    100

shadowfacts

shadowfacts    100

  • Dragon Slayer
  • shadowfacts
  • Forge Modder
  • 100
  • 588 posts
Posted January 27, 2015

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.

  • Quote

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

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

Developer of many mods

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted January 27, 2015

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.

  • Quote

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.

Share this post


Link to post
Share on other sites

shadowfacts    100

shadowfacts

shadowfacts    100

  • Dragon Slayer
  • shadowfacts
  • Forge Modder
  • 100
  • 588 posts
Posted January 27, 2015

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?

  • Quote

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

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

Developer of many mods

Share this post


Link to post
Share on other sites

ImaFool    3

ImaFool

ImaFool    3

  • Stone Miner
  • ImaFool
  • Members
  • 3
  • 70 posts
Posted January 27, 2015

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

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted January 27, 2015

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.

  • Quote

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.

Share this post


Link to post
Share on other sites

shadowfacts    100

shadowfacts

shadowfacts    100

  • Dragon Slayer
  • shadowfacts
  • Forge Modder
  • 100
  • 588 posts
Posted January 27, 2015

I have a custom finite fluid block.

 

Did you bother reading the whole thing ImaFool?

  • Quote

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

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

Developer of many mods

Share this post


Link to post
Share on other sites

ImaFool    3

ImaFool

ImaFool    3

  • Stone Miner
  • ImaFool
  • Members
  • 3
  • 70 posts
Posted January 27, 2015

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

aaaaaaand remove them?

 

I have a custom finite fluid block.

 

Did you bother reading the whole thing ImaFool?

 

Uhhm maybe i missunderstood a little :P

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted January 27, 2015

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).

  • Quote

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.

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted January 27, 2015

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.

  • Quote

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.

Share this post


Link to post
Share on other sites

ImaFool    3

ImaFool

ImaFool    3

  • Stone Miner
  • ImaFool
  • Members
  • 3
  • 70 posts
Posted January 27, 2015

I dont really know bout COG, but cant you just set the generation weight up? and isnt vanilla stuff like ravines generating before mods anyway

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted January 27, 2015

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

  • Quote

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.

Share this post


Link to post
Share on other sites

TheGreyGhost    819

TheGreyGhost

TheGreyGhost    819

  • Reality Controller
  • TheGreyGhost
  • Members
  • 819
  • 3280 posts
Posted January 27, 2015

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

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted January 27, 2015

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.

  • Quote

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.

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • cadbane86140
      Minecraft: Parkour Stairs Part 1!

      By cadbane86140 · Posted 2 minutes ago

      Hello There! Today we are playing a BRAND NEW parkour map that was actually just released about a month ago and all I gotta say is that this map is so freaking unique and the map creators did something with this map that we have never seen in parkour before! There are so many hilarious moments in this video that I know you guys are gonna love! I hope you all enjoy this video and if you did don't forget to like and sub for more! https://www.youtube.com/watch?v=5aGkMp5bExg
    • cadbane86140
      Minecraft: Parkour Stairs Part 1!

      By cadbane86140 · Posted 3 minutes ago

      Hello There! Today we are playing a BRAND NEW parkour map that was actually just released about a month ago and all I gotta say is that this map is so freaking unique and the map creators did something with this map that we have never seen in parkour before! There are so many hilarious moments in this video that I know you guys are gonna love! I hope you all enjoy this video and if you did don't forget to like and sub for more! https://www.youtube.com/watch?v=5aGkMp5bExg
    • kiou.23
      Block Rotate

      By kiou.23 · Posted 31 minutes ago

      That's usually the case, always try to understand the code before copy and pasting, or else you'll get a lot of headaches later in the code's life
    • Varzac
      Forge jar file not opening

      By Varzac · Posted 57 minutes ago

      I ran Jarfix and then tried installing again with the same results. Nothing happening I even tried using winrar, but as you said nothing happened
    • BeardlessBrady
      [1.16.4] Null when OpenGUI

      By BeardlessBrady · Posted 1 hour ago

      Ah.. Thats what I get for stopping half way through and not double checking, thanks!
  • Topics

    • cadbane86140
      0
      Minecraft: Parkour Stairs Part 1!

      By cadbane86140
      Started 2 minutes ago

    • cadbane86140
      0
      Minecraft: Parkour Stairs Part 1!

      By cadbane86140
      Started 3 minutes ago

    • ehbean
      10
      Block Rotate

      By ehbean
      Started 7 hours ago

    • Varzac
      3
      Forge jar file not opening

      By Varzac
      Started 13 hours ago

    • BeardlessBrady
      2
      [1.16.4] Null when OpenGUI

      By BeardlessBrady
      Started 1 hour ago

  • Who's Online (See full list)

    • cadbane86140
    • ehbean
    • We Random
    • The_Deadly_Taco
    • kiou.23
    • DieGo901yt
    • brok4d
    • JackRaidenPH
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Lag Problem - Seeking Clever Solutions
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community