Jump to content

Recommended Posts

A few years back, there was a post about potential cache line conflicts with TCriticalSection

https://www.delphitools.info/2011/11/30/fixing-tcriticalsection/

 

The comments indicate it was fixed for TMonitor, but I wonder if anyone knows if it was fixed for TCriticalSection. Looking at the TCriticalSection code in Delphi Seattle, it is very complex, I guess due to cross platform concerns with records, record helpers and then windows API calls all coming into play. I could not find any code there that seems to move things onto a difference cache line, but I definitely could be missing something.  Does anyone have any insight into this?

  • Thanks 1

Share this post


Link to post
Posted (edited)

Print TCriticalSection.InstanceSize and you know if it was fixed or not - spoiler: no, it was not.

On Windows that is - on Posix TCriticalSection simply uses System.TMonitor which allocates at least the size of a cache line

Edited by Stefan Glienke
  • Like 2
  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×