Skip to content

Benchmark interceptor gains against historical baseline - #825

Merged
AndreaCuneo merged 10 commits into
masterfrom
copilot/optimize-data-table-extension
Aug 3, 2026
Merged

Benchmark interceptor gains against historical baseline#825
AndreaCuneo merged 10 commits into
masterfrom
copilot/optimize-data-table-extension

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The existing benchmark compared the interceptor only with the already-optimized fallback. This adds the original reflection baseline and evaluates LoadDataRow against MoreLINQ-style Rows.Add.

Changes

  • Benchmark coverage

    • Reproduces the pre-optimization reflection implementation.
    • Compares historical baseline, optimized fallback, interceptor, and Rows.Add.
    • Records three final runs and allocation results.
  • Results

    • Interceptor is 25–33% faster for 1 row.
    • Interceptor is 52–55% faster for 100 rows.
    • Interceptor is 30–31% faster for 10,000 rows.
    • Rows.Add is 9–22% slower for bulk input and changes row-state semantics.
  • Loading lifecycle

    • Retains LoadDataRow.
    • Pairs bulk-loading calls through try/finally in runtime and generated paths:
table.BeginLoadData();
try
{
    // Fill rows using LoadDataRow.
}
finally
{
    table.EndLoadData();
}
  • Regression coverage
    • Verifies notifications are restored after enumeration failure.
    • Verifies loaded rows remain Unchanged.

Copilot AI and others added 7 commits August 2, 2026 21:48
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
@AndreaCuneo
AndreaCuneo marked this pull request as ready for review August 3, 2026 06:15
@AndreaCuneo
AndreaCuneo requested a review from a team as a code owner August 3, 2026 06:15
Copilot AI review requested due to automatic review settings August 3, 2026 06:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end runtime + benchmark coverage to quantify and validate ToDataTableArk<T>() interceptor performance against the historical reflection implementation, while also wiring the interceptor namespace automatically for both NuGet consumers and monorepo projects.

Changes:

  • Adds a standalone benchmark harness comparing historical baseline vs optimized fallback vs interceptor vs Rows.Add insertion.
  • Adds comprehensive regression tests for reflection fallback behavior and interceptor runtime interception/deduplication.
  • Ensures the interceptor namespace is allow-listed via buildTransitive assets and via repo-wide Directory.Build.props.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Ark.Tools.Core.Tests/DataTableExtensionsTests.cs Adds broad reflection-fallback regression coverage (schema, conversions, row state, failure behavior).
tests/Ark.Tools.Core.Interceptors.Tests/packages.lock.json Locks dependencies for the new interceptor runtime test project.
tests/Ark.Tools.Core.Interceptors.Tests/InterceptorRuntimeTests.cs Verifies interception occurs and inspects emitted generated source for expected patterns.
tests/Ark.Tools.Core.Interceptors.Tests/InterceptedEntity.cs Test fixtures used to validate eligible/ineligible interception scenarios.
tests/Ark.Tools.Core.Interceptors.Tests/Generated/Ark.Tools.Core.Analyzers/Ark.Tools.Core.Analyzers.ToDataTableArkInterceptorGenerator/ToDataTableArkInterceptors.g.cs Checked-in example of generated interceptor output.
tests/Ark.Tools.Core.Interceptors.Tests/Ark.Tools.Core.Interceptors.Tests.csproj New test project that explicitly wires the analyzer and emits compiler-generated files.
src/common/Ark.Tools.Core/DataTableExtensions.cs Refactors fallback shredding to use cached compiled accessors and adds try/finally around bulk-load lifecycle.
src/common/Ark.Tools.Core/buildTransitive/Ark.Tools.Core.props Adds InterceptorsNamespaces opt-in for NuGet consumers via transitive build assets.
src/common/Ark.Tools.Core/Ark.Tools.Core.csproj Packs the new buildTransitive props into the NuGet package.
src/common/Ark.Tools.Core.Analyzers/ToDataTableArkInterceptorModels.cs Adds symbol-free models for incremental generator pipeline.
src/common/Ark.Tools.Core.Analyzers/ToDataTableArkInterceptorGenerator.cs New C# 14 interceptor generator emitting reflection-free ToDataTableArk implementations per callsite/type.
Directory.Build.props Adds repo-wide InterceptorsNamespaces allow-list for monorepo ProjectReference scenarios.
benchmarks/Ark.Tools.Core.Benchmarks/RowsAddConverter.cs Adds Rows.Add-style converter for benchmark comparison.
benchmarks/Ark.Tools.Core.Benchmarks/results/optimized.md Records optimized fallback benchmark results and methodology notes.
benchmarks/Ark.Tools.Core.Benchmarks/results/interceptor-comparison.md Records comparison results across baseline/fallback/interceptor/Rows.Add.
benchmarks/Ark.Tools.Core.Benchmarks/results/baseline.md Records historical baseline benchmark results and methodology notes.
benchmarks/Ark.Tools.Core.Benchmarks/Program.cs Benchmark harness main program printing markdown tables.
benchmarks/Ark.Tools.Core.Benchmarks/packages.lock.json Locks dependencies for the new benchmarks project.
benchmarks/Ark.Tools.Core.Benchmarks/HistoricalBaselineConverter.cs Reproduces the pre-optimization reflection implementation for benchmarks.
benchmarks/Ark.Tools.Core.Benchmarks/BenchmarkRow.cs Model representing a single benchmark measurement row.
benchmarks/Ark.Tools.Core.Benchmarks/BenchmarkEntity.cs Benchmark fixture entity and deterministic data generator.
benchmarks/Ark.Tools.Core.Benchmarks/Ark.Tools.Core.Benchmarks.csproj New benchmarks console project that wires the analyzer for interception.
Ark.Tools.slnx Adds the new benchmarks and interceptor test projects to the solution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread benchmarks/Ark.Tools.Core.Benchmarks/Program.cs
Comment thread src/common/Ark.Tools.Core/DataTableExtensions.cs
Comment thread benchmarks/Ark.Tools.Core.Benchmarks/Program.cs
Comment thread tests/Ark.Tools.Core.Interceptors.Tests/InterceptorRuntimeTests.cs Fixed
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 06:40
Copilot AI requested a review from AndreaCuneo August 3, 2026 06:57
Comment thread .gitignore Outdated
Comment thread src/common/Ark.Tools.Core/DataTableExtensions.cs Outdated
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 07:03
Copilot AI requested a review from AndreaCuneo August 3, 2026 07:11
@AndreaCuneo

Copy link
Copy Markdown
Contributor

@copilot sync with master

Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 07:21

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot sync with master

Synced with master via merge commit 2c9453e. Full solution build succeeded and all 405 tests passed.

@AndreaCuneo
AndreaCuneo merged commit aa62e0a into master Aug 3, 2026
6 checks passed
@AndreaCuneo
AndreaCuneo deleted the copilot/optimize-data-table-extension branch August 3, 2026 07:40
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.

3 participants