feat(watcher): port watchpack safeTime/mtime-accuracy to native watcher#14267
feat(watcher): port watchpack safeTime/mtime-accuracy to native watcher#14267stormslowly wants to merge 2 commits into
Conversation
The native watcher returned empty fileTimeInfoEntries / contextTimeInfoEntries
(left as a TODO), so compiler.fileTimestamps / contextTimestamps were empty and
the persistent-cache snapshot degraded to "trust changedFiles only".
Port watchpack's safeTime mechanism into rspack_watcher:
- FS_ACCURACY global + ensureFsAccuracy resolution detection
- per-entry { safe_time, timestamp, accuracy } with initial/event regimes
- fixupEntryAccuracy lazy tightening + directory safe_time aggregation
- expose via napi getTimeInfo(); populate the two maps and getInfo() in
NativeWatchFileSystem
accuracy is kept internal: rspack's FileSystemInfoEntry exposes only
{ safeTime, timestamp }, matching webpack's public contract.
Merging this PR will degrade performance by 2.4%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | js@collect imported identifiers |
225 µs | 230.5 µs | -2.4% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing stormslowly:feat/native-watcher-safetime (4f1743a) with main (ac43bc2)
Footnotes
-
40 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Unable to generate the flame graphsThe performance report has correctly been generated, but there was an internal error while generating the flame graphs for this run. We're working on fixing the issue. Feel free to contact us on Discord or at support@codspeed.io if the issue persists. |
The directory-aggregation test used a Unix-style "/project/src" path, which is not absolute on Windows — update() relativized it (joined cwd) so the file's parent chain no longer matched the registered directory. Build the paths from std::env::temp_dir() instead. Also bump the real-change test sleep to 50ms to clear Windows' ~15.6ms SystemTime granularity.
Why
The native watcher returned empty
fileTimeInfoEntries/contextTimeInfoEntries(left as a// TODO), socompiler.fileTimestamps/contextTimestampswere empty. Persistent-cache snapshot validation then degrades to "trust the changedFiles set only", which can miss or over-invalidate across processes — the JS (watchpack) path does populate these viacollectTimeInfoEntries, so this closes a parity gap.What
Port watchpack's
safeTime/ mtime-accuracy mechanism intorspack_watcher:FS_ACCURACYglobal (2000ms, monotonically ratchets down) +ensureFsAccuracyresolution detection{ safe_time, timestamp, accuracy }with the initial-scan regime (min(now, mtime) + FS_ACCURACY) and the real-time regime (now, accuracy0), including the attribute-only within-window skipfixupEntryAccuracylazy tightening on read + directorysafe_timeaggregated from descendant filesgetTimeInfo();NativeWatchFileSystemnow fills both maps andgetInfo()accuracyis kept internal — rspack'sFileSystemInfoEntryexposes only{ safeTime, timestamp }, matching webpack's public contract.Before / After
Test
cargo test -p rspack_watcher— ported watchpack safeTime characterization tests (FS_ACCURACY ladder, fixup, initial/event regimes, within-window skip, dir aggregation)DirectoryWatcherExtrasuite green (reference parity)NativeWatcher.part1/2/3JS suites green (230 cases)