mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1542] [CLOSED] serve: avoid exhaustive partial-tag suffix checks #3522
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#3522
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/1542
Author: @InB4DevOps
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:perf/parser-partial-tag-search📝 Commits (1)
2269597serve: avoid exhaustive partial-tag suffix checks📊 Changes
2 files changed (+72 additions, -3 deletions)
View changed files
📝
serve/frontend.py(+12 -3)➕
serve/test_parser_hold.py(+60 -0)📄 Description
Summary
Speed up
OutputParser._hold()by searching the bounded suffix for candidate tag-prefix starts instead of checking every possible prefix withstr.endswithon every token delta.The earliest matching candidate is the longest proper-prefix suffix. Overlapping candidates, empty/one-character tags, Unicode text, and streamed tag boundaries retain the original behavior.
Adds parity tests against the original algorithm, including exhaustive short strings and randomized chunk boundaries through reasoning, quoted code, tool calls, streamed tools, and recovery.
Why
Profiling a synthetic 49,664-token output workload identified 496,640 suffix checks in
_hold(). Ordinary prose generally contains no candidate<, so the new path replaces these checks with a bounded C-level string search.Local Linux measurements on an Intel Core i7-12700KF, CPython 3.12.3, regex 2026.9.29 and Jinja2 3.1.6, with profiling disabled, seven fresh-process samples and two warmups per workload:
The combined CPU output-processing workload used 32.4% less elapsed time. This is a synthetic Python workload, not an end-to-end inference-throughput claim. No model or GPU was needed. Windows performance has not yet been measured.
The measurements came from local profiling/benchmark work; this PR contains only the parser optimization and correctness tests.
Minimal workload reproduction
With
regexandjinja2installed, run this Python snippet from the repository root on the base and PR branches. It recreates the measured combined workload (49,664 tokens, 66,048 UTF-8 output bytes). Run in fresh processes for repeated samples; fixture creation and correctness checks are outside the timer.Validation
Validated the isolated PR branch, based on current upstream
main:git diff --checkalso passed. The implementation uses portable Python string operations; Windows execution is pending.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.