Skip to content

feat: dump requests that exhaust the solver time limit - #113

Merged
andig merged 2 commits into
mainfrom
feat/dump-slow-requests
Jul 25, 2026
Merged

feat: dump requests that exhaust the solver time limit#113
andig merged 2 commits into
mainfrom
feat/dump-slow-requests

Conversation

@andig

@andig andig commented Jul 25, 2026

Copy link
Copy Markdown
Member

Follows #112, whose access log showed that about 2 percent of optimize calls run into OPTIMIZER_TIME_LIMIT and return whatever the solver has at 20 seconds. The p99 is pinned there. Those are the requests worth studying, and right now none of them is kept.

  • OPTIMIZER_DUMP_SLOW_REQUESTS takes the path of a JSON Lines file. Every request whose solve exceeds the time limit is appended as one line. Unset, the default, disables the dump entirely
  • production writes to /tmp/slow-requests.jsonl
  • a line carries ts, elapsed and request, and the request key holds exactly what test_cases/*.json holds, so a line can be replayed by the existing harness
  • the append takes an exclusive flock. Every gunicorn worker writes to the same file and a request is far larger than the buffer size that would make the append atomic on its own
  • the elapsed time covers model building as well as solving, so a request that only exceeds the limit while building is captured too
  • a failing write is logged and swallowed. A full or read only disk must never turn a solved request into an error

The file is ephemeral, a replica restart takes it with it, and replicas currently come and go on a one minute scale. That is fine for pulling a handful of pathological cases out of production by hand, and not enough if these should be collected reliably. A volume mount or shipping the lines to blob storage would be the next step, once we know what the captured requests actually look like.

andig added 2 commits July 25, 2026 13:30
About 2 percent of optimize calls run into OPTIMIZER_TIME_LIMIT and return
whatever the solver has by then. Keep those requests so they can be replayed
instead of only knowing they happened. Gated by OPTIMIZER_DUMP_SLOW_REQUESTS,
off by default, on in production.
OPTIMIZER_DUMP_SLOW_REQUESTS now takes the path of the output file instead of
a flag plus a directory, and every slow request is appended as one line under
an exclusive lock.
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