Earlier quoted context omitted.
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…
how does constant_tsc interact with VMs being silently migrated from one physical machine to another?
Two frequently used system calls are ~77% slower on AWS EC2
51–60 of 101 posts
Re: Two frequently used system calls are ~77% slower on AWS EC2
#52Earlier quoted context omitted.
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.
Not quite; vdso is a general syscall-wrapper mechanism. The Solaris solution is specifically just for the gettimeofday(), gethrtime() interfaces, etc. 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 int…
Please see this[1] for a detailed explanation. For a shorter explanation, please see the vDSO man page[2]. Thanks for reading my blog post!
[1]: https://blog.packagecloud.io/eng/2016/04/05/the-definitive-g... [2]: http://man7.org/linux/man-pages/man7/vdso.7.html
Re: Two frequently used system calls are ~77% slower on AWS EC2
#53Earlier quoted context omitted.
how does constant_tsc interact with VMs being silently migrated from one physical machine to another?
Not sure, but it can't be better than moving processes between CPUs I guess. Also, does EC2 silently move VMs like this?
Advanced users that can run their own analysis or who have applications which would withstand potential time warps, are of course, free to ignore my warning at their own risk ;)
Re: Two frequently used system calls are ~77% slower on AWS EC2
#54Earlier quoted context omitted.
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…
how does constant_tsc interact with VMs being silently migrated from one physical machine to another?
You see this a lot when AWS lets you know about maintenance on a physical host and gives you the option to avoid the automated move by doing these steps manually at a time of your choosing before the maintenance window.
Re: Two frequently used system calls are ~77% slower on AWS EC2
#55The 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…
This is what's usually considered the "root cause" of this problem, though. It's easy enough, if it's your own program, to wrap the OS time APIs to cache the evaluated timestamp for one event-loop (or for a given length of realtime by checking with the TSC.) Most modern interpreters/VM runtimes also do this.
Re: Two frequently used system calls are ~77% slower on AWS EC2
#56Earlier quoted context omitted.
Not quite; vdso is a general syscall-wrapper mechanism. The Solaris solution is specifically just for the gettimeofday(), gethrtime() interfaces, etc. 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 int…
Not quite. The vDSO provides a general syscall-wrapper mechanism for certain types of system call interfaces. It also provides implementations of gettimeofday clock_gettime and 2 other system calls completely in userland and acts precisely as you've described. Please see this[1] for a detailed explanation. For a shorter explanation, please see the vDSO man page[2]. Thanks for reading my blog post! [1]: https://blog.p…
Also, I personally find VDSO disagreeable as do others although perhaps not in as dramatic terms as some:
https://mobile.twitter.com/bcantrill/status/5548101655902617...
I think Ian Lance Taylor's summary is the most balanced and thoughtful:
Basically you want the kernel to provide a mapping for a small number of magic symbols to addresses that can be called at runtime. In other words, you want to map a small number of indexes to addresses. I can think of many different ways to handle that in the kernel. I don't think the first mechanism I would reach for would be for the kernel to create an in-memory shared library. It's kind of a baroque mechanism for implementing a simple table.
It's true that dynamically linked programs can use the ELF loader. But the ELF loader needed special changes to support VDSOs. And so did gdb. And this approach doesn't help statically linked programs much. And glibc functions needed to be changed anyhow to be aware of the VDSO symbols. So as far as I can tell, all of this complexity really didn't get anything for free. It just wound up being complex.
All just my opinion, of course.
https://github.com/golang/go/issues/8197#issuecomment-660959...
Re: Two frequently used system calls are ~77% slower on AWS EC2
#57Earlier quoted context omitted.
how does constant_tsc interact with VMs being silently migrated from one physical machine to another?
Not sure, but it can't be better than moving processes between CPUs I guess. Also, does EC2 silently move VMs like this?
Re: Two frequently used system calls are ~77% slower on AWS EC2
#58Author 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...
Nitpick - `77 percent faster` is not the inverse of `77 percent slower`. The line that says `The results of this microbenchmark show that the vDSO method is about 77% faster` should read `446% faster`.
EDIT: B would, of course, take 100% longer than A, rather than be 100% faster.
Re: Two frequently used system calls are ~77% slower on AWS EC2
#59Earlier quoted context omitted.
Not sure, but it can't be better than moving processes between CPUs I guess. Also, does EC2 silently move VMs like this?
Even without migration, the synchronization can be an issue. In older multi-core machines, tsc synchronization was an issue among cores. Modern systems take care of this. And core CPU clock frequency change is also taken care of, so that constant rate is available via tsc. However, when hypervisors such as VMWare or paravirtualization like Xen come into play, there are further issues, because RDTSC instruction either…
For me, it's much simpler - I come from the PostgreSQL world, so gettimeofday() is pretty much what EXPLAIN ANALYZE does to instrument queries. Good time source means small overhead, bad time source means instrumented queries may take multiples of actual run time (and be skewed in various ways). No fun.