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

[release/8.0] Improve performance of UnmanagedMemoryStream #93812

Merged
merged 3 commits into from
Oct 23, 2023

Commits on Oct 21, 2023

  1. Improve performance of UnmanagedMemoryStream

    UnmanagedMemoryStream used Interlocked operations to update its state to prevent tearing of 64-bit values on 32-bit platforms. This pattern is expensive in general and it was found to be prohibitively expensive on recent hardware..
    
    This change removes the expensive Interlocked operations and addresses
    the tearing issues in alternative way:
    - The _length field is converted to nuint that is guaranteed to be
      updated atomically.
    - Writes to _length field are volatile to guaranteed the
      unininitialized memory cannot be read.
    - The _position field remains long and it has a risk of tearing. It is
      not a problem since tearing of this field cannot lead to buffer
      overruns.
    
    Fixes #93624
    jkotas authored and github-actions committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    3a43523 View commit details
    Browse the repository at this point in the history
  2. Add comment

    jkotas authored and github-actions committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    fe42c20 View commit details
    Browse the repository at this point in the history

Commits on Oct 23, 2023

  1. Configuration menu
    Copy the full SHA
    d0731b0 View commit details
    Browse the repository at this point in the history