mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6844
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5608
Author: @kolacheee
Created: 8/28/2026
Status: ✅ Merged
Merged: 8/28/2026
Merged by: @kolacheee
Base:
staging← Head:feat/5592-phase3-write-cost📝 Commits (2)
04360aaperf(storage): share unchanged rows across write paths — rows are immutable once installed941bfc5style: format lazy-chat-units regression📊 Changes
3 files changed (+84 additions, -6 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/db/file-backed-store.ts(+26 -6)📝
scripts/regressions/lazy-chat-units.regression.ts(+57 -0)📄 Description
Why
Part of #5592 — the largest remaining per-write cost from the original #4730 diagnosis. Every insert cloned the ENTIRE resident message table (
target.map(cloneRow)— O(rows) object clones per message), and each transaction's first mutation per table deep-copied the whole array again. On the large profiles that produced the GC-fatal ~430 MB allocation spikes, sending one message allocated a full copy of every resident row.Stacked on #5607 (both touch the store; merge that first and this rebases clean).
What
The store's mutation paths already REPLACE rows rather than mutating them — with exactly one exception found by audit: the set-null cascade wrote
nullinto live row objects in place. That last mutator is now copy-on-write, which promotes row-object immutability to a store-wide invariant, and sharing becomes safe everywhere:slice()of the table instead of per-row clones (~8 bytes/row transient instead of a full object clone per row),Update paths already shared unmatched rows, so read-side behavior is unchanged: selects clone at projection (verified in #5597), so no caller ever held a live row reference.
Regressions
New block pins the invariant behaviorally: a rolled-back set-null must leave the child's foreign key intact in memory and on disk. Verified to FAIL under the dangerous half-state (shallow snapshots while the in-place mutator still existed) and pass with both halves — the half-state is precisely what a future in-place mutation would recreate, so the test guards the invariant, not just this change. Full local node suite 155/161 (only the six known Windows-checkout lanes), message-sharding green in both lazy and eager modes.
Test plan
pnpm checkon a non-Windows checkoutpnpm regressionReferences #5592 and #4730 (do not auto-close).
Summary by CodeRabbit
Performance
Bug Fixes
Tests
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.