Futurepack Mod - Now with flyable Spaceships!

Futurepack Mod - Now with flyable Spaceships!

1M Downloads

Performance tuning request - futurepack.common.block.TileEntityDungeonCore.run

ProsperCraft opened this issue ยท 3 comments

commented

We are having major issues with the sever slowing down and not being able to break blocks after it has been running for about an hour and a half or so, a spark/warmroast profile showed this-

futurepack.common.block.TileEntityDungeonCore.run()45.80%

df37c36eb10af100df85447a9a81e220

https://sparkprofiler.github.io/#c3kjScsPqO

Futurepack-1.12.2-26.4.88
Mohist-83bcbf5-server (no longer using sponge)

commented

Well as you see from the test there is hardly anything I can do about this. run needs 45.8% where 33% are getChunk (vanilla I cant change that) and another 11% are from getChunkFromChunkCoords. So I am left with 1.4%. Also this method already wokrs VERY slowly and is partially async.

	@Override
	public void run()
	{
		if(rooms!=null)
		{
			next++;
			if(next < rooms.length)
			{
				StructureBoundingBox box = rooms[next];
				BlockPos middle = new BlockPos( (box.maxX+box.minX)/2, (box.maxY+box.minY)/2, (box.maxZ+box.minZ)/2);
				IChunkProtection prot = world.getChunk(middle).getCapability(FPDungeonProtection.cap_PROTECTION, null);
				if(prot.getRawProtectionState(middle) != (IChunkProtection.BLOCK_NOT_BREAKABLE | IChunkProtection.BLOCK_NOT_PLACABLE))
				{
					FPDungeonProtection.addProtection(world, box);
				}
				
				Thread t = new Thread(new Runnable()
				{	
					@Override
					public void run()
					{
						try {
							Thread.sleep(20);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
						((WorldServer)world).addScheduledTask(TileEntityDungeonCore.this);
					}
				}, "Waiting");
				t.start();
			}
		}
	}

As you can see I am only doing 1 room entry per tick, where this list will contain over 100. This will only run once so after the list is done everything will return to normal.

commented

Is it possible that if we pregenerated a ton of land that we have a lot of these in the queue and it is just finishing them all up?

commented

This is from the dungeon dimension and happens once when someone enters a dungeon.