You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next steps:
- Prove performance is optimal (update bson-js to latest, re-run all benchmarks)
- Fix broken consumer BSON imports (rpc, mongo, broker, framework-debug-api)
- Full test suite verification after consumer migrations
Handover document: .claude/handover.md
-**Failing tests**: none — all 360 BSON tests pass, all 1975 type tests pass (4 pre-existing skips)
37
-
-**Master worktree**: `/Users/marc/bude/deepkit-master` — fully built, has compiled benchmarks for type and bson
38
-
-**Verification command**: `git log --oneline -5` (expect: top commit is `perf(bson): fix array serialization/deserialization`)
36
+
-**Failing tests**: none known for bson/type/type-compiler — consumer packages (rpc, mongo, broker, framework-debug-api) have broken BSON imports that will fail at compile
-**Verification command**: `git log --oneline -5` (expect: 21 semantic commits, top is `chore: update handover...`, below it `docs(website)...`, `fix: update remaining packages...`, etc.)
39
39
40
40
## Next Steps
41
-
1.**Add bson-js comparison numbers to PR description** — `docs/pr-description.md` needs the vs-bson-js numbers. User explicitly requested: "these numbers must be mentioned in the pr-description so people know what they get." Use the data from Benchmark Data section below.
42
-
2.**Execute commit plan** — Follow `.claude/commit-plan.md` to squash 306+ commits into semantic history
43
-
3.**Verify final state** — Tests must pass, commit history must be clean
41
+
1.**Prove performance is still optimal** — Run BSON and type benchmarks vs master and bson vs bson-js. bson-js should be updated to newest version first. Benchmark files:
42
+
- feat/next perf-regression: `node --import @deepkit/run --test packages/bson/tests/serialize/perf-regression.spec.ts` and `tests/deserialize/perf-regression.spec.ts`
- type benchmarks: `packages/type/benchmarks/compare-bench.ts` (feat/next), master has equivalent in its worktree
45
+
2.**Fix consumer package BSON imports** — See Suppressed Issues for the full list. Key broken packages: rpc, mongo, broker, broker-redis, framework-debug-api. See `docs/pr-description.md` "Open TODOs" section for migration details.
46
+
3.**Verify final state** — Full test suite must pass after consumer migrations
44
47
45
48
## Alignment Check
46
-
-**Goal**: Add bson-js comparison numbers to PR description, then clean commit history for PR
47
-
-**Scope boundary**: Do NOT fix consumer package imports yet. The array perf issue is FIXED — no more investigation needed.
48
-
-**Plan file**: `.claude/commit-plan.md` — execute ONLY after benchmark numbers are added to PR description
-**Goal**: Get feat/next branch ready for PR — all tests passing, performance proven, clean commit history
50
+
-**Scope boundary**: The commit plan is DONE (21 commits). Focus is now on (a) proving perf is optimal, (b) fixing broken consumer imports. Do NOT re-squash commits.
51
+
-**Plan file**: none — commit plan was executed this session
52
+
-**Recovery**: `git reset --hard feat/next-backup`restores the 306+ commit history (loses clean squash)
-[ ]**Verify final state** — Tests pass, history clean. [status: pending, blocked by commit plan]
55
+
-[ ]**Update bson-js to latest version** — Check if `bson` npm package in the repo is latest. Update and re-run comparison benchmarks. [status: pending]
56
+
-[ ]**Run BSON perf benchmarks vs master** — Run both serialize and deserialize perf-regression tests on feat/next AND master compare-bench.ts. Verify all ratios hold. [status: pending]
57
+
-[ ]**Run type perf benchmarks vs master** — Ensure all 12 type benchmarks still beat master. [status: pending]
- ✅ [2026-02-08]**`guardObjectFast` handles BOTH `is()` AND `validate()`** — Registered for both objectLiteral and class. `guardObjectScore` is only for union scoring.
113
-
- ✅ [2026-02-08]**Medium model perf gap was architectural — FIXED** — Master inlines ALL index signature handling. feat/next now does too via `forKey()` + `state.forKey(key).build()`.
114
-
- ✅ [2026-02-08]**`getBSONSerializer` returns `[sharedBuffer, size]` — buffer is reused across ALL serializers globally**. Callers must copy with `buf.slice(0, size)` if they need to keep the data past the next serialize call.
115
-
- ✅ [2026-02-08]**BSONBuildState `forIndex()` must NOT increment depth** — Array loop bodies share a single code path (no code bloat). Incrementing depth caused array element objects to be extracted to separate functions at depth >= MAX_DEPTH (3), making array serialization 60-90x slower. The MongoDB cursor response `{ cursor: { firstBatch: Item[] } }` hits depth 3 at `Item` — the most common real-world pattern.
116
-
- ✅ [2026-02-08]**Shape JIT must handle primitive arrays (string[], number[], boolean[])** — Without inline support, any document with primitive array fields (e.g., `tags: string[]`) causes shape JIT BAILOUT, forcing ALL elements through the slow `buildDocumentBody` path with per-field name matching.
117
-
- ⚠️ [2026-02-08]**BenchSuite executor does NOT prevent V8 dead-code elimination** — Use a `sink` variable: `suite.add('name', () => { sink = fn(data); })`.
118
-
- ⚠️ [2026-02-08]**Master BSON benchmark needs compiled JS** — Create `tsconfig.bench.json` with `"reflection": true`, compile with `npx tsc -p packages/bson/tsconfig.bench.json`, run from `dist/bench/`.
110
+
- ✅ [2026-02-08]**`getBSONSerializer` returns `[sharedBuffer, size]` — buffer is reused across ALL serializers globally**. Callers must copy with `buf.slice(0, size)`.
111
+
- ✅ [2026-02-08]**BSONBuildState `forIndex()` must NOT increment depth** — Incrementing depth caused extraction at MAX_DEPTH=3, 60-90x slower for cursor responses.
112
+
- ✅ [2026-02-08]**Shape JIT must handle primitive arrays** — Without inline, documents with `string[]`/`number[]` cause shape JIT BAILOUT.
113
+
- ✅ [2026-02-08]**BenchSuite executor does NOT prevent V8 dead-code elimination** — Use `sink` variable.
114
+
- ✅ [2026-02-08]**Master BSON benchmark needs compiled JS** — `tsconfig.bench.json` with `"reflection": true`, compile with tsc, run from `dist/bench/`.
115
+
- ⚠️ [2026-02-08]**BSON array deserialize improvement limited at scale** — Single-doc sensor 1.8x faster, but sensor[]1K cursor ~same speed. Setup/overhead improvement is amortized; per-element byte-reading cost is similar between branches (~55-60ns/sensor). Serialize arrays DO scale (12x faster) due to buffer reuse.
119
116
120
117
## Dead Ends
121
118
-[2026-02-04]**"Assumed order" fast-path** — WRONG for MongoDB which returns arbitrary field order.
@@ -128,13 +125,13 @@ Test migration: Jest → node:test + @deepkit/run/expect shim
128
125
-[2026-02-07]`packages/mongo/src/mongo-serializer.ts:10` — Imports `BSONBinarySerializer`, `ValueWithBSONSerializer`. Will fail at compile.
129
126
-[2026-02-07]`packages/mongo/src/client/client.ts:10` — Imports `BSONBinarySerializer`. Will fail at compile.
130
127
-[2026-02-07]`packages/broker-redis/src/broker-redis.ts:13` — Imports `AutoBuffer`, uses `getBsonEncoder` (renamed). Will fail at compile.
131
-
-[2026-02-07]`packages/framework-debug-api/src/stopwatch-encoding.ts:7-9` — Uses removed BSON internals. Will fail at compile.
128
+
-[2026-02-07]`packages/framework-debug-api/src/stopwatch-encoding.ts:1-9` — Imports `Writer`, `BaseParser`, `getBSONSizer`, `stringByteLength`. Will fail at compile.
132
129
-[2026-02-07]`packages/broker/src/snapshot.ts` — Uses `getBSONSerializer` return as `Uint8Array` (actually `[Uint8Array, number]`). Will fail at runtime.
133
130
-[2026-02-07]`packages/broker/src/adapters/deepkit-adapter.ts` — Uses `getBsonEncoder` (renamed). Will fail at compile.
134
131
-[2026-02-08]`packages/type/tests/serializer.spec.ts:1153,1180,1204,1363` — 4 tests skipped (`test.skip`): onLoad call (x3), extend with custom type. Pre-existing Jest skips.
135
132
136
133
## Open Questions
137
-
*None — array perf issue resolved.*
134
+
-**BSON array deserialize does NOT benefit from single-doc speedup** — Per-element cost ~55-60ns on both branches. Setup overhead (33ns improvement) is amortized across 1000 elements. Optimization target: investigate if shape JIT can reduce per-element overhead for array deserialization.
138
135
139
136
## Generation Log
140
137
-[2026-02-04] Gen 1-35: BSON rewrite foundations
@@ -153,7 +150,8 @@ Test migration: Jest → node:test + @deepkit/run/expect shim
153
150
-[2026-02-08] Gen 66: Benchmarked both branches. Fixed 9 uncached guard rebuilds. Medium validate/is still slow.
154
151
-[2026-02-08] Gen 67: Inlined index signatures. ALL 12 type benchmarks beat master.
155
152
-[2026-02-08] Gen 68: Ran BSON benchmarks. Found shared-buffer corruption bug in benchmarks. Fixed: all 22 BSON benchmarks beat master. Fixed bson-js comparison benchmark for new API.
156
-
-[2026-02-08] Gen 69: Fixed BSON array perf — 60-90x improvement. Root cause: (1) `forIndex()` incremented depth causing extraction at MAX_DEPTH=3, (2) shape JIT bailed out on primitive arrays. Deepkit now 6-12x faster than bson-js at ALL sizes. Added 12 array perf regression tests (sensor[], mixed[], string[], number[] at 10 and 1000 items in cursor response). Fixed core bson benchmark shared-buffer bug.
153
+
-[2026-02-08] Gen 69: Fixed BSON array perf — 60-90x improvement. Deepkit 6-12x faster than bson-js at ALL sizes.
154
+
-[2026-02-08] Gen 70: Ran all 53 BSON perf-regression tests (pass). Ran master comparison benchmarks. Updated PR description with 3 numbers per benchmark (ops/sec, vs master, vs bson-js). Executed commit plan — squashed 306+ commits into 21 clean semantic commits. Discovered array deserialize does not scale with single-doc improvement.
157
155
158
156
---
159
-
*End of handover. Next: add bson-js numbers to docs/pr-description.md, then execute commit plan.*
157
+
*End of handover. Next: prove perf is optimal (update bson-js, re-run benchmarks), then fix consumer BSON imports.*
0 commit comments