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

Remove unnecessary lock in TerminalLogger.UpdateNodeStatus #10045

Merged
merged 2 commits into from May 1, 2024

Conversation

dfederm
Copy link
Contributor

@dfederm dfederm commented Apr 19, 2024

This is a minor perf improvement.

In particular when using the project cache with a high cache rate (thus spamming ProjectFinished events), this lock is taking ~6% of the CPU for the process due to contention. That's a lower bound though because I'm seeing other methods which do take the lock also suffer from high contention (eg ThreadProc also takes ~6% CPU), so removing the lock from UpdateNodeStatus is likely to reduce contention there as well.

This lock isn't necessary since this operation is a simple object replacement in an array. Other similar operations also don't take a lock, (See the write in ProjectStarted and the read in MessageRaised) which proves that it's not required.

Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

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

Looks good - the lock seems to be used to guard the terminal access (rather then write access or sequentialization of order).

If the contention is so high - we might want to consider offloading the updates to single UI processing thread (or do a mixed solution via updating sinchronously only if Monitor.TryEnter is successful without timeout and otherwise queue the request for a UI processing thread).

@rainersigwald rainersigwald enabled auto-merge (squash) May 1, 2024 13:39
@rainersigwald rainersigwald merged commit 300b2a8 into dotnet:main May 1, 2024
10 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.

None yet

5 participants