You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GetCurrentProcessorId was "fast" previously because of aggressive caching. It would return the same result for 3000 invocations (or was it 50000 invocations?, i do not remember..)
Since the threads can move between cores, long caching diminishes the value of this API. We saw problems with that.
However there are machines/OSs/hypervisors where underlying implementation is very slow (on order of 1000x slower than fast systems) and such caching could be the only way to not make this API an occasional perf trap.
The change was to measure the underlying implementation and adjust caching accordingly.
The goal was to improve precision on systems where it is possible, while not regressing hopelessly on older/slower systems.
Since, I assume you have a relatively modern system, the former performance of this API was basically measuring access to a thread local. Not much real work was happening comparatively.
35% is acceptable regression in this case. The calibration expects that "working" implementation will be a bit more expensive than just fetching a value from TLS.
3x-5x regression would be alarming. It would mean our measurements are off.
FWIW I got data from more machines and the regression is not bigger than a few nanoseconds so it's still acceptable and I am keeping it closed at it was.
Activity
DrewScoggins commentedon Jun 12, 2020
@adamsitnik @VSadov
VSadov commentedon Jun 12, 2020
GetCurrentProcessorIdwas "fast" previously because of aggressive caching. It would return the same result for 3000 invocations (or was it 50000 invocations?, i do not remember..)Since the threads can move between cores, long caching diminishes the value of this API. We saw problems with that.
However there are machines/OSs/hypervisors where underlying implementation is very slow (on order of 1000x slower than fast systems) and such caching could be the only way to not make this API an occasional perf trap.
The change was to measure the underlying implementation and adjust caching accordingly.
The goal was to improve precision on systems where it is possible, while not regressing hopelessly on older/slower systems.
Since, I assume you have a relatively modern system, the former performance of this API was basically measuring access to a thread local. Not much real work was happening comparatively.
35% is acceptable regression in this case. The calibration expects that "working" implementation will be a bit more expensive than just fetching a value from TLS.
3x-5x regression would be alarming. It would mean our measurements are off.
mangod9 commentedon Jul 22, 2020
Closing based on analysis above.
adamsitnik commentedon Aug 20, 2020
FWIW I got data from more machines and the regression is not bigger than a few nanoseconds so it's still acceptable and I am keeping it closed at it was.
System.Threading.Tests.Perf_Thread.GetCurrentProcessorId