Skip to content

[Benchmarks] Profile RevitApiBenchmark benchmarks with dotTrace - #65

Merged
Nice3point merged 3 commits into
developfrom
benchmarks/64-update-injector-for-dottrace
Nov 1, 2026
Merged

Nice3point merged 3 commits into
developfrom
benchmarks/64-update-injector-for-dottrace

Conversation

@Nice3point

@Nice3point Nice3point commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary of the Pull Request

What is this about:

The dotTrace profiler attaches to the process of a RevitApiBenchmark benchmark on every supported Revit version.

Description:

What changed

  • Nice3point.Revit.Injector is 2021.1.11–2026.1.11 for Revit 2021–2026, and 2027.0.11 for Revit 2027. Its console filter runs no managed code.
  • On .NET Framework, the BenchmarkDotNet host process sets COMPlus_AttachThreadAlwaysOn=1, and the benchmark processes inherit it.
  • BenchmarkHostProcess.IsCurrent identifies the host process for the RevitAPIUI metadata resolver and the attach thread.

Where to look

  • The attach thread is a documented runtime setting of .NET Framework 4. It adds one idle thread to every benchmark process the host starts, profiled or not.
  • The runtime reads the setting only when the process starts. The host process sets it, because the module initializer of a benchmark process runs after the runtime started.
  • The cause on .NET Framework is not known. A benchmark process with Revit opens no attach pipe, and its finalizer thread runs finalizers.

How verified

  • Build: Release.R21 to Release.R27, zero warnings, zero errors.

  • AddDiagnoser(new DotTraceDiagnoser()) in Program.cs, ApplicationBenchmarks and SelectionBenchmarks in one run, a Dry job:

    Revit Runtime Injector Snapshots of ApplicationBenchmarks Snapshots of SelectionBenchmarks
    2027 .NET 10 2027.0.10 fails as in the issue not run
    2027 .NET 10 2027.0.11 2 2
    2025 .NET 8 2025.1.11 2 not run
    2024 .NET Framework 4.8 2024.1.11, without the setting fails with Can't attach CLR profiler not run
    2024 .NET Framework 4.8 2024.1.11, this branch 2 2

Quality Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@Nice3point Nice3point added bug 🐛 An unexpected issue that highlights incorrect behavior benchmarks 📊 Benchmark runner and its configuration labels Nov 1, 2026
@Nice3point Nice3point self-assigned this Nov 1, 2026
@Nice3point
Nice3point marked this pull request as ready for review November 1, 2026 15:31
Copilot AI balanced review requested due to automatic review settings November 1, 2026 15:31
@Nice3point
Nice3point merged commit 9c72184 into develop Nov 1, 2026
2 checks passed
@Nice3point
Nice3point deleted the benchmarks/64-update-injector-for-dottrace branch November 1, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Reported profiling runs used a project reference, leaving the shipped ILRepack-merged injector unvalidated in Revit across both CLR families.

No open issues 🎉

What changed in this PR

This PR enables dotTrace attachment to Revit API benchmark processes through an injector update and a .NET Framework runtime setting applied by the benchmark host.

Changes:

  • Updates injector packages for Revit 2021–2027.
  • Enables the .NET Framework profiler attach thread through an inherited environment variable.
  • Shares host-process detection between profiler setup and RevitAPIUI metadata resolution.
File Description
source/​Nice3point.BenchmarkDotNet.Revit/​RevitApplicationBenchmark.cs Calls profiler setup during initialization and documents it.
source/​Nice3point.BenchmarkDotNet.Revit/​Hosting/​RevitUiMetadataResolver.cs Uses shared host-process detection.
source/​Nice3point.BenchmarkDotNet.Revit/​Hosting/​ProfilerAttachThread.cs Sets the profiler attach environment variable in .NET Framework hosts.
source/​Nice3point.BenchmarkDotNet.Revit/​Hosting/​BenchmarkHostProcess.cs Centralizes host-process identification.
Directory.Packages.props Updates Revit injector dependencies to the profiling-compatible releases.

Review effort: Balanced

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

Labels

benchmarks 📊 Benchmark runner and its configuration bug 🐛 An unexpected issue that highlights incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants