Registry Mirror
Skip to content

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 28, 2026

Copy link
Copy Markdown
Member

FileSystemInitializer.WithFile called Directory.CreateDirectory for the parent directory of every initialized file, although it usually exists, for example for all files added in WithSubdirectory(...).Initialized(...). Each call resolves the path again, and fileInfo.Directory was even evaluated twice.

The parent directory is now only created when it does not exist. CreateDirectory does nothing for an existing directory, also on the real file system, so the result is the same. In a local measurement, initializing a fixture with 100 files allocated 14 % less.

@vbreuss vbreuss self-assigned this Nov 28, 2026
@mergify

mergify Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The change appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The change appears safe to merge.

Summary

WithFile now reads fileInfo.Directory once and creates the parent only when it is missing.

  • File setup creates parent folders only when they are missing.

Reviews (1) · Last reviewed commit: "perf: create the parent directory of an ..." · Reviewed by Greptile

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Test Results

     80 files       80 suites   1h 38m 24s ⏱️
 88 641 tests  83 921 ✅  4 720 💤 0 ❌
205 254 runs  185 316 ✅ 19 938 💤 0 ❌

Results for commit c03b8a0.

@github-actions

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 Δ
Enumerate (N=1000&Pattern=*) 326,949 B 326,950 B 🔴 +1 B (±0%)
CompleteTestBenchmarks
Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 64.47 μs 1.217 μs 1.138 μs 1.00 112.01 KB 1.00
SystemIOAbstractions 56.57 μs 0.723 μs 0.641 μs 0.88 166.7 KB 1.49
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.01GHz, 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  

MockCreationBenchmarks
CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 5.279 μs 0.2616 μs 0.2447 μs 1.00 15.96 KB 1.00
SystemIOAbstractions 5.331 μs 0.0568 μs 0.0504 μs 1.01 8.15 KB 0.51
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.67GHz, 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  

EnumerationBenchmarks
Enumerate N Pattern Mean Error StdDev Ratio Allocated Alloc Ratio
Testably 10 ***** 7.317 μs 0.0933 μs 0.0827 μs 1.00 5.9 KB 1.00
SystemIOAbstractions 10 * 5.463 μs 0.0226 μs 0.0211 μs 0.75 3.93 KB 0.67
Testably 10 *.txt 7.641 μs 0.1400 μs 0.1310 μs 1.00 5.59 KB 1.00
SystemIOAbstractions 10 *.txt 8.325 μs 0.0414 μs 0.0387 μs 1.09 4.24 KB 0.76
Testably 1000 ***** 856.062 μs 1.1865 μs 0.9263 μs 1.00 319.29 KB 1.00
SystemIOAbstractions 1000 * 343.809 μs 0.9633 μs 0.9010 μs 0.40 70.45 KB 0.22
Testably 1000 *.txt 873.239 μs 0.7974 μs 0.6225 μs 1.00 284.52 KB 1.00
SystemIOAbstractions 1000 *.txt 606.387 μs 1.2138 μs 1.0136 μs 0.69 66.9 KB 0.24
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  

@vbreuss
vbreuss merged commit d6001d7 into main Nov 28, 2026
21 checks passed
@vbreuss
vbreuss deleted the perf/initializer-parent-directory branch November 28, 2026 18:41
github-actions Bot added a commit that referenced this pull request Nov 29, 2026
… initialized file only when it is missing (#1250) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Nov 29, 2026
… initialized file only when it is missing (#1250) by Valentin Breuß
@github-actions

Copy link
Copy Markdown

This is addressed in release v8.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant