Repository navigation
perf: wake the fs lock keep-alive thread immediately on release - #1317
Merged
Merged
Conversation
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.
The keep-alive thread spawned by
LaxSingleProcessFsFlag::lockslept for a flat 100ms between poll file updates and only checked the cancellation token after each sleep. The runtime waits for blocking tasks when the process shuts down, so on a cold plugin cache (where the lock is held while the plugin compiles) exiting was delayed until the thread's current sleep ended. In practice this quantized total process time to the keep-alive thread's 100ms boundaries.This replaces the sleep with
recv_timeouton anmpscchannel so that dropping the guard wakes the thread right away. The poll interval stays at 100ms since the other process treats the lock as abandoned afterpoll_file_update_ms * 2.Confirmed with
straceon the unmodified build: in runs where the lock was released just after a poll file write,exit_grouphappened exactly 100ms later.Timings
Cold cache (
DPRINT_CACHE_DIRpointing at an empty directory, deleted between runs), release build,dprint output-resolved-configwith a config referencing a localtypescriptplugin.wasmfile by path.hyperfine -N --warmup 2 --runs 20.Sorted run times (ms):