Skip to content

[Benchmarks] Reference SQLitePCLRaw.bundle_e_sqlite3 in EFCore.Sqlite.Benchmarks#38293

Merged
AndriySvyryd merged 1 commit into
dotnet:mainfrom
LoopedBard3:parkerbibus/fix-sqlite-benchmarks-init
May 19, 2026
Merged

[Benchmarks] Reference SQLitePCLRaw.bundle_e_sqlite3 in EFCore.Sqlite.Benchmarks#38293
AndriySvyryd merged 1 commit into
dotnet:mainfrom
LoopedBard3:parkerbibus/fix-sqlite-benchmarks-init

Conversation

@LoopedBard3
Copy link
Copy Markdown
Member

@LoopedBard3 LoopedBard3 commented May 18, 2026

Fixes #38292. This was generated by AI, so if there is a different preferred approach, feel free to close.

Since the SQLitePCLRaw 3.x bump (#36551), every benchmark in
EFCore.Sqlite.Benchmarks throws on [GlobalSetup]:

System.Exception: You need to call SQLitePCL.raw.SetProvider().
If you are using a bundle package, this is done by calling
SQLitePCL.Batteries.Init().
   at SQLitePCL.raw.get_Provider()
   at SQLitePCL.raw.sqlite3_libversion()
   at Microsoft.Data.Sqlite.SqliteConnection.get_ServerVersion()
   at Microsoft.EntityFrameworkCore.Sqlite.Update.Internal
        .SqliteUpdateSqlGenerator..ctor(UpdateSqlGeneratorDependencies)
   ...
   at BenchmarkDotNet.Autogenerated.Runnable_0.GlobalSetup()

In SQLitePCLRaw 3.x the bundle packages register the provider via a
[ModuleInitializer], so referencing SQLitePCLRaw.bundle_e_sqlite3
(the same package EFCore.Sqlite.FunctionalTests already uses) is
sufficient — no code change is needed. The version is already pinned in
the root Directory.Packages.props as
SQLitePCLRaw.bundle_e_sqlite3 = $(SQLitePCLRawVersion) (3.0.3).

This regression has been silently masking every EF Core measurement in
the aspnet/Benchmarks benchmarks-ci-01 pipeline for ~122
consecutive builds since 2026-03-19. BenchmarkDotNet reports every
method as NA under "Benchmarks with issues" but exits with code 0,
and crank's RunBenchmarkDotNet only fails on agent-side errors, so
the AzDO task is marked succeeded. See the issue for the full
investigation.

Verification

Reproduced locally with crank + crank-agent --no-cleanup on the
agent's net11.0 preview SDK. Funcletization scenario:

Before:

 Method            | Mean | Error | Op/s |
------------------ |-----:|------:|-----:|
 NewQueryInstance  |   NA |    NA |   NA |
 SameQueryInstance |   NA |    NA |   NA |
 ValueFromObject   |   NA |    NA |   NA |

After the one-line <PackageReference> add:

 Method            | Mean     | Error     | StdDev    | Op/s  | Gen0    | Gen1    | Allocated |
------------------ |---------:|----------:|----------:|------:|--------:|--------:|----------:|
 NewQueryInstance  | 5.443 ms | 1.7801 ms | 0.0976 ms | 183.7 | 54.6875 | 23.4375 |    1.4 MB |
 SameQueryInstance | 4.950 ms | 0.8875 ms | 0.0486 ms | 202.0 | 46.8750 | 23.4375 |   1.28 MB |
 ValueFromObject   | 5.474 ms | 0.8126 ms | 0.0445 ms | 182.7 | 54.6875 | 23.4375 |   1.44 MB |

Since the SQLitePCLRaw 3.x bump in dotnet#36551, every benchmark in
EFCore.Sqlite.Benchmarks throws on [GlobalSetup]:

  System.Exception: You need to call SQLitePCL.raw.SetProvider().
  If you are using a bundle package, this is done by calling
  SQLitePCL.Batteries.Init().
     at SQLitePCL.raw.get_Provider()
     at SQLitePCL.raw.sqlite3_libversion()
     at Microsoft.Data.Sqlite.SqliteConnection.get_ServerVersion()
     at Microsoft.EntityFrameworkCore.Sqlite.Update.Internal
          .SqliteUpdateSqlGenerator..ctor(UpdateSqlGeneratorDependencies)
     ...
     at BenchmarkDotNet.Autogenerated.Runnable_0.GlobalSetup()

In SQLitePCLRaw 3.x the bundle packages register the provider via a
ModuleInitializer, so referencing SQLitePCLRaw.bundle_e_sqlite3 (the
same package used by EFCore.Sqlite.FunctionalTests) is sufficient - no
code change is needed. The package version is already pinned in the
root Directory.Packages.props as SQLitePCLRaw.bundle_e_sqlite3
= $SQLitePCLRawVersion (3.0.3).

The aspnet/Benchmarks benchmarks-ci-01 pipeline has been silently
running zero EF Core measurements (every method reports NA in BDN, but
crank treats BDN's normal exit as success) for roughly two months
since 2026-03-19 / build 2930691.

Verified locally with crank + crank-agent --profile local: before the
fix every method is NA, after the fix all methods report real Mean
and Op/s.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 18, 2026 22:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes EFCore.Sqlite.Benchmarks failing at BenchmarkDotNet [GlobalSetup] after the SQLitePCLRaw 3.x upgrade by ensuring the SQLitePCLRaw provider gets registered via the bundle package’s module initializer.

Changes:

  • Add a PackageReference to SQLitePCLRaw.bundle_e_sqlite3 in the SQLite benchmarks project so provider registration happens automatically at runtime.

@AndriySvyryd AndriySvyryd merged commit c94ca46 into dotnet:main May 19, 2026
30 of 31 checks passed
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.

[Benchmarks] EFCore.Sqlite.Benchmarks silently fails since SQLitePCLRaw 3.x bump — missing bundle reference

3 participants