Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event tracing to DependencyGraphResolver #6284

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Feb 24, 2025

Bug

Fixes: NuGet/Home#14134

Description

This adds event tracing to the two major parts of the new dependency resolver, resolving the graph and flattening it while reporting errors/downgrades/cycles.

It measures each project/framework/runtime identifier with how many items were resolved, the total number of items that were queued/processed, and the number of times it started over due to evictions.

image

For flattening, it tracks resolved/unresolved package count and success/failure.

image

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@jeffkl jeffkl self-assigned this Feb 24, 2025
@jeffkl jeffkl requested a review from a team as a code owner February 24, 2025 17:58
Comment on lines +932 to +936
// Keeps track of the number of times the entire walk is started over
int? restartCount = NuGetEventSource.IsEnabled ? -1 : null;

// Keeps track of the total number of items that have been queued for processing
int? totalQueuedItemCount = NuGetEventSource.IsEnabled ? 0 : null;
Copy link
Member

@zivkan zivkan Feb 26, 2025

Choose a reason for hiding this comment

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

I don't understand the intent of making these counters nullable.

Two ints would normally increase the stack size by 8 bytes. Making them nullable makes that even larger, although I don't know the runtime implementation details well enough to know by exactly how much (but each nullable needs a bool, so maybe 2 more bytes).

Plus each time the counter is incremented, the compiler needs to emit "if not null" guards. Since CPUs have branch predictors, if the CPU guesses wrong, the pipeline needs to be flushed. All this to say that having nullable counters probably has worse theoretical perf than having a counter that's only written to, never read. Having said that I expect the impact to be so incredibly small that run to run noise/variation will completely drown out the difference. But, I don't feel like making the counters nullable helps.

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.

Event tracing in new dependency resolver
5 participants