@@ -127,6 +127,8 @@ public record Snapshot(
127127 long lastMutationStartBukkitTick ,
128128 long lastMutationEndBukkitTick ,
129129 long lastMutationElapsedNanos ,
130+ long lastMutationWriteElapsedNanos ,
131+ long lastMutationInspectionElapsedNanos ,
130132 int restoredCount ,
131133 int skippedExternalCount ,
132134 int restoreFailureCount ,
@@ -156,6 +158,8 @@ public String summary() {
156158 + " mutationStartBukkitTick=" + lastMutationStartBukkitTick
157159 + " mutationEndBukkitTick=" + lastMutationEndBukkitTick
158160 + " mutationElapsedMs=" + String .format (Locale .ROOT , "%.6f" , lastMutationElapsedNanos / 1_000_000.0D )
161+ + " mutationWriteMs=" + String .format (Locale .ROOT , "%.6f" , lastMutationWriteElapsedNanos / 1_000_000.0D )
162+ + " mutationInspectionMs=" + String .format (Locale .ROOT , "%.6f" , lastMutationInspectionElapsedNanos / 1_000_000.0D )
159163 + " restored=" + restoredCount
160164 + " skippedExternal=" + skippedExternalCount
161165 + " restoreFailures=" + restoreFailureCount
@@ -482,6 +486,10 @@ private static Snapshot mutate(Session session, int requestedOperations, Mode mo
482486 applied ++;
483487 }
484488 }
489+ // Keep the synchronous write loop separate from the ownership/PDC
490+ // verification performed by snapshot(). Total mutation time still
491+ // includes the small bookkeeping gap between both phases.
492+ long writeEndNanos = System .nanoTime ();
485493 session .lastMutationRequested = operations ;
486494 session .lastMutationApplied = applied ;
487495 session .skippedExternalCount = skipped ;
@@ -492,7 +500,7 @@ private static Snapshot mutate(Session session, int requestedOperations, Mode mo
492500 mode == Mode .ACTIVE ? "vanilla_furnace_events_primed"
493501 : mode == Mode .DIRECT_WRITE ? "eventless_direct_write"
494502 : "idle_normalized" ,
495- true , startTick , startNanos );
503+ true , startTick , startNanos , writeEndNanos );
496504 }
497505
498506 private static List <Entry > plan (Player owner , int count ) {
@@ -762,14 +770,16 @@ private static List<Block> blocks(List<Entry> entries) {
762770 }
763771
764772 private static Snapshot snapshot (Session session , SceneState state , String detail ) {
765- return snapshot (session , state , detail , false , NO_MUTATION_TICK , 0L );
773+ return snapshot (session , state , detail , false , NO_MUTATION_TICK , 0L , 0L );
766774 }
767775
768776 private static Snapshot snapshot (Session session , SceneState state , String detail ,
769777 boolean captureMutationTiming ,
770- long mutationStartBukkitTick , long mutationStartNanos ) {
778+ long mutationStartBukkitTick , long mutationStartNanos ,
779+ long mutationWriteEndNanos ) {
771780 int owned = 0 ;
772781 int unloaded = 0 ;
782+ long inspectionStartNanos = captureMutationTiming ? System .nanoTime () : 0L ;
773783 try {
774784 for (Entry entry : session .entries ) {
775785 if (!isLoaded (entry )) {
@@ -780,9 +790,12 @@ private static Snapshot snapshot(Session session, SceneState state, String detai
780790 }
781791 } finally {
782792 if (captureMutationTiming ) {
793+ long endNanos = System .nanoTime ();
783794 session .lastMutationStartBukkitTick = mutationStartBukkitTick ;
784795 session .lastMutationEndBukkitTick = Bukkit .getCurrentTick ();
785- session .lastMutationElapsedNanos = Math .max (0L , System .nanoTime () - mutationStartNanos );
796+ session .lastMutationElapsedNanos = Math .max (0L , endNanos - mutationStartNanos );
797+ session .lastMutationWriteElapsedNanos = Math .max (0L , mutationWriteEndNanos - mutationStartNanos );
798+ session .lastMutationInspectionElapsedNanos = Math .max (0L , endNanos - inspectionStartNanos );
786799 }
787800 }
788801 Counts counts = session .counts ;
@@ -791,14 +804,15 @@ private static Snapshot snapshot(Session session, SceneState state, String detai
791804 owned , unloaded , counts .furnace , counts .blastFurnace , counts .smoker ,
792805 counts .beeHive , counts .beeNest , session .revision , session .lastMutationRequested ,
793806 session .lastMutationApplied , session .lastMutationStartBukkitTick , session .lastMutationEndBukkitTick ,
794- session .lastMutationElapsedNanos , session .restoredCount , session .skippedExternalCount ,
807+ session .lastMutationElapsedNanos , session .lastMutationWriteElapsedNanos ,
808+ session .lastMutationInspectionElapsedNanos , session .restoredCount , session .skippedExternalCount ,
795809 session .restoreFailureCount , session .inspectionFailureCount , detail );
796810 }
797811
798812 private static Snapshot absent (UUID ownerId , String detail ) {
799813 return new Snapshot (ownerId , SceneState .ABSENT , null , 0 , 0 , 0 , 0 , 0 , 0 ,
800814 0 , 0 , 0 , 0 , 0 , 0L , 0 , 0 , NO_MUTATION_TICK , NO_MUTATION_TICK ,
801- 0L , 0 , 0 , 0 , 0 , detail );
815+ 0L , 0L , 0L , 0 , 0 , 0 , 0 , detail );
802816 }
803817
804818 private static Session requireSession (UUID ownerId ) {
@@ -877,6 +891,8 @@ private static final class Session {
877891 private long lastMutationStartBukkitTick ;
878892 private long lastMutationEndBukkitTick ;
879893 private long lastMutationElapsedNanos ;
894+ private long lastMutationWriteElapsedNanos ;
895+ private long lastMutationInspectionElapsedNanos ;
880896 private int restoredCount ;
881897 private int skippedExternalCount ;
882898 private int restoreFailureCount ;
0 commit comments