Skip to content

fix: FileSystemWatcherMock buffer overflows from changes outside the watched path - #1274

Closed
pw-sgr wants to merge 2 commits into
Testably:mainfrom
pw-sgr:fix-watcher-buffer-overflow-outside-path
Closed

pw-sgr wants to merge 2 commits into
Testably:mainfrom
pw-sgr:fix-watcher-buffer-overflow-outside-path

Conversation

@pw-sgr

@pw-sgr pw-sgr commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1227

FileSystemWatcherMock records changes outside the watched folder, resulting in buffer overflows in the mock

Replaces #1232, dropping the additional fixes, because the pr became too big due to regressions

I also took the time and prepared a pr #1275 that fixes everything. However that pr is big, as I replaced the whole watcher with the dotnet one. So it's up to you @vbreuss which one to choose.

…eSystemWatcherMock buffer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mergify

mergify Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

This pull request is closed, so it cannot be queued. Reopen it to get the box back.

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · Fix recursive path matching before merging so sibling changes cannot still overflow the watched buffer.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches callers of the mock file-system watcher.

Fix recursive path matching before merging so sibling changes cannot still overflow the watched buffer.

Findings

  1. P1 Sibling changes still overflow buffer ▶

Summary

Filters changes by watched path before they enter the mock watcher's bounded buffer.

  • Mock watchers skip outside changes before they fill the event queue.

Reviews (1) · Last reviewed commit: "fix: ignore changes outside the watched ..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🚀 Benchmark Results

Compared to main, which ran on the same runner. Times that change by more than 10% are marked.

Memory

Benchmark main PR Δ
Initialize (N=100) 350,466 B 341,514 B 🟢 -8,952 B (-3%)
RoundTrip (Size=65536) 198,043 B 198,029 B 🟢 -14 B (±0%)
MoveTree 128,284 B 128,265 B 🟢 -19 B (±0%)
Enumerate (N=1000&Pattern=*.txt) 218,314 B 218,315 B 🔴 +1 B (±0%)

Time

Benchmark main PR Δ
RoundTrip (Size=1024) 7.29 μs 6.21 μs 🟢 -15%
Chunks 61.55 μs 44.49 μs 🟢 -28%
MoveTree 136.45 μs 117.94 μs 🟢 -14%
CompleteTestBenchmarks
Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 21.19 μs 0.255 μs 0.238 μs 1.00 39.9 KB 1.00
SystemIOAbstractions 78.85 μs 0.839 μs 0.744 μs 3.72 166.7 KB 4.18
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

InitializationBenchmarks
Initialize N Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 10 32.58 μs 0.138 μs 0.123 μs 1.00 42.42 KB 1.00
SystemIOAbstractions 10 30.83 μs 0.384 μs 0.359 μs 0.95 48.59 KB 1.15
Testably 100 262.72 μs 1.416 μs 1.255 μs 1.00 333.51 KB 1.00
SystemIOAbstractions 100 244.55 μs 0.953 μs 0.892 μs 0.93 392.78 KB 1.18
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.45GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

MockCreationBenchmarks
CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 1.467 μs 0.0059 μs 0.0052 μs 1.00 5.21 KB 1.00
SystemIOAbstractions 4.740 μs 0.0166 μs 0.0155 μs 3.23 8.15 KB 1.56
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
INTEL XEON PLATINUM 8573C 0.80GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

FileRoundTripBenchmarks
RoundTrip Size Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 1024 6.212 μs 3.092 μs 2.8918 μs 1.21 4.26 KB 1.00
SystemIOAbstractions 1024 9.200 μs 3.435 μs 3.0447 μs 1.79 16.54 KB 3.88
Testably 65536 114.328 μs 1.084 μs 0.9613 μs 1.00 193.39 KB 1.00
SystemIOAbstractions 65536 76.680 μs 1.207 μs 1.0704 μs 0.67 408.49 KB 2.11
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.45GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=4096  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

FileInfoBenchmarks
Inspect Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 1.391 μs 0.1882 μs 0.1668 μs 1.01 1.52 KB 1.00
SystemIOAbstractions 1.371 μs 0.0441 μs 0.0412 μs 1.00 2.55 KB 1.69
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.68GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=65536  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

FileStreamBenchmarks
Chunks Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 44.49 μs 2.265 μs 2.008 μs 1.00 201.51 KB 1.00
SystemIOAbstractions 86.31 μs 2.841 μs 2.657 μs 1.94 326.67 KB 1.62
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.63GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=2048  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

DirectoryTreeBenchmarks
MoveTree Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 117.94 μs 2.312 μs 1.805 μs 1.00 125.26 KB 1.00
SystemIOAbstractions 46.70 μs 0.180 μs 0.141 μs 0.40 106.62 KB 0.85
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 3.90GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=512  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

Enumeration10Benchmarks
Enumerate N Pattern Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 10 ***** 3.541 μs 0.3129 μs 0.2443 μs 1.00 4.31 KB 1.00
SystemIOAbstractions 10 * 3.142 μs 0.0430 μs 0.0359 μs 0.89 3.93 KB 0.91
Testably 10 *.txt 3.382 μs 0.1842 μs 0.1723 μs 1.00 3.88 KB 1.00
SystemIOAbstractions 10 *.txt 4.859 μs 0.0802 μs 0.0750 μs 1.44 4.24 KB 1.09
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.29GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=16384  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

Enumeration1000Benchmarks
Enumerate N Pattern Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 1000 ***** 829.5 μs 17.24 μs 15.29 μs 1.00 263.55 KB 1.00
SystemIOAbstractions 1000 * 320.3 μs 1.07 μs 0.90 μs 0.39 70.42 KB 0.27
Testably 1000 *.txt 806.7 μs 4.44 μs 3.94 μs 1.00 213.2 KB 1.00
SystemIOAbstractions 1000 *.txt 691.5 μs 5.66 μs 5.02 μs 0.86 66.87 KB 0.31
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.24GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  InvocationCount=512  
IterationCount=15  LaunchCount=1  UnrollFactor=1  
WarmupCount=10  

…atcherMock paths

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pw-sgr

pw-sgr commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Other pr choosen #1275 (review)

@pw-sgr pw-sgr closed this Dec 4, 2026
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.

FileSystemWatcherMock: Buffer overflows from changes outside the watched path

1 participant