mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 03:49:26 +00:00
perf(push): drop per-entry cache fsync; let long runs profile themselves
The cache fsynced every payload and manifest -- two per entry, ~18 ms, and a push publishes one entry per question (~22,000 on a WordPress plugin). A read already rejects any entry whose manifest receipt, payload size or payload SHA-256 does not check, so a torn write is a miss, never a wrong answer; the fsyncs bought nothing the verification does not. The broader problem: three quadratic walls in this replay were found one per two-hour run, because all were Python bookkeeping between engine calls and the only record was the engine log. `OUSAST_SAMPLE_PROFILE=<path>` starts an in-process sampler that rewrites the hottest stacks every 30 s, so a run killed at its deadline still names where its time went. The host cannot ptrace the container, hence in-process. The replay harness turns it on per case. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e7e2941e37
commit
b4b9308af8
@@ -0,0 +1,28 @@
|
||||
"""The in-process sampler leaves a readable profile behind, including for a process killed mid-run."""
|
||||
|
||||
import time
|
||||
|
||||
from openultrasast import profiling
|
||||
|
||||
|
||||
def _busy_quadratic(n: int) -> int:
|
||||
seen: list[int] = []
|
||||
for i in range(n):
|
||||
if i not in seen:
|
||||
seen.append(i)
|
||||
return len(seen)
|
||||
|
||||
|
||||
def test_the_sampler_names_the_function_that_holds_the_time(tmp_path, monkeypatch):
|
||||
target = tmp_path / "profile.txt"
|
||||
monkeypatch.delenv(profiling.ENV, raising=False)
|
||||
assert profiling.start() is None # off unless asked for
|
||||
assert profiling.start(str(target), interval=0.002, flush=0.2) is not None
|
||||
deadline = time.monotonic() + 1.5
|
||||
while time.monotonic() < deadline:
|
||||
_busy_quadratic(3000)
|
||||
time.sleep(0.3)
|
||||
text = target.read_text()
|
||||
assert text.startswith("samples ")
|
||||
self_section = text.split("self (executing):")[1]
|
||||
assert "_busy_quadratic" in self_section.splitlines()[1], self_section[:300]
|
||||
Reference in New Issue
Block a user