diff --git a/.claude/knowledge/journal/2026-11-25.md b/.claude/knowledge/journal/2026-11-25.md new file mode 100644 index 000000000..5d1028869 --- /dev/null +++ b/.claude/knowledge/journal/2026-11-25.md @@ -0,0 +1,9 @@ +# Learning journal 2026-11-25 + +### 2026-11-25: Results and lifecycle — Keep peak memory flat in row-building fast paths: stream per-row values, chunk numpy tolist +**Context:** In PR #1078, `_convert_columnar_table` first collected every per-row value list and only then called `_create_rows`. A reviewer flagged the extra peak memory: 107 MB against 88 MB on main for a 200k x 4 table. Separately, walking a numpy object array one row at a time created a view per row, which cost more than the Row construction being removed. Calling `tolist()` on 1024-row chunks fixed the speed without raising peak memory. Calling `tolist()` on the whole array raised peak memory by about 14%. +**Rule:** When optimizing result-row conversion, pass a generator of per-row values instead of a materialized list, convert numpy object arrays with `tolist()` in bounded chunks instead of row-by-row views or one full `tolist()`, and report peak traced memory against main alongside timings. + +### 2026-11-25: Results and lifecycle — Prove fast-path object construction is equivalent to the public factory +**Context:** PR #1078 added `_create_rows`, which builds `Row` objects directly with `tuple.__new__` and a `__dict__` write, skipping `Row.__call__`, `__new__` and `__setattr__`. Its tests compare the result with `fields(*values)` for tuple, list, numpy, generator, short and empty inputs. They check type, value types, that `__fields__` is the same object, repr, asDict, attribute and key access, pickle bytes, that rows stay read-only, the exact ValueError message, and rows on both sides of the 1024-row chunk boundaries. +**Rule:** When a performance fast path bypasses a class's normal constructor, test it against the original factory across every input shape for type, repr, equality, pickle bytes, field identity, immutability, exact error messages and chunk-boundary row counts. diff --git a/.claude/knowledge/lessons.md b/.claude/knowledge/lessons.md index 3f64682d5..c73627c60 100644 --- a/.claude/knowledge/lessons.md +++ b/.claude/knowledge/lessons.md @@ -1,6 +1,6 @@ # Lessons - + ## Backend contracts and configuration - L-0001 (1×, log:2026-08-13): When changing cursor.description type_code strings, update every downstream conversion branch that matches them. @@ -40,6 +40,8 @@ - L-0032 (1×, #1022): KERNEL_REV changes CI source only. Shipping a kernel fix requires a released wheel and matching packaging floor/lock update, plus an in-repo E2E regression. - L-0033 (1×, #1020): Prove optional C acceleration actually executes and skip when unavailable. Choose input/output protocols separately and verify encoded bytes and nesting limits against the fallback. - L-0034 (1×, #1016): Carry sync result metadata into async get_execution_result. Read numModifiedRows from the existing terminal FINISHED_STATE status response via the shared helper, avoiding an extra RPC. +- L-0051 (1×, #1078): In row-conversion fast paths, stream per-row values via generators, convert numpy object arrays with tolist() in bounded chunks (not per-row views or one full tolist()), and report peak traced memory vs main with timings. +- L-0052 (1×, #1078): Fast paths bypassing a class constructor must match the public factory across all input shapes: type, repr, equality, pickle bytes, field identity, immutability, exact error messages and chunk-boundary row counts. ## Logging and concurrency - L-0035 (2×, #924): pyo3-log caches effective logger levels. Reset its cache after relevant level changes/session setup and isolate cached state in tests. @@ -57,3 +59,6 @@ - L-0045 (1×, #1004): Recheck capability claims after tool upgrades; replacing version numbers inside old support statements does not validate them. - L-0046 (1×, #1013): Confirm targeted regression tests fail when their guarded check is removed; inject inputs where earlier sanitization cannot neutralize the case. - L-0047 (1×, #1045): Secret-bearing CI steps must run Python isolated or from a neutral directory, preventing checkout modules from shadowing trusted imports. + +## Release and packaging +- L-0050 (1×, #1079): Before a changelog claims a security dependency update, raise the pyproject.toml minimum or state it is lock-only; poetry.lock does not constrain installers of the published package.