Skip to content

Commit ae8c29c

Browse files
committed
Make carpet profiler more precise
added "Tile Tick", "Chunk Tick", "Block Events", "Player Chunk Map" phases
1 parent 14071f4 commit ae8c29c

2 files changed

Lines changed: 62 additions & 41 deletions

File tree

patches/net/minecraft/world/WorldServer.java.patch

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -97,65 +97,80 @@
9797
this.wakeAllPlayers();
9898
}
9999

100+
- this.profiler.startSection("spawner");
100101
+ //CM profiler
101102
+ int did = this.dimension.getType().getId();
102103
+ String world_name = (did==0)?"Overworld":((did<0?"The Nether":"The End"));
103104
+ // CM end
104-
+
105+
106+
- if (this.getGameRules().getBoolean("doMobSpawning") && this.worldInfo.getGenerator() != WorldType.DEBUG_ALL_BLOCK_STATES)
107+
- {
108+
- this.entitySpawner.findChunksForSpawning(this, this.spawnHostileMobs, this.spawnPeacefulMobs, this.worldInfo.getGameTime() % 400L == 0L);
109+
- this.getChunkProvider().spawnMobs(this, this.spawnHostileMobs, this.spawnPeacefulMobs);
105110
+ if (TickSpeed.process_entities)
106111
+ { // [CM] extra indent to skip processing of entities
107-
this.profiler.startSection("spawner");
108-
+ CarpetProfiler.start_section(world_name, "Spawning");
109-
+ MicroTimingLoggerManager.setTickStage(this, TickStage.SPAWNING); // TISCM Micro Timing logger
110-
111-
if (this.getGameRules().getBoolean("doMobSpawning") && this.worldInfo.getGenerator() != WorldType.DEBUG_ALL_BLOCK_STATES)
112-
{
113-
this.entitySpawner.findChunksForSpawning(this, this.spawnHostileMobs, this.spawnPeacefulMobs, this.worldInfo.getGameTime() % 400L == 0L);
114-
this.getChunkProvider().spawnMobs(this, this.spawnHostileMobs, this.spawnPeacefulMobs);
112+
+ this.profiler.startSection("spawner");
113+
+ CarpetProfiler.start_section(world_name, "Spawning");
114+
+ MicroTimingLoggerManager.setTickStage(this, TickStage.SPAWNING); // TISCM Micro Timing logger
115+
+
116+
+ if (this.getGameRules().getBoolean("doMobSpawning") && this.worldInfo.getGenerator() != WorldType.DEBUG_ALL_BLOCK_STATES)
117+
+ {
118+
+ this.entitySpawner.findChunksForSpawning(this, this.spawnHostileMobs, this.spawnPeacefulMobs, this.worldInfo.getGameTime() % 400L == 0L);
119+
+ this.getChunkProvider().spawnMobs(this, this.spawnHostileMobs, this.spawnPeacefulMobs);
120+
+ }
121+
+ CarpetProfiler.end_current_section();
115122
}
116-
+ CarpetProfiler.end_current_section();
117-
+ }
118123
+ // [CM] end extra indent
119124

120125
this.profiler.endStartSection("chunkSource");
121126
+ MicroTimingLoggerManager.setTickStage(this, TickStage.CHUNK_UNLOADING); // TISCM Micro Timing logger
122127
this.chunkProvider.tick(hasTimeLeft);
123128
int j = this.calculateSkylightSubtracted(1.0F);
124129

125-
@@ -208,25 +264,57 @@
130+
@@ -208,26 +264,64 @@
126131
this.setSkylightSubtracted(j);
127132
}
128133

129134
- this.worldInfo.setGameTime(this.worldInfo.getGameTime() + 1L);
130135
+ if (TickSpeed.process_entities)
131136
+ { // CM extra indent to skip processing of entities
132137

133-
+ // TISCM Micro Timing logger
134-
+ // Flushes messages right before overworld gametime increases
135-
+ if (this.getDimension().getType() == DimensionType.OVERWORLD)
136-
+ {
137-
+ MicroTimingLoggerManager.flushMessages(this.getGameTime());
138-
+ }
139-
+
140-
+ this.worldInfo.setGameTime(this.worldInfo.getGameTime() + 1L);
141-
if (this.getGameRules().getBoolean("doDaylightCycle"))
142-
{
143-
this.worldInfo.setDayTime(this.worldInfo.getDayTime() + 1L);
144-
}
138+
- if (this.getGameRules().getBoolean("doDaylightCycle"))
139+
- {
140+
- this.worldInfo.setDayTime(this.worldInfo.getDayTime() + 1L);
141+
- }
142+
+ // TISCM Micro Timing logger
143+
+ // Flushes messages right before overworld gametime increases
144+
+ if (this.getDimension().getType() == DimensionType.OVERWORLD)
145+
+ {
146+
+ MicroTimingLoggerManager.flushMessages(this.getGameTime());
147+
+ }
145148

146-
this.profiler.endStartSection("tickPending");
147-
+ CarpetProfiler.start_section(world_name, "Blocks");
148-
+ MicroTimingLoggerManager.setTickStage(this, TickStage.TILE_TICK); // TISCM Micro Timing logger
149-
this.tickPending();
150-
+ CarpetProfiler.end_current_section();
149+
- this.profiler.endStartSection("tickPending");
150+
- this.tickPending();
151+
+ this.worldInfo.setGameTime(this.worldInfo.getGameTime() + 1L);
152+
+ if (this.getGameRules().getBoolean("doDaylightCycle"))
153+
+ {
154+
+ this.worldInfo.setDayTime(this.worldInfo.getDayTime() + 1L);
155+
+ }
156+
+
157+
+ this.profiler.endStartSection("tickPending");
158+
+ CarpetProfiler.start_section(world_name, "Tile Tick");
159+
+ MicroTimingLoggerManager.setTickStage(this, TickStage.TILE_TICK); // TISCM Micro Timing logger
160+
+ this.tickPending();
161+
+ CarpetProfiler.end_current_section();
151162
+ } // end extra indent
163+
+
152164
this.profiler.endStartSection("tickBlocks");
153-
+ CarpetProfiler.start_section(world_name, "Blocks");
165+
+ CarpetProfiler.start_section(world_name, "Chunk Tick");
154166
this.tickBlocks();
155167
+ CarpetProfiler.end_current_section();
156-
+ MicroTimingLoggerManager.setTickStage(this, TickStage.PLAYER_CHUNK_MAP); // TISCM Micro Timing logger
168+
+
157169
this.profiler.endStartSection("chunkMap");
170+
+ CarpetProfiler.start_section(world_name, "Player Chunk Map");
171+
+ MicroTimingLoggerManager.setTickStage(this, TickStage.PLAYER_CHUNK_MAP); // TISCM Micro Timing logger
158172
this.playerChunkMap.tick();
173+
+ CarpetProfiler.end_current_section();
159174
+
160175
+ if (TickSpeed.process_entities)
161176
+ { // CM extra indent to skip processing of entities
@@ -177,11 +192,14 @@
177192
+ this.getLightingEngine().procLightUpdates();
178193
+ }
179194
this.profiler.endSection();
195+
+ CarpetProfiler.start_section(world_name, "Block Events");
180196
+ MicroTimingLoggerManager.setTickStage(this, TickStage.BLOCK_EVENT); // TISCM Micro Timing logger
181197
this.sendQueuedBlockEvents();
198+
+ CarpetProfiler.end_current_section();
182199
this.insideTick = false;
183200
}
184-
@@ -270,7 +358,7 @@
201+
202+
@@ -270,7 +364,7 @@
185203
}
186204
}
187205

@@ -190,7 +208,7 @@
190208
}
191209
}
192210

193-
@@ -306,6 +394,13 @@
211+
@@ -306,6 +400,13 @@
194212
{
195213
if (this.allPlayersSleeping && !this.isRemote)
196214
{
@@ -204,7 +222,7 @@
204222
for (EntityPlayer entityplayer : this.playerEntities)
205223
{
206224
if (!entityplayer.isSpectator() && !entityplayer.isPlayerFullyAsleep())
207-
@@ -397,9 +492,11 @@
225+
@@ -397,9 +498,11 @@
208226
boolean flag1 = this.isThundering();
209227
this.profiler.startSection("pollingChunks");
210228

@@ -216,7 +234,7 @@
216234
Chunk chunk = iterator.next();
217235
int j = chunk.x * 16;
218236
int k = chunk.z * 16;
219-
@@ -407,7 +504,20 @@
237+
@@ -407,7 +510,20 @@
220238
chunk.enqueueRelightChecks();
221239
this.profiler.endStartSection("tickChunk");
222240
chunk.tick(false);
@@ -237,23 +255,23 @@
237255

238256
if (flag && flag1 && this.rand.nextInt(100000) == 0)
239257
{
240-
@@ -434,6 +544,7 @@
258+
@@ -434,6 +550,7 @@
241259
}
242260

243261
this.profiler.endStartSection("iceandsnow");
244262
+ MicroTimingLoggerManager.setTickStageDetail(this, "Ice&Snow"); // TISCM Micro Timing logger
245263

246264
if (this.rand.nextInt(16) == 0)
247265
{
248-
@@ -460,6 +571,7 @@
266+
@@ -460,6 +577,7 @@
249267
}
250268

251269
this.profiler.endStartSection("tickBlocks");
252270
+ MicroTimingLoggerManager.setTickStageDetail(this, "RandomTick"); // TISCM Micro Timing logger
253271

254272
if (i > 0)
255273
{
256-
@@ -493,13 +605,21 @@
274+
@@ -493,13 +611,21 @@
257275
}
258276
}
259277
}
@@ -276,7 +294,7 @@
276294
{
277295
BlockPos blockpos = this.getHeight(Heightmap.Type.MOTION_BLOCKING, pos);
278296
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockpos, new BlockPos(blockpos.getX(), this.getHeight(), blockpos.getZ()))).grow(3.0D);
279-
@@ -625,12 +745,16 @@
297+
@@ -625,12 +751,16 @@
280298

281299
private void tickBlock(NextTickListEntry<Block> blockTickEntry)
282300
{
@@ -293,7 +311,7 @@
293311
}
294312

295313
public void tickEntity(Entity entityIn, boolean forceUpdate)
296-
@@ -1021,26 +1145,54 @@
314+
@@ -1021,26 +1151,54 @@
297315

298316
public void addBlockEvent(BlockPos pos, Block blockIn, int eventID, int eventParam)
299317
{

src/main/java/carpet/utils/CarpetProfiler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public class CarpetProfiler
2323
private static long current_tick_start = 0;
2424
private static String [] GENERAL_SECTIONS = {"Network", "Autosave"};
2525
private static String [] DIMENSIONS = {"Overworld","The End","The Nether"};
26-
private static String [] SECTIONS = {"Spawning","Blocks","Entities","Tile Entities","Entities(client)","Tile Entities(client)","Villages"};
26+
private static String [] SECTIONS = {
27+
"Spawning","Blocks","Entities","Tile Entities","Entities(client)","Tile Entities(client)","Villages", // legacy CM
28+
"Tile Tick", "Chunk Tick", "Block Events", "Player Chunk Map" // TIS CM
29+
};
2730

2831
public static void prepare_tick_report(int ticks)
2932
{

0 commit comments

Comments
 (0)