Repository navigation
Save Node's compiled code at image build, and prefetch the run's files (~45% faster) - #1043
Open
exercism-agent[bot] wants to merge 1 commit into
Open
exercism-agent[bot] wants to merge 1 commit into
exercism-agent[bot] wants to merge 1 commit into
Conversation
…to the page cache at the start The image runs the test runner once with NODE_COMPILE_CACHE set, as appuser, so each run loads Jest's compiled code instead of compiling it. A second build stage records the files one run opens (with strace), and run.sh reads them in parallel in the background, so a run on a machine with a cold page cache doesn't wait for each file in turn. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Hello 🙂 I'm working with Claude to try and get our tooling faster.
This PR makes this project around 45% faster. I've run it in production to benchmark things in the real world against the most recent few hundred solutions, so I'm confident that it works robustly. However, I've not written the code. I have tried my hardest to get Claude to write sensible messages and comments that explains stuff, but I'd ask for your patience in the fact I'm sending AI code to you. Everything below here is from your friendly neighbourhood LLM...
What changed
Every run started Node from scratch, and Node compiled Jest's code, Babel and the reporter before it could run a test. This took a large part of each run. The image build now runs the test runner once on a small exercise with
NODE_COMPILE_CACHEset. Node saves the compiled code of every module it loads in/opt/test-runner/.node-compile-cache, and each run then loads that code instead of compiling it again.Node keeps a separate cache for each user ID, so the warm-up runs as
appuser. Node writes the cache files readable only by their owner, so the Dockerfile then gives them to root and makes them readable by everyone. Runs only read the cache, and they write nothing new into the container.On a machine where the image's files aren't in the page cache yet, Node read about 2,900 files one at a time from disk as it needed them, which took several seconds. A second build stage now records the files opened by one run (with
strace, which stays out of the final image), andrun.shreads them into the page cache at the start of each run, 8 at a time, in the background. Node then finds most of them already in memory.The warm-up checks that its run passed, so a broken runner will fail the image build. Students will see no change in results or messages.
This has been tested in production, and has reduced the median run from 4.6s to 2.6s.
🤖 Generated with Claude Code