Skip to content

Housekeeping deleted-sweep purge spikes MSPT (synchronous world save + region-file deletion on main thread) #3018

Description

@tastybento

Summary

The periodic Housekeeping deleted-sweep purge runs a full world save and region-file deletion on the main server thread, producing a large MSPT spike each time it fires. Observed while spot-checking an unrelated settings-GUI perf fix (#3016): the GUI itself was no longer the cost, but a purge landing mid-measurement produced a ~181 ms /mspt max.

Evidence (server log)

08:38:32 [BentoBox] Housekeeping: saving all worlds before purge...
08:38:32 [BentoBox] Housekeeping: world save complete
08:38:32 [BentoBox] Housekeeping deleted sweep: starting across 2 gamemode(s)
08:38:32 [BentoBox] Purge deleted-sweep: 16 candidate region(s) ... caveblock-world
08:38:32 [BentoBox] Purge deleted: evicted 0 loaded chunk(s) from 12 target region(s)
08:38:32 [BentoBox] Now deleting region files for world caveblock-world
08:38:32 [BentoBox] Purge complete for world caveblock-world: 12 region(s) ...
08:38:32 [BentoBox] ... scanning 'Gusher' world 'gusher_world' ...
08:38:32 [BentoBox] Housekeeping deleted sweep: complete — 2 world(s) processed, 13 region(s) purged in 0s

/mspt immediately after (1-minute window still contains the purge):

08:38:49  avg/min/max, 5s/10s/1m:  7.8/1.5/72.0, 8.6/1.5/72.0, 8.1/1.4/181.0

/mspt before the purge (no purge in window): 1m max was 79.5 ms; the most-recent 5s max was 17.6 ms. The 181 ms peak coincides with the purge.

Suspected cost

  • saveWorld / "saving all worlds before purge" is a synchronous main-thread save.
  • Region-file deletion (Now deleting region files for world ...) is main-thread file I/O.
  • Chunk eviction from target regions.

All of this runs in one tick (log says "13 region(s) purged in 0s"), so it lands as a single heavy tick.

Ideas to investigate

  • Spread the purge across ticks (budgeted per-tick region deletion) instead of one synchronous burst.
  • Move region-file deletion and the pre-purge save off the main thread where the API allows (file deletion is filesystem-only; the save may need main-thread coordination but could use Paper async chunk-save paths).
  • Rate-limit / batch region deletion (N regions per tick).
  • Confirm whether "saving all worlds" is strictly necessary before every sweep, or can be scoped to affected worlds only.

Repro

Run a server with housekeeping deleted-sweep enabled and deletable islands present; watch /mspt (or spark) when the sweep fires. Relevant code: HousekeepingManager / island deletion + region purge path.

Notes

Found while working on #3016 (settings-GUI click-spam MSPT). Filed for later — not part of that PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: PendingWaiting for a developer to start working on this issue.Type: EnhancementImprovement or modification which is usually a new feature.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions