4473ccd5b0
time() can be a hot call, and it currently uses __vdso_gettimeofday, which is already pretty fast (~3 times faster than the syscall), but with a __vdso_time call it is ~3 times even faster, in part because __vdso_time does not require interlocking with updates, and the read for just the seconds is atomic. __vdso_time is always available, whereas __vdso_gettimeofday is gated on access to the physical timers. arm improvement is compelling (x10), x86 improvement is even more pronounced (x100). [TL;DR] w/vdso32 kernel patches, locked cores to MAX, little cores only. BEFORE: hikey960 vdso (aarch64): ---------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------- BM_time_clock_gettime 48 ns 48 ns 15414753 BM_time_clock_gettime_syscall 175 ns 175 ns 4062031 BM_time_clock_gettime_REALTIME 44 ns 44 ns 15897875 BM_time_clock_gettime_BOOTTIME 47 ns 47 ns 14307903 BM_time_clock_gettime_TAI 210 ns 210 ns 3341372 BM_time_clock_gettime_unsupported 100 ns 100 ns 7030649 BM_time_gettimeofday 47 ns 47 ns 14969643 BM_time_gettimeofday_syscall 163 ns 163 ns 4283542 BM_time_time 59 ns 59 ns 11815385 hikey960 vdso32 (aarch32): ---------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------- BM_time_clock_gettime 90 ns 90 ns 7572898 BM_time_clock_gettime_syscall 251 ns 251 ns 2763442 BM_time_clock_gettime_REALTIME 81 ns 80 ns 8699536 BM_time_clock_gettime_BOOTTIME 97 ns 97 ns 7256667 BM_time_clock_gettime_TAI 272 ns 272 ns 2570419 BM_time_clock_gettime_unsupported 160 ns 160 ns 4379819 BM_time_gettimeofday 73 ns 73 ns 9608922 BM_time_gettimeofday_syscall 200 ns 199 ns 3527957 BM_time_time 123 ns 123 ns 5651095 x86_64 (glibc): -------------------------------------------------------------------- Benchmark Time CPU Iterations -------------------------------------------------------------------- BM_time_clock_gettime 21 ns 21 ns 28873070 BM_time_clock_gettime_syscall 224 ns 224 ns 3095370 BM_time_clock_gettime_REALTIME 17 ns 17 ns 42083086 BM_time_clock_gettime_BOOTTIME 239 ns 239 ns 2924015 BM_time_clock_gettime_TAI 236 ns 236 ns 2961423 BM_time_clock_gettime_unsupported 221 ns 221 ns 3357696 BM_time_gettimeofday 22 ns 22 ns 27975154 BM_time_gettimeofday_syscall 238 ns 238 ns 2882032 BM_time_time 2 ns 2 ns 340354885 BM_time_time_syscall 207 ns 207 ns 3383073 imx7d_pico IOT nyc (w/arm,cpu-registers-not-fw-configured) (armv7a): (virtual timers) Benchmark Time(ns) CPU(ns) Iterations ------------------------------------------------------------------ BM_time_clock_gettime 20 477 1489362 BM_time_clock_gettime_syscall 20 487 1458333 BM_time_clock_gettime_REALTIME 19 464 1400000 BM_time_clock_gettime_BOOTTIME 29 700 1000000 BM_time_clock_gettime_TAI 29 690 1000000 BM_time_clock_gettime_unsupported 9 227 3043478 BM_time_gettimeofday 18 444 1555556 BM_time_gettimeofday_syscall 19 456 1555556 BM_time_time 21 497 1166667 imx7d_pico IOT nyc (wo/arm,cpu-registers-not-fw-configured) (armv7a): (physical timers) Benchmark Time(ns) CPU(ns) Iterations ------------------------------------------------------------------ BM_time_clock_gettime 6 144 4666667 BM_time_clock_gettime_syscall 20 486 1400000 BM_time_clock_gettime_REALTIME 6 136 5000000 BM_time_clock_gettime_BOOTTIME 6 153 4375000 BM_time_clock_gettime_TAI 31 760 1000000 BM_time_clock_gettime_unsupported 10 233 3043478 BM_time_gettimeofday 6 140 5000000 BM_time_gettimeofday_syscall 19 450 1555556 BM_time_time 9 203 3500000 AFTER: hikey960 vdso (aarch64): -------------------------------------------------------------------- Benchmark Time CPU Iterations -------------------------------------------------------------------- BM_time_clock_gettime 48 ns 48 ns 15414753 BM_time_clock_gettime_syscall 175 ns 175 ns 4062031 BM_time_clock_gettime_REALTIME 44 ns 44 ns 15897875 BM_time_clock_gettime_BOOTTIME 47 ns 47 ns 14307903 BM_time_clock_gettime_TAI 210 ns 210 ns 3341372 BM_time_clock_gettime_unsupported 100 ns 100 ns 7030649 BM_time_gettimeofday 47 ns 47 ns 14975314 BM_time_gettimeofday_syscall 164 ns 164 ns 4278797 BM_time_time 16 ns 16 ns 42932165 hikey960 vdso32 (aarch32): -------------------------------------------------------------------- Benchmark Time CPU Iterations -------------------------------------------------------------------- BM_time_clock_gettime 90 ns 90 ns 7572898 BM_time_clock_gettime_syscall 251 ns 251 ns 2763442 BM_time_clock_gettime_REALTIME 81 ns 80 ns 8699536 BM_time_clock_gettime_BOOTTIME 97 ns 97 ns 7256667 BM_time_clock_gettime_TAI 272 ns 272 ns 2570419 BM_time_clock_gettime_unsupported 160 ns 160 ns 4379819 BM_time_gettimeofday 73 ns 73 ns 9596230 BM_time_gettimeofday_syscall 199 ns 199 ns 3575428 BM_time_time 35 ns 35 ns 19798801 imx7d_pico IOT nyc (w/arm,cpu-registers-not-fw-configured) (armv7a): Benchmark Time(ns) CPU(ns) Iterations ------------------------------------------------------------------ BM_time_clock_gettime 20 477 1489362 BM_time_clock_gettime_syscall 20 487 1458333 BM_time_clock_gettime_REALTIME 19 464 1400000 BM_time_clock_gettime_BOOTTIME 29 700 1000000 BM_time_clock_gettime_TAI 29 690 1000000 BM_time_clock_gettime_unsupported 9 227 3043478 BM_time_gettimeofday 18 444 1555556 BM_time_gettimeofday_syscall 19 456 1555556 BM_time_time 2 50 11666667 imx7d_pico IOT nyc (wo/arm,cpu-registers-not-fw-configured) (armv7a): Benchmark Time(ns) CPU(ns) Iterations ------------------------------------------------------------------ BM_time_clock_gettime 6 144 4666667 BM_time_clock_gettime_syscall 20 486 1400000 BM_time_clock_gettime_REALTIME 6 136 5000000 BM_time_clock_gettime_BOOTTIME 6 153 4375000 BM_time_clock_gettime_TAI 31 760 1000000 BM_time_clock_gettime_unsupported 10 233 3043478 BM_time_gettimeofday 6 140 5000000 BM_time_gettimeofday_syscall 19 450 1555556 BM_time_time 2 50 10000000 Test: bionic-unit-tests --gtest_filter=time.time taskset F bionic-benchmarks --bionic_xml=vdso.xml \ --benchmark_filter='BM_time_(time*|clock_gettime*|gettimeofday*)' Bug: 63737556 Change-Id: I81b088a12ca41a6c4733d46c5477527777138efa |
||
---|---|---|
.. | ||
__get_tls.h | ||
bionic_arc4random.h | ||
bionic_asm.h | ||
bionic_asm_arm.h | ||
bionic_asm_arm64.h | ||
bionic_asm_mips.h | ||
bionic_asm_x86.h | ||
bionic_asm_x86_64.h | ||
bionic_auxv.h | ||
bionic_config.h | ||
bionic_constants.h | ||
bionic_ctype.h | ||
bionic_defs.h | ||
bionic_errdefs.h | ||
bionic_fortify.h | ||
bionic_futex.h | ||
bionic_globals.h | ||
bionic_ieee.h | ||
bionic_lock.h | ||
bionic_macros.h | ||
bionic_malloc_dispatch.h | ||
bionic_mbstate.h | ||
bionic_page.h | ||
bionic_prctl.h | ||
bionic_sdk_version.h | ||
bionic_sigdefs.h | ||
bionic_ssp.h | ||
bionic_string_utils.h | ||
bionic_systrace.h | ||
bionic_time_conversions.h | ||
bionic_tls.h | ||
bionic_vdso.h | ||
CachedProperty.h | ||
CFIShadow.h | ||
ErrnoRestorer.h | ||
FdPath.h | ||
get_cpu_count_from_string.h | ||
grp_pwd.h | ||
icu.h | ||
kernel_sigset_t.h | ||
KernelArgumentBlock.h | ||
NetdClientDispatch.h | ||
ScopedPthreadMutexLocker.h | ||
ScopedReaddir.h | ||
ScopedSignalBlocker.h | ||
thread_private.h | ||
WriteProtected.h |