Skip to content

The one-line SQL comment split test checks a linear ratio, so a newline scan to the end of the text fails it - #335

Merged
zlareb1 merged 3 commits into
mainfrom
fix/sql-split-scaling-test
Nov 7, 2026
Merged

zlareb1 merged 3 commits into
mainfrom
fix/sql-split-scaling-test

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

...

Why

test_one_line_sql_with_a_comment_after_every_semicolon_splits_in_bounded_time exists to catch a split of SELECT 1; /* c */ … on one line that turns quadratic, and it cannot. Its likeliest regression is dropping the next_start limit from text.find("\n", end, next_start) in extractor/loom_extractor/sql.py, which makes every ; scan to the end of the text. On a one-line script that changes no output, so only time shows it, and the scan runs in C: at 100,000 statements the split still ends within the fixed 10 s bound. With that line changed, the test passes on main.

The test now times 10,000 and 160,000 statements with the tracer off and asserts the larger costs under 24 times the smaller, plus 50 ms for timer noise. A linear split costs about 17 times here; the regression above costs about 50. A warm-up call keeps the sqlglot and dialect import out of the small timing. _cpu is the tracer-off timing _within already used (from #297), so both share it, and it now also runs gc.collect() and keeps the garbage collector off while it times: a full collection walks every earlier test's heap in the worker and would land on one side of the ratio only.

Scope and risk

One unit test, plus _within split into _cpu and the bound check. Every _within caller (the hostile Markdown, TOML, HTML and SQL inputs) now times with the collector off as well; all pass. test_many_sql_statements_on_one_line_split_in_bounded_time keeps its fixed bound: its input has no comments, so the bounded finds never run for it.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none.
  • Rollback: revert the test.

Tests

  • The new test passes with and without --cov=extractor; the _within callers pass too (-k "linear_time or bounded_time": 6 passed).
  • With next_start dropped from the ; line's newline search, it fails in both modes at this head: assert 8.01 < 24 * 0.139 + 0.05 and, under coverage, assert 10.09 < 24 * 0.269 + 0.05. main's version of the test passes with the same change.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code; the probe and the timings were run by hand.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version.
  • The frontend builds and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1 zlareb1 changed the title The one-line SQL split test checks that its time scales linearly, not a fixed bound The one-line SQL split test checks that its time scales linearly, timed without a tracer Nov 7, 2026
…ne scan to the end of the text fails it

With a newline search from each ';' not stopped at the next token, the 100,000-statement split still ran under the fixed 10 s bound (the scan runs in C), so the test named for bounded time passed on a quadratic split. It now times 10,000 and 160,000 statements, tracer off, and asserts the larger costs under 24 times the smaller: a linear split costs about 17, that regression about 50. _cpu is the timing _within uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the fix/sql-split-scaling-test branch from 545f789 to 9e94f34 Compare November 7, 2026 08:49
@zlareb1 zlareb1 changed the title The one-line SQL split test checks that its time scales linearly, timed without a tracer The one-line SQL comment split test checks a linear ratio, so a newline scan to the end of the text fails it Nov 7, 2026
zlareb1 and others added 2 commits November 7, 2026 08:53
… names the collector

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 5fc813b into main Nov 7, 2026
34 checks passed
@zlareb1
zlareb1 deleted the fix/sql-split-scaling-test branch November 7, 2026 09:39
@zlareb1 zlareb1 mentioned this pull request Nov 12, 2026
3 tasks done
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.

1 participant