fix: metadata-only update() never rewrites the noun record — the unconditional whole-vector save turned per-entity stat touches into full rewrites+fsync, amplifying read-heavy sweeps into disk saturation on a production deployment
All checks were successful
CI / Node 22 (push) Successful in 2m53s
CI / Node 24 (push) Successful in 2m46s
CI / Bun (latest) (push) Successful in 3m0s

Also: idle PathResolver stats tick no longer logs NaN% every minute (logs
only on new traffic, via prodLog); graph-lsm-* key family recognized as
system resources (kills the per-boot unknown-key warning on provider-backed
brains). Four regression pins in tests/integration/update-write-granularity.
This commit is contained in:
David Snelling 2026-07-29 10:42:50 -07:00
parent 64049631bc
commit cb717be275
4 changed files with 155 additions and 15 deletions

View file

@ -57,6 +57,7 @@ export class PathResolver {
// Statistics
private cacheHits = 0
private cacheMisses = 0
private lastLoggedLookups = 0 // last total the maintenance tick logged stats at
private metadataIndexHits = 0
private metadataIndexMisses = 0
private graphTraversalFallbacks = 0
@ -519,10 +520,14 @@ export class PathResolver {
}
}
// Log cache statistics (in production, send to monitoring)
const hitRate = this.cacheHits / (this.cacheHits + this.cacheMisses)
if ((this.cacheHits + this.cacheMisses) % 1000 === 0) {
console.log(`[PathResolver] Cache stats: ${Math.round(hitRate * 100)}% hit rate, ${this.pathCache.size} entries, ${this.hotPaths.size} hot paths`)
// Log cache statistics only when there is new traffic to report — an
// idle resolver stays silent. 0/0 lookups previously rendered
// "NaN% hit rate" (and the %1000 gate passes at zero), which spammed
// production journals once a minute on every idle VFS.
const totalLookups = this.cacheHits + this.cacheMisses
if (totalLookups > 0 && totalLookups !== this.lastLoggedLookups && totalLookups % 1000 === 0) {
this.lastLoggedLookups = totalLookups
prodLog.debug(`[PathResolver] Cache stats: ${Math.round((this.cacheHits / totalLookups) * 100)}% hit rate, ${this.pathCache.size} entries, ${this.hotPaths.size} hot paths`)
}
}, 60000) // Every minute
// Cache maintenance must never keep the host process alive.