(no title)
sa46 | 6 months ago
My understanding is that using tsc directly is tricky. The rate might not be constant, and the rate differs across cores. [1]
[1]: https://www.pingcap.com/blog/how-we-trace-a-kv-database-with...
sa46 | 6 months ago
My understanding is that using tsc directly is tricky. The rate might not be constant, and the rate differs across cores. [1]
[1]: https://www.pingcap.com/blog/how-we-trace-a-kv-database-with...
toast0|6 months ago
You could cpu pin the thread that's reading the tsc, except you can't pin threads in OpenBSD :p
wahern|6 months ago
OpenBSD actually only implemented this optimization relatively recently. Though most TSCs will be invariant, they still need to be trained across cores, and there are other minutiae (sleeping states?) that made it a PITA to implement in a reliable way, and OpenBSD doesn't have as much manpower as Linux. Some of those non-obvious issues would be relevant to someone trying to do this manually, unless they could rely on their specific hardware behavior.
quotemstr|6 months ago
denotational|6 months ago
tonyarkles|6 months ago
The issue ended up being that my multi-threaded code when running on a single core pinned that core at 100% CPU usage, as expected, but when running it across 4 cores it was running 4 cores at 25% usage each. This resulted in the clock governor turning down the frequency on the cores from ~2GHz to 900MHz and causing the execution speed to drop even worse than just the expected lock contention. It was a fun mystery to dig into for a while.
Dylan16807|6 months ago
I'm not sure of the details for when cores end up with different numbers.
triknomeister|6 months ago
ainiriand|6 months ago
unknown|6 months ago
[deleted]