dendibakh / perf-book

The book "Performance Analysis and Tuning on Modern CPU"
https://book.easyperf.net/perf_book
Creative Commons Zero v1.0 Universal
2k stars 144 forks source link

__rdtscp instruction should be used instead of __rdtsc #6

Open ujos opened 2 years ago

ujos commented 2 years ago

Because __rdtsc is not serializable CPU is free to reorder the execution of this instruction which could lead to wrong latency measurements results.

Instead the serializable version __rdtscp should be used.

dendibakh commented 2 years ago

Ok, I think you're right. At the same time, __rdtscp is more expensive. I guess I need to revisit that part. Thanks for the note.