Skip to content

Read CQL frames by offset instead of re-slicing the buffer - #93

Merged
TomK merged 1 commit into
masterfrom
framed-transport-read-offset
Nov 6, 2026
Merged

TomK merged 1 commit into
masterfrom
framed-transport-read-offset

Conversation

@TomK

@TomK TomK commented Nov 6, 2026

Copy link
Copy Markdown
Member

Large CQL results take quadratic time to decode: TFramedTransport copies the rest of the frame on every read, and the pure-PHP binary protocol reads one 1–8 byte field at a time. In production, results of roughly 5MB and up hit PHP's 40s max_execution_time inside thrift's substr.

  • Any CQL result: decoded through DalFramedTransport, which reads the frame by offset; decode time is linear in result size.

Test plan

  • New DalFramedTransportTest: frame boundaries, readAll across frames, putBack, unframed passthrough, framed writes, and a 2MB small-field read (failed at 8.6s on the stock transport, passes in milliseconds). Run on PHP 8.5; edge cases also checked on PHP 7.4.
  • Read-only 1000-row SELECT (4.4MB result) on a dev Cassandra 3.11: identical decoded output (md5 match), 3.74s → 0.50s.

🤖 Generated with Claude Code

TFramedTransport copies the rest of the frame on every read, and the
binary protocol reads a CQL result one 1-8 byte field at a time, so
decoding an n-byte result costs O(n^2). A 4.4MB result took 3.7s to
decode; ~5MB exhausts a 40s execution limit. DalFramedTransport serves
reads from the frame by offset, keeping decode linear (15MB in ~1s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TomK
TomK merged commit 1dbe209 into master Nov 6, 2026
6 checks passed
@TomK
TomK deleted the framed-transport-read-offset branch November 6, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants