The Speed of Time
brendangregg.com
brendangregg.com
Also, think about it this way: imagine if you started out with Ubuntu. You’d then likely never notice that your system is 30% slower than it needs be.
Now, take it further: the system from which you moved to Ubuntu most likely has not been the most efficient it could get either, and it was also likely that random crap was sapping significant amount of performance.
And finally, extend this from Cassandra and Ubuntu to everything else. Welcome to 2021, where machines are faster than ever, but things feel as slow as they have always been.
But there is still hope for us mere mortals to understand how systems work better and make them faster. His systems performance book is absolutely ridiculous. It is pretty dense and I've been through chapters several times without fully grasping everything, but it is extremely pragmatic with how it dives into various topics and it is by far the best computer science book I've read.
I highly recommend it to anyone who gets close to systems.
Ran into an issue where on two identical machines one was showing cpu usage 30% higher. A quick `perf top` showed it was spending the majority of its time in `read_hpet` in the kernel. Found that one machine was set to hpet because the kernel thought tsc was unstable at bootup:
tsc: Marking TSC unstable due to check_tsc_sync_source failed
Only ever happened one time and we could never reproduce it. bios/firmware updates might have also helped. We still added a monitoring check to ensure that current_clocksource was tsc.Just some data points for anyone with an interest in EC2 and clock sources...
I kept having one of the nodes dropping out because it had missed sending its heartbeats, even though it was under next to no load and otherwise healthy.
It was a head scratcher for a bit, but once I ended up figuring out what was going on it was a super obvious issue.
Running `date; sleep 1;` in a loop, both were printing numbers increasing one second at a time, but one node was printing twice as fast as the other! Of course there were timing issues when two nodes couldn’t agree on something as fundamental as how long a second was.
(As an aside, thank you for all your work on FreeBSD! If I ever run into you around town I owe you a beer!)
(BTW I have a Patreon for anyone who wants to contribute to my FreeBSD/EC2 work or can convince their employers to: https://www.patreon.com/cperciva )
Yes, t3 instances. I wasn't seeing this behaviour on _all_ of the instances. Deploying and redeploying a three node cluster a few times trying to track down what was going on never left me in a stable state though so it certainly wasn't rare.
This was in us-west-2. I didn't notice if the issue correlated with the AZ or anything else, as until I figured out what was going on I naturally assumed it was an issue on my end and once I found the issue I just patched over it with `kern.timecounter.hardware=ACPI-fast` and moved on since this was just some play projects.
Haven't used FreeBSD at work, but I've been using it at home and for personal hosting on AWS for the past 20 odd years. Just pledged a bit on Patreon. Thanks for all the work you put in!
Using ACPI-fast is the correct workaround on 13.0, at least until the underlaying EC2 issue gets fixed. On 14.0 we have kvmclock which works fine even on instances with broken TSCs, and that's much faster than ACPI-fast -- but still slightly slower than TSC.
The strange thing is that where possible QueryPerformanceCounter should use just RDTSC internally accordingly to docs. By timing it it appears that at least in my case it did not.
When I was thinking about "What could system calls look like in a clean-sheet OS?" (e.g. async-only) I always found time() was a special case that opened the door to more special cases since time() is usually almost all overhead and it often gets called often.
I am also involved in similar detective works, but usually I tend to forget the initial parts before anyone figures out that it is an investigation