Skip to content

Commit 0bff91e

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 1d8e3bd commit 0bff91e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎.claude/knowledge/learning-log.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,12 @@ until a human merges it. The engineer author phase reads this log (see
190190
- **Context:** PR #1022 was titled as fixing kernel TLS certificate errors, but it only bumped `KERNEL_REV`. That file only sets which kernel commit `kernel-e2e.yml` builds from source for CI. Users installing the `[kernel]` extra still resolve the PyPI release allowed by `pyproject.toml` (`^1.4.0`), which predates the fix. The reviewer also noted there was no in-repo assertion (e.g. in `tests/e2e/test_kernel_tls.py`) to catch the behavior regressing on a later pin bump.
191191
**Rule:** Bumping `KERNEL_REV` changes CI only and ships nothing to users. A kernel-side fix reaches users only after a kernel PyPI release that includes it plus a matching floor bump in `pyproject.toml`/`poetry.lock`. Don't call a pin bump a user-facing fix, and add an in-repo e2e assertion for the behavior so later pin bumps can't silently regress it.
192192

193+
### 2026-11-12: learnings since 2026-11-11T17:26:04Z
194+
- **Context:** PR #1020 switched the Thrift backend to `TBinaryProtocolAccelerated` so replies decode in C. Two things came up. First, that class falls back to pure Python without any error when `thrift.protocol.fastbinary` isn't built, and it only takes the C path when the transport is a `CReadableTransport`, so a plain round-trip test passes without ever running the C decoder. The fix was a test, skipped when fastbinary is absent, that wraps `protocol._fast_decode` with `Mock(wraps=...)` and asserts it was called. Second, the accelerated protocol also changes request *encoding*, and the C encoder rejects structs nested deeper than about 64 levels (for example native array parameters 62+ deep). So the client was built as `TCLIService.Client(accelerated_input, pure_python_output)`, with a test checking that both encoders produce byte-identical requests.
195+
**Rule:** When adopting `TBinaryProtocolAccelerated` (or any optional C-extension fast path), assert the fast path actually ran: skip the test when the extension isn't importable, and wrap or spy the C entry point such as `_fast_decode`. Don't trust a round-trip that also passes on the pure-Python fallback. Also remember the accelerated protocol encodes requests too, and the C encoder has a nesting-depth limit. Decide input and output protocols separately, and pin encoder parity with a byte-equality test.
196+
- **Context:** PR #1020 found that `unsafe_logger.debug("Received response: {}".format(response))` in `thrift_backend.make_request` built the full repr of every Thrift request and response, even though the logger has only a NullHandler by default. For a 100 MiB inline Arrow fetch this made about 400 MB of repr. Peak memory fell from 425 MiB to 200 MiB once the call used lazy `%s` args.
197+
**Rule:** Never pre-format log messages with `.format()` or f-strings when they contain large payloads (requests, responses, result batches). Pass lazy `%s` args (`logger.debug("...: %s", obj)`) so the repr is only built when a handler actually emits the record. Eager formatting costs CPU and memory even when the logger is disabled.
198+
- **Context:** PR #1026 forwarded `telemetry_flush_interval_ms` to the PyO3 kernel `Session`. The PyO3 u64 conversion accepted `True` as 1 ms, and its errors for negative or string values did not name the option. A Python-side check was added before the kernel call: `isinstance(v, bool) or not isinstance(v, int) or v <= 0` raises a `ValueError` that names the option.
199+
**Rule:** When validating an integer option in Python, especially one forwarded to native bindings such as PyO3, explicitly reject `bool`, because `bool` is a subclass of `int` and native int conversions accept `True`/`False` as 1/0. Validate before the native call so the error names the option, rather than surfacing a wrapped conversion error.
200+
193201
--- *Add new entries above this line (oldest→newest); newest sections sort to the bottom.* ---

0 commit comments

Comments
 (0)