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
-**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
-**Failing tests**: none known for bson/type/type-compiler. Consumer packages (rpc, mongo, broker, framework-debug-api) have broken BSON imports (deferred to separate session).
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
41
+
1.**Investigate BSON deserialize performance ceiling** — Currently only 5–13x faster than bson-js v7 for deserialization. User considers this insufficient. Compare against manually-written optimal deserializer to find bottleneck. Key benchmarks: `packages/bson/tests/deserialize/perf-regression.spec.ts`. Profile shape JIT code path for overhead.
42
+
2.**Fix consumer package BSON imports** — Key broken packages: rpc, mongo, broker, broker-redis, framework-debug-api. See Suppressed Issues for file locations. See `docs/pr-description.md` "Open TODOs" for migration details. (User said: do in separate session)
43
+
3.**Commit the dirty files** — bson v7 upgrade + PR description updates need to be committed.
47
44
48
45
## Alignment Check
49
-
-**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
46
+
-**Goal**: Get feat/next branch ready as Deepkit v2 — all tests passing, performance maximized, clean history
47
+
-**Scope boundary**: Consumer package migration is deferred. Do NOT re-squash commits. Focus is on (a) deserialize perf investigation, (b) eventually fixing consumer imports.
48
+
-**Plan file**: none
52
49
-**Recovery**: `git reset --hard feat/next-backup` restores the 306+ commit history (loses clean squash)
53
50
54
51
## Tasks
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]
-[ ]**Investigate BSON deserialize perf ceiling** — Deserialize is only 5–13x vs bson-js v7 (serialize is 2–224x). Write a manually-optimized deserializer for a sensor doc to find theoretical max, then compare with generated JIT code. Identify specific overhead sources. [status: pending]
- ✅ [2026-02-06]**Type compiler resolves `T | undefined` as optional T, not union** — `prop.optional = true` and `prop.type = UUID`.
@@ -110,9 +102,10 @@ Test migration: Jest → node:test + @deepkit/run/expect shim
110
102
- ✅ [2026-02-08]**`getBSONSerializer` returns `[sharedBuffer, size]` — buffer is reused across ALL serializers globally**. Callers must copy with `buf.slice(0, size)`.
111
103
- ✅ [2026-02-08]**BSONBuildState `forIndex()` must NOT increment depth** — Incrementing depth caused extraction at MAX_DEPTH=3, 60-90x slower for cursor responses.
112
104
- ✅ [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.
105
+
- ✅ [2026-02-08]**BSON array deserialize improvement limited at scale** — Per-element cost ~55-60ns on both branches. Setup overhead amortized across 1000 elements.
106
+
- ⚠️ [2026-02-08]**bson-js v7 dropped default export** — Must use `import * as bson from 'bson'` instead of `import bson from 'bson'`. Also removed `@types/bson` (v7 ships own types).
107
+
- ⚠️ [2026-02-08]**bson-js v7 is 2–5x faster than v4** — Our absolute perf unchanged, but comparison ratios drop. Thresholds in perf-regression tests adjusted.
108
+
- ⚠️ [2026-02-08]**bson-js has no pre-allocated buffer API** — `serialize()` always allocates `Buffer.allocUnsafe()`. No `serializeInto()`. Buffer alloc + GC is their top overhead for small docs (~50-80ns).
116
109
117
110
## Dead Ends
118
111
-[2026-02-04]**"Assumed order" fast-path** — WRONG for MongoDB which returns arbitrary field order.
@@ -129,9 +122,10 @@ Test migration: Jest → node:test + @deepkit/run/expect shim
129
122
-[2026-02-07]`packages/broker/src/snapshot.ts` — Uses `getBSONSerializer` return as `Uint8Array` (actually `[Uint8Array, number]`). Will fail at runtime.
130
123
-[2026-02-07]`packages/broker/src/adapters/deepkit-adapter.ts` — Uses `getBsonEncoder` (renamed). Will fail at compile.
131
124
-[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.
125
+
-[2026-02-08]`packages/bson/tests/deserialize/perf-regression.spec.ts` — 4 thresholds lowered for bson v7: boolean 5→1.5, number 2→1, UUID (ser) 5→2, string[] (ser) 3→1.5. Not regressions — bson-js v7 is faster.
132
126
133
127
## Open Questions
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.
128
+
-**Why is BSON deserialize only 5–13x vs bson-js v7?** — Serialize is 2–224x faster, but deserialize ceiling is 13x. User considers this unacceptable. Need to profile the generated JIT code against a hand-written optimal deserializer to identify specific bottlenecks. Potential areas: shape JIT overhead, field name parsing, object allocation, property assignment.
135
129
136
130
## Generation Log
137
131
-[2026-02-04] Gen 1-35: BSON rewrite foundations
@@ -151,7 +145,8 @@ Test migration: Jest → node:test + @deepkit/run/expect shim
151
145
-[2026-02-08] Gen 67: Inlined index signatures. ALL 12 type benchmarks beat master.
152
146
-[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.
153
147
-[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.
148
+
-[2026-02-08] Gen 70: Executed commit plan — squashed 306+ commits into 21 clean semantic commits.
149
+
-[2026-02-08] Gen 71: Updated bson-js v4→v7. Fixed 26 test imports, adjusted 4 thresholds. Rewrote PR description as "Deepkit v2" with performance summary. All benchmarks re-run sequentially with clean numbers. User flagged deserialize perf ceiling for investigation.
155
150
156
151
---
157
-
*End of handover. Next: prove perf is optimal (update bson-js, re-run benchmarks), then fix consumer BSON imports.*
152
+
*End of handover. Next: investigate BSON deserialize perf ceiling, then fix consumer BSON imports.*
0 commit comments