Riptide is JavaScriptCore’s non-moving garbage collector. Objects remain in place rather than moving between semi-spaces, making its design fundamentally different from V8’s movement-based collector. section 9.3
Its defining optimization is concurrency: most marking runs on background threads while application code continues. A write barrier can force already visited objects back into consideration, creating a retreating wavefront and, under heavy mutation of old objects, a potential death spiral. section 9.3.4
A space-time scheduler prevents nontermination by linking allocation pressure to pause length. JSC reserves headroom, progressively gives the collector more CPU time as allocations consume it, and stops the application if the budget is exhausted. section 9.3.4
A cache that pushes marking backward
A long-lived sessions Map stores old-generation session objects. Each request mutates those objects with fresh request data, copied headers, timestamps, and truncated history. Under sustained allocation and mutation, the collector may revisit the same objects repeatedly; latency rises as JSC throttles the application to finish marking. section 9.3.4
const sessions = new Map(); #A
function handleRequest(req) {
let session = sessions.get(req.sessionId);
if (!session) {
session = { id: req.sessionId, created: Date.now() };
sessions.set(req.sessionId, session);
}
// Every request mutates the long-lived session object
// with fresh short-lived objects
session.lastAccess = Date.now();
session.lastRequest = { #B
url: req.url,
headers: { ...req.headers },
timestamp: Date.now(),
};
session.history = (session.history || [])
.slice(-99)
.concat([req.url]); #C
return buildResponse(req, session);
}
Inspect the request handler to trace how persistent session state receives newly allocated objects on every request. section 9.3.4
