Skip to content

Conversation

@filipnavara
Copy link
Member

Profiling shows that large part of the GC transition overhead (~30%) in #58939 is caused by assert-style checks. Disabling them seems to be the best bang-for-the-buck option for reducing the overhead without fundamental changes to the code.

@ghost ghost added area-VM-meta-mono community-contribution Indicates that the PR has been added by a community member labels Sep 13, 2021
@ghost
Copy link

ghost commented Sep 13, 2021

Tagging subscribers to this area:
See info in area-owners.md if you want to be subscribed.

Issue Details

Profiling shows that large part of the GC transition overhead (~30%) in #58939 is caused by assert-style checks. Disabling them seems to be the best bang-for-the-buck option for reducing the overhead without fundamental changes to the code.

Author: filipnavara
Assignees: -
Labels:

area-VM-meta-mono

Milestone: -

static void
check_thread_state (MonoThreadInfo* info)
{
#ifdef ENABLE_CHECKED_BUILD_THREAD
Copy link
Member

Choose a reason for hiding this comment

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

@filipnavara I think this one should be ENABLE_CHECKED_BUILD_GC - I think other thread state machine stuff in "GC", too. (for example assert_gc_safe_mode).

I think we should also turn on the GC checked build in debug builds:

https://github.com/dotnet/runtime/blob/main/src/mono/CMakeLists.txt#L694-L695

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. But to be honest I can't tell the difference - looks like we use both defines for closely related things.

Copy link
Member Author

Choose a reason for hiding this comment

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

I mostly tried to match the asserts in the same file but I can change it. I will update the PR to enable it on debug builds.

Copy link
Member Author

Choose a reason for hiding this comment

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

After checking how the configuration options are set I came to the conclusion to change it to the general ENABLE_CHECKED_BUILD. That one is defined in all debug builds, the other ones can be selectively enabled.

@filipnavara
Copy link
Member Author

On Mac Catalyst ARM64 the test case in #58939 goes from 6,845,245 to 9,126,591 iterations per second, or 33% throughput improvement.

@marek-safar marek-safar merged commit 3904758 into dotnet:main Sep 16, 2021
@srxqds
Copy link
Contributor

srxqds commented Sep 17, 2021

will you consider to backport to release/6.0?

@lambdageek
Copy link
Member

/backport to release/6.0-rc2

@github-actions
Copy link
Contributor

Started backporting to release/6.0-rc2: https://github.com/dotnet/runtime/actions/runs/1246192307

steveisok pushed a commit that referenced this pull request Sep 21, 2021
…elease builds (#59269)

Backport of #59029

Profiling shows that large part of the GC transition overhead (~30%) in #58939 is caused by assert-style checks. Disabling them seems to be the best bang-for-the-buck option for reducing the overhead without fundamental changes to the code.

Co-authored-by: Filip Navara <[email protected]>
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
@filipnavara filipnavara deleted the mono_reduce_pinvoke_asserts branch June 5, 2025 07:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-VM-meta-mono community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants