I wonder why the blog post claims setting clock source to 'tsc' is considered dangerous.
Two frequently used system calls are ~77% slower on AWS EC2
41–50 of 101 posts
Re: Two frequently used system calls are ~77% slower on AWS EC2
#42Re: Two frequently used system calls are ~77% slower on AWS EC2
#43Yes, this is why we (Netflix) default to tsc over the xen clocksource. I found the xen clocksource had become a problem a few years ago, quantified using flame graphs, and investigated using my own microbenchmark. Summarized details here: https://www.slideshare.net/brendangregg/performance-tuning-e...
[1] Long term issues like inter-clock drift and global synchronization are a rather different problem area, and the OS has tools to help there.
Re: Two frequently used system calls are ~77% slower on AWS EC2
#44The title is misleading. 77% slower sounds like the system calls take 1.77x the time on EC2. In fact, the results indicate that the normal calls are 77% faster - in other words, EC2 gettimeofday and clock_gettime calls take nearly 4.5x longer to run on EC2 than they do on ordinary systems. This is a big speed hit. Some programs can use gettimeofday extremely frequently - for example, many programs call timing functio…
4.5x longer = 350% slower.
Re: Two frequently used system calls are ~77% slower on AWS EC2
#45I wonder why the blog post claims setting clock source to 'tsc' is considered dangerous.
Because if the clock rate changes, tsc can become out of sync. https://lwn.net/Articles/209101/
A worse issue is that the counters may not be synchronized between cpus, which may be an issue when the process moves between sockets.
But I wouldn't call that "dangerous", it's simply a feature of the clock source. If that's an issue for your program, you should use CLOCK_MONOTONIC anyway and not rely on gettimeofday() doing the right thing.
Re: Two frequently used system calls are ~77% slower on AWS EC2
#46I prefer the way Solaris solved this problem: 1) first, by eliminating the need for a context switch for libc calls such as gettimeofday(), gethrtime(), etc. (there is no public/supported interface on Solaris for syscalls, so libc would be used) 2) by providing additional, specific interfaces with certain guarantees: https://docs.oracle.com/cd/E53394_01/html/E54766/get-sec-fro... This was accomplished by creating a s…
This is precisely what the vDSO does. The clocksources mentioned explicitly list themselves as not supporting this action, hence the fallback to a regular system call.
The difference is that on Solaris, since there is no public system call interface, there's also no need for a fallback. Every program is just faster, no matter how Solaris is virtualized, since every program is using libc.
There's also no need for an administrative interface to control clocksource; the best one is always used.
Re: Two frequently used system calls are ~77% slower on AWS EC2
#47I prefer the way Solaris solved this problem: 1) first, by eliminating the need for a context switch for libc calls such as gettimeofday(), gethrtime(), etc. (there is no public/supported interface on Solaris for syscalls, so libc would be used) 2) by providing additional, specific interfaces with certain guarantees: https://docs.oracle.com/cd/E53394_01/html/E54766/get-sec-fro... This was accomplished by creating a s…
You just described the old method Linux used that was vulnerable to info leaks iirc and why it now a vDSO
Re: Two frequently used system calls are ~77% slower on AWS EC2
#48Author here, greetings. Anyone who finds this interesting may also enjoy our writeup describing every Linux system call method in detail [1]. [1]: https://blog.packagecloud.io/eng/2016/04/05/the-definitive-g...
Re: Two frequently used system calls are ~77% slower on AWS EC2
#49Is this just an EC2 problem, or does it affect any Xen/KVM guest? I ran the test program on a Hyper-V VM running CentOS 7 and got the same result: 100 calls to the gettimeofday syscall. Conversely, I tested a vSphere guest (also running CentOS 7), which didn't call gettimeofday at all.
>Is this just an EC2 problem, or does it affect any Xen/KVM guest? Looks like it's how the Xen hypervisor works.
Re: Two frequently used system calls are ~77% slower on AWS EC2
#50Earlier quoted context omitted.
Because if the clock rate changes, tsc can become out of sync. https://lwn.net/Articles/209101/
Not really. Recent CPUs (at least those from Intel, which is what EC2 runs on) implement constant_tsc, so the frequency does not affect the tsc. A worse issue is that the counters may not be synchronized between cpus, which may be an issue when the process moves between sockets. But I wouldn't call that "dangerous", it's simply a feature of the clock source. If that's an issue for your program, you should use CLOCK_M…