[PR #1093] [MERGED] fix(slurp2): stop the world tick freezing the Engine every 5 minutes (0.2.41) #1292

Closed
opened 2026-10-21 05:07:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1093
Author: @Gunterlie
Created: 9/26/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @Gunterlie

Base: staging ← Head: hotfix/slurp2-settings-cache


📝 Commits (3)

  • df1d891 fix(slurp2): cache normalized settings so the world tick stops freezing the Engine
  • 8bd0335 fix(slurp2): yield to the event loop between world tick steps
  • c391998 docs(slurp2): describe the 0.2.41 tick fix without an unmeasured guarantee

📊 Changes

15 files changed (+482 additions, -391 deletions)

View changed files

➕ artifacts/slurp2-0.2.41.zip (+0 -0)
📝 catalog/catalog.json (+8 -8)
📝 catalog/notes.json (+6 -6)
📝 catalog/v2/catalog.json (+8 -8)
📝 catalog/v2/notes.json (+6 -6)
📝 catalog/v3/catalog.json (+8 -8)
📝 catalog/v3/notes.json (+6 -6)
📝 packages/slurp2/CHANGELOG.md (+4 -0)
📝 packages/slurp2/client.js (+51 -51)
📝 packages/slurp2/manifest.json (+5 -5)
📝 packages/slurp2/server.mjs (+338 -291)
📝 packages/slurp2/src/engine/packages/client/src/slp/features/onboarding/slp-release.ts (+8 -1)
📝 packages/slurp2/src/engine/packages/server/src/slp/features/world/slp-world-operation.ts (+17 -0)
📝 packages/slurp2/src/engine/packages/server/src/slp/modules/settings/slp-settings.ts (+16 -0)
📝 scripts/build-feature-packages.mjs (+1 -1)

📄 Description

Pull request

Linked issue

Closes #1094

Emergency hotfix for SonaGate's report.

Why this change

Every tickMinutes (default 5), the [slurp-world] tick held the Engine's event loop for about 7 s. Every other package, API route and open tab froze until it finished. SonaGate's CPU profile of one freeze put 4.4 s of the 7 s inside Slurp's getSettings() → normalizeSlurpSettings, which ran the full zod validation of the settings object on every call. The tick calls it many times per pass. Most of the remaining 1.5 s was GC from those parses.

What changed

  • Settings cache (modules/settings/slp-settings.ts): normalizeSlurpSettings keeps the last stored raw string (or null before the first save) and its parsed result. Callers get a structuredClone, so a caller that changes its copy cannot corrupt the cache. Object inputs (the updateSettings path) still parse every time. Any settings write stores a new string, so the next read misses the cache and parses again.
  • Tick yields (features/world/slp-world-operation.ts): the tick's storage calls resolve without real I/O, so a large world ran as one block. Each per-creator, per-commission and per-action loop now awaits setImmediate before its next step, so routes and other packages keep responding during a tick. The world-tick claim and trySlpOperation lock still hold across the yields, so a catch-up that runs in parallel still gets busy.
  • Slurp2 0.2.41: version bump, CHANGELOG and splash release notes. The generated client.js, server.mjs, manifest.json, artifact and catalogs are rebuilt.

Package and security impact

  • Affected package IDs: slurp2
  • Engine compatibility impact: none
  • New or changed permissions/entrypoints: none
  • Restart, storage, update, or uninstall impact: none. No schema or storage change. The cache is in-process only.

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

The agent ran these (built against Marinara-Engine staging 4629eb913, clean):

  • node scripts/build-feature-packages.mjs slurp2, node scripts/typecheck-packages.mjs slurp2, the architecture regression, test-catalog-lanes, validate-package-locales, validate-catalog, catalog-release-notes, git diff --check and Prettier on the changed sources: all pass.
  • An ad-hoc esbuild bundle of slp-settings.ts checked that the cached and uncached results are equal for string, null and object input, that callers get a clone, that a changed clone does not leak into the cache, and that a new string misses the cache. Per call: 0.28 ms cached against 2.9 ms uncached.
  • The 70 regression files that read slp-settings.ts, slp-world-operation.ts or the storage were run against a clean staging worktree and this branch: the pass/fail result is the same for every file (46 pass, 24 fail on both, which is the known pre-existing red set). slurp-world, slurp-world-pulse, slurp2-free-clock and slurp2-simulation-fixes pass.
  • A read-only review found one gap (a null settings row skipped the cache). It is fixed in this branch.

Not verified: the package was not sideloaded into a running Engine, and the freeze was not measured again on a real world. A re-measurement with SonaGate's lag watchdog would confirm the fix.

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

UI evidence (if applicable)

Not applicable (server only).

Summary by CodeRabbit

  • New Features

    • Released Slurp Remastered version 0.2.41.
  • Improvements

    • World-tick processing now pauses between steps.
    • Slurp settings are validated once per change rather than on every read.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Agents/pull/1093 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 9/26/2026 **Status:** ✅ Merged **Merged:** 9/26/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `hotfix/slurp2-settings-cache` --- ### 📝 Commits (3) - [`df1d891`](https://github.com/Pasta-Devs/Marinara-Agents/commit/df1d891dafedc3d58d1a64dc374095fcee8c063b) fix(slurp2): cache normalized settings so the world tick stops freezing the Engine - [`8bd0335`](https://github.com/Pasta-Devs/Marinara-Agents/commit/8bd0335253085e9036f95a07d3c5dd04aa399f8a) fix(slurp2): yield to the event loop between world tick steps - [`c391998`](https://github.com/Pasta-Devs/Marinara-Agents/commit/c391998d241c530916ec07e5f59e9a2855642188) docs(slurp2): describe the 0.2.41 tick fix without an unmeasured guarantee ### 📊 Changes **15 files changed** (+482 additions, -391 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/slurp2-0.2.41.zip` (+0 -0) 📝 `catalog/catalog.json` (+8 -8) 📝 `catalog/notes.json` (+6 -6) 📝 `catalog/v2/catalog.json` (+8 -8) 📝 `catalog/v2/notes.json` (+6 -6) 📝 `catalog/v3/catalog.json` (+8 -8) 📝 `catalog/v3/notes.json` (+6 -6) 📝 `packages/slurp2/CHANGELOG.md` (+4 -0) 📝 `packages/slurp2/client.js` (+51 -51) 📝 `packages/slurp2/manifest.json` (+5 -5) 📝 `packages/slurp2/server.mjs` (+338 -291) 📝 `packages/slurp2/src/engine/packages/client/src/slp/features/onboarding/slp-release.ts` (+8 -1) 📝 `packages/slurp2/src/engine/packages/server/src/slp/features/world/slp-world-operation.ts` (+17 -0) 📝 `packages/slurp2/src/engine/packages/server/src/slp/modules/settings/slp-settings.ts` (+16 -0) 📝 `scripts/build-feature-packages.mjs` (+1 -1) </details> ### 📄 Description # Pull request ## Linked issue Closes #1094 Emergency hotfix for SonaGate's report. ## Why this change Every `tickMinutes` (default 5), the `[slurp-world]` tick held the Engine's event loop for about 7 s. Every other package, API route and open tab froze until it finished. SonaGate's CPU profile of one freeze put 4.4 s of the 7 s inside Slurp's `getSettings()` → `normalizeSlurpSettings`, which ran the full zod validation of the settings object on every call. The tick calls it many times per pass. Most of the remaining 1.5 s was GC from those parses. ## What changed - **Settings cache** (`modules/settings/slp-settings.ts`): `normalizeSlurpSettings` keeps the last stored raw string (or `null` before the first save) and its parsed result. Callers get a `structuredClone`, so a caller that changes its copy cannot corrupt the cache. Object inputs (the `updateSettings` path) still parse every time. Any settings write stores a new string, so the next read misses the cache and parses again. - **Tick yields** (`features/world/slp-world-operation.ts`): the tick's storage calls resolve without real I/O, so a large world ran as one block. Each per-creator, per-commission and per-action loop now awaits `setImmediate` before its next step, so routes and other packages keep responding during a tick. The world-tick claim and `trySlpOperation` lock still hold across the yields, so a catch-up that runs in parallel still gets `busy`. - Slurp2 0.2.41: version bump, CHANGELOG and splash release notes. The generated `client.js`, `server.mjs`, `manifest.json`, artifact and catalogs are rebuilt. ## Package and security impact - Affected package IDs: `slurp2` - Engine compatibility impact: none - New or changed permissions/entrypoints: none - Restart, storage, update, or uninstall impact: none. No schema or storage change. The cache is in-process only. ## Validation - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes The agent ran these (built against Marinara-Engine `staging` 4629eb913, clean): - `node scripts/build-feature-packages.mjs slurp2`, `node scripts/typecheck-packages.mjs slurp2`, the architecture regression, `test-catalog-lanes`, `validate-package-locales`, `validate-catalog`, `catalog-release-notes`, `git diff --check` and Prettier on the changed sources: all pass. - An ad-hoc esbuild bundle of `slp-settings.ts` checked that the cached and uncached results are equal for string, `null` and object input, that callers get a clone, that a changed clone does not leak into the cache, and that a new string misses the cache. Per call: 0.28 ms cached against 2.9 ms uncached. - The 70 regression files that read `slp-settings.ts`, `slp-world-operation.ts` or the storage were run against a clean `staging` worktree and this branch: the pass/fail result is the same for every file (46 pass, 24 fail on both, which is the known pre-existing red set). `slurp-world`, `slurp-world-pulse`, `slurp2-free-clock` and `slurp2-simulation-fixes` pass. - A read-only review found one gap (a `null` settings row skipped the cache). It is fixed in this branch. Not verified: the package was not sideloaded into a running Engine, and the freeze was not measured again on a real world. A re-measurement with SonaGate's lag watchdog would confirm the fix. ## Documentation impact - [x] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) Not applicable (server only). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Released Slurp Remastered version 0.2.41. * **Improvements** * World-tick processing now pauses between steps. * Slurp settings are validated once per change rather than on every read. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-21 05:07:45 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Agents#1292
No description provided.