feat: dump requests that exhaust the solver time limit - #113
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #112, whose access log showed that about 2 percent of optimize calls run into
OPTIMIZER_TIME_LIMITand 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_REQUESTStakes 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/tmp/slow-requests.jsonlts,elapsedandrequest, and therequestkey holds exactly whattest_cases/*.jsonholds, so a line can be replayed by the existing harnessflock. 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 ownThe 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.