Reduce allocations in XLSX query processing - #1002
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
@michelebastione could you please review? thanks |
|
Is this new MemoryValidation project a necessary addition? I don't see how that's better than simply running the main benchmarks using BenchmarkDotNet, besides the fact that we get an approximation for the peak memory usage. If that's what this is about I think we should try doing it by adding a custom MemoryDiagnoser to our BenchmarkDotNet pipeline before going for the "doing it raw" approach. |
Yes, memory usage. But we can try it. |
|
AI suggestion :
|
|
The |
@michelebastione Ok, I will remove the benchmark part 🙌 |
|
I can take care of it |
We'll work on it separately and add it to the codebase in a new PR
Thanks ❤ |
Summary
ExcelRowdirectly with the required capacity instead of copying an intermediate dictionaryIDiagnoserPeak memory diagnostics
PeakMemoryDiagnosersamples the workload process every 20 ms during the actual workload phase of a separate BenchmarkDotNet diagnostic run. This avoids affecting the primary timing run and addsPeak Working SetandPeak Private Bytesto the normal Markdown, CSV, and HTML reports.The diagnoser is enabled with
BenchmarkPeakMemory=true. The Query benchmark workflow enables it automatically; Create and Template benchmarks keep their existing runtime.A local run of
MiniExcel Queryproduced:Peak values are sampled approximations and are machine-specific.
Allocatedremains cumulative managed allocation per operation.Allocation improvement
Using the repository's 1,000,000-row x 10-column workbook on .NET 10, cumulative managed allocations decreased from 9,957.6 MB to approximately 8,223.5 MB, a reduction of about 1.73 GB (17.4%).
Validation
dotnet test tests/MiniExcelTests/MiniExcelTests.csproj -c Release --no-restore: 367 passeddotnet build benchmarks/MiniExcel.Benchmarks/MiniExcel.Benchmarks.csproj -c Release -f net10.0 --no-restore: succeededMiniExcel Queryrun completed with a separate diagnostic run and both peak-memory metricsMiniExcel QueryFirstintegration run: 109.2 us mean, 64,072 KB peak working set, 36,684 KB peak private bytes, 55.23 KB allocated