看到「Two frequently used system calls are ~77% slower on AWS EC2」這篇在講 gettimeofday
與 clock_gettime
的效能,另外搜資料時發現應該也是作者提問的「gettimeofday() not using vDSO?」這篇。
在 EC2 比較新的機器上用 tsc 應該是沒問題的 (在 2015 的時候官方就這樣建議了):
it seems tsc support in Xen has improved with version 4.0 and with improved CPU support in Sandy Bridge+ platforms. Modern EC2 machines should be okay with tsc. Check Xen version using dmesg | grep "Xen version". Amazon recommended the tsc clocksource already in re:Invent 2015 (https://www.slideshare.net/AmazonWebServices/cmp402-amazon-ec2-instances-deep-dive). I'm not yet running to production with this, but the situation doesn't seem as bad as implied by packagecloud.
開了一台 t2.micro 看 /sys/devices/system/clocksource/clocksource0/current_clocksource
看起來目前是設成 xen
:
ubuntu@ip-172-31-22-165:~$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource xen
在「(CMP402) Amazon EC2 Instances Deep Dive」這邊也可以看到一些資料 (page 24 與 page 25):