mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1557] [CLOSED] serve: skip tool-body rescans until a closing tag arrives #3530
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3530
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1557
Author: @InB4DevOps
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:perf/tool-call-closing-scan📝 Commits (1)
38dd74eserve: skip tool-body rescans until a closing tag arrives📊 Changes
2 files changed (+77 additions, -1 deletions)
View changed files
📝
serve/frontend.py(+16 -1)➕
serve/test_parser_call_scan.py(+61 -0)📄 Description
Summary
Avoid repeatedly walking an accumulating wrapped tool-call body before a closing
</tool_call>can possibly be present.This is independent of #1542. It contains only the tool-call scan change and tests; no partial-tag optimization, newline-free tracking, profiling instrumentation, native-engine changes or GPU changes.
Standalone validation
Validated against a same-day untouched checkout of upstream main at
fb58e0dbc8399662c0e47c76578c6e878b14f6cf. The candidate checkout contained only these two changed files, excluding all other local optimizations.Tests compare emitted events after each fragment, including fixed/random chunk boundaries, literal tags, consecutive calls, incomplete calls, recovery, reasoning tools and server API behavior. Random tool IDs are excluded from semantic comparisons. Cursor tests assert that structural walks are skipped before a closing candidate and reset for subsequent calls.
git diff --checkpassed.Windows correctness and performance validation: pending.
Measurements
Intel Core i7-12700KF, 20 logical CPUs; Linux 7.0.0-38-generic, glibc 2.39, CPython 3.12.3, Jinja2 3.1.6. Default scheduling/power policy, no affinity pinning. Seven fresh-process samples per checkout with alternating baseline/candidate order, two warmups per case, fixed 16-character chunks, profiling disabled. Fixture creation, validation and hashing are outside timing. No model or GPU was needed.
Median elapsed milliseconds:
At 128 KiB, buffered parsing used 91.6% less elapsed time and streamed parsing used 82.6% less. The streamed candidate range was 26.21–26.99 ms versus 152.40–155.21 ms upstream. These are synthetic CPU parser measurements, not end-to-end inference-throughput gains.
The fallback paths show little change, including small slowdowns retained in the table. This change does not fix repeated current-line/tool-body string copying or guarantee linear scaling on all inputs.
All 168 measured outputs matched known content, final arguments and concatenated streamed JSON; hashes matched across both checkouts and every sample.
Minimal workload reproduction
Run this from each checkout's repository root with Jinja2 installed. It reproduces the 128 KiB streamed workload; change
streamtoFalsefor the buffered case. Repeat in fresh processes, alternating checkouts. The snippet prints one post-warmup sample.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.