Skip to content

Remove unused SORT_MARK_STACK code.#123063

Merged
adityamandaleeka merged 1 commit intodotnet:mainfrom
adityamandaleeka:remove_unused_sortmarkstack
Jan 12, 2026
Merged

Remove unused SORT_MARK_STACK code.#123063
adityamandaleeka merged 1 commit intodotnet:mainfrom
adityamandaleeka:remove_unused_sortmarkstack

Conversation

@adityamandaleeka
Copy link
Member

This PR removes the SORT_MARK_STACK feature and related rqsort1 function from the GC. These aren't used and if we need them, we can always bring them back from history.

I don't know the full history here but I assume it's not enabled because the performance benefits weren't worth the sorting cost. Plus we have prefetch in the mark phase now which should help hide memory latency.

@dotnet-policy-service
Copy link
Contributor

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

Copy link
Contributor

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 removes the unused SORT_MARK_STACK feature from the garbage collector. The feature was designed to sort the mark stack during GC marking phases to potentially improve memory access patterns, but it was never enabled in production builds. With prefetch optimization now available in the mark phase, this sorting code is no longer needed.

Changes:

  • Removed the rqsort1 function that implemented reverse quicksort for sorting mark stack entries
  • Removed all SORT_MARK_STACK conditional compilation blocks from both foreground and background GC marking functions

@AaronRobinsonMSFT
Copy link
Member

Is it possible this was a diagnostic tool used during GC development/debugging scenarios?

@VSadov
Copy link
Member

VSadov commented Jan 12, 2026

Not sure what the history of this either, but my guess would be the same as @adityamandaleeka -
Someone hoped that sorting mark stack would speed up marking, but it did not always help.

Marks stack typically covers only a small portion of the heap and in general can contain fairly random pointers, thus it can be too sparse to benefit from sorting.

Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

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

LGTM

@adityamandaleeka adityamandaleeka merged commit fd07ebf into dotnet:main Jan 12, 2026
107 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments