Skip to content

Commit f13f63a

Browse files
author
peco-engineer-bot[bot]
committed
learn: retrospective learnings
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 75a0d5d commit f13f63a

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Learning journal 2026-11-25
2+
3+
### 2026-11-25: Results and lifecycle — Keep peak memory flat in row-building fast paths: stream per-row values, chunk numpy tolist
4+
**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%.
5+
**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.
6+
7+
### 2026-11-25: Results and lifecycle — Prove fast-path object construction is equivalent to the public factory
8+
**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.
9+
**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.

‎.claude/knowledge/lessons.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Lessons
22

3-
<!-- distilled-through: 2026-11-18 -->
3+
<!-- distilled-through: 2026-11-25 -->
44

55
## Backend contracts and configuration
66
- 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 @@
4040
- 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.
4141
- 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.
4242
- 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.
43+
- 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.
44+
- 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.
4345

4446
## Logging and concurrency
4547
- 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 @@
5759
- L-0045 (1×, #1004): Recheck capability claims after tool upgrades; replacing version numbers inside old support statements does not validate them.
5860
- L-0046 (1×, #1013): Confirm targeted regression tests fail when their guarded check is removed; inject inputs where earlier sanitization cannot neutralize the case.
5961
- L-0047 (1×, #1045): Secret-bearing CI steps must run Python isolated or from a neutral directory, preventing checkout modules from shadowing trusted imports.
62+
63+
## Release and packaging
64+
- 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.

0 commit comments

Comments
 (0)