dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.19k stars 4.72k forks source link

Expose Thread.GetCurrentProcessorId() as a public API #20480

Closed danmoseley closed 4 years ago

danmoseley commented 7 years ago

@VSadov commented on Thu Feb 16 2017

Environment.CurrentExecutionId seems to be a generally useful API, that can be used to correlate accesses to striped data in order to minimize unwanted cross core sharing.

Currently the best correlation option is the CurrentManagedThreadId which helps with continuity of accesses to the same stripe within a thread, but does not help much with preventing unwanted stripe sharing from threads running on separate cores.


@VSadov commented on Thu Feb 16 2017

Re: https://github.com/dotnet/coreclr/blob/e5f2df239b546ac9ed2417506c90af222eaf1013/src/mscorlib/src/System/Environment.cs#L709


@jkotas commented on Fri Feb 17 2017

Agree that it looks useful.

@VSadov Process for adding new public APIs https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/api-review-process.md

Close the issue here, and open a new one in corefx with the API proposal.


@gkhanna79 commented on Sat Mar 04 2017

@danmosemsft Can you please move this to CoreFX?

Drawaes commented 6 years ago

Ahh that looks better. The problem with RDTSCP I suspect is the "timing" aspect (not the which cpu) as it flushes the pipeline and serializes it causing a barrier... because I guess if you are timing at that level it would suck to get reordered ... Also those two recent timing bugs mean that its highly likely that high resolution timing will be disabled in say a VM shared environment...