Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds a new benchmark - misc-futex-perf.cc. The goal is to indirectly measure performance of the futex syscall implemented in OSv and compare it to Linux and thus guide us in implementing the improvements described in the issue #853. The benchmark program does it by implementing special mutex - fmutex - based on futex syscall according to the algorithm specified in the Ulrich Drepper's paper "Futexes Are Tricky". The test is similar to the misc-mutex2.cc written by Nadav Har'El. It takes three parameters: mandatory number of threads (nthreads) and a computation length (worklen) and optional number of mutexes (nmutexes) which is equal to 1 by default. The test groups all threads (nthreads * nmutexes) into nmutexes sets of nthreads threads trying to take the group mutex (one out of nmutexes) in a loop and increment the group counter and then do some short computation of the specified length outside the loop. The test runs for 30 seconds, and shows the average total number of lock-protected counter increments per second. The number of cpus is set by using the '-c' option passes to run.py in case of OSv, and using taskset -c 0..n when running the same program on host. The results of the test that show number of total increments (across counters of all groups of threads) per second for both OSv and Linux host are below. It also shows number of total futex syscall calls (wake) captured by adding an atomic counter in the futex implementation for OSv. +------------------+----------------------------+----------------------+ | Run parameters | On OSv guest | On Linux host (op/s) | | | (op/s) (futex called) | +------------------+----------------------------+----------------------+ | 1 0 1 (1 cpu) | 5.1353e+07 0 | 5.21169e+07 | | 2 0 1 (2 cpus) | 2.26067e+07 345,745 | 1.78575e+07 | | 4 0 1 (4 cpus) | 4.93204e+07 2342 | 1.41494e+07 | | 1 500 1 (1 cpu) | 5.67558e+06 0 | 5.75555e+06 | | 2 500 1 (2 cpus) | 9.19294e+06 3618 | 9.78263e+06 | | 4 500 1 (4 cpus) | 5.65933e+06 38,243 | 6.87465e+06 | | 4 500 2 (4 cpus) | 8.30834e+06 266 | 1.15537e+07 | | 4 500 4 (4 cpus) | 1.06216e+07 111 | 1.16908e+07 | | 4 500 8 (4 cpus) | 1.39291e+07 101 | 1.31845e+07 | +------------------+----------------------------+----------------------+ The results are surprising and somewhat confusing. For example the lines 2 and 3 show OSv outperforming Linux by a lot. Also the line 7 (4 500 2) shows OSv peformance worse by ~30% even when number of futex calls is pretty low. Possibly there is a flaw in this test, or some kind of different explanation. Signed-off-by: Waldemar Kozaczuk <[email protected]> Message-Id: <[email protected]>
- Loading branch information