base: Add a perftest for thread_local based TLS.
thread_local is already used in Chrome, though not widely as it is still banned by the style-guide. Add a benchmark to estimate its performance. Detailed results below, tldr: - On Linux: 2-3x faster than the current TLS implementation for reading, ~10x faster for writing - On Android: ~4x faster for reading On Linux (Intel Xeon "Haswell"): [ RUN ] ThreadLocalStoragePerfTest.ThreadLocalStorage *RESULT TLS read throughput: ThreadLocalStorage= 154230.54381689752 operations/ms *RESULT TLS write throughput: ThreadLocalStorage= 168171.8043152885 operations/ms *RESULT TLS read-write throughput: ThreadLocalStorage= 82276.76257394624 operations/ms *RESULT TLS read throughput: ThreadLocalStorage 4 threads= 155118.12245024586 operations/ms *RESULT TLS write throughput: ThreadLocalStorage 4 threads= 171458.9441558219 operations/ms *RESULT TLS read-write throughput: ThreadLocalStorage 4 threads= 82700.67318347971 operations/ms [ RUN ] ThreadLocalStoragePerfTest.PlatformTls *RESULT TLS read throughput: PlatformTls= 318390.2190524707 operations/ms *RESULT TLS write throughput: PlatformTls= 232018.56148491878 operations/ms *RESULT TLS read-write throughput: PlatformTls= 144791.13878230652 operations/ms *RESULT TLS read throughput: PlatformTls 4 threads= 255597.5871587772 operations/ms *RESULT TLS write throughput: PlatformTls 4 threads= 195446.10573634322 operations/ms *RESULT TLS read-write throughput: PlatformTls 4 threads= 132872.70794578793 operations/ms [ RUN ] ThreadLocalStoragePerfTest.Cpp11Tls *RESULT TLS read throughput: C++ thread_local TLS= 384763.37052712584 operations/ms *RESULT TLS write throughput: C++ thread_local TLS= 2500625.1562890722 operations/ms *RESULT TLS read-write throughput: C++ thread_local TLS= 2430724.3558580456 operations/ms *RESULT TLS read throughput: C++ thread_local TLS 4 threads= 342794.4604415193 operations/ms *RESULT TLS write throughput: C++ thread_local TLS 4 threads= 1192037.1915603767 operations/ms *RESULT TLS read-write throughput: C++ thread_local TLS 4 threads= 1774937.8771742987 operations/ms On Android (Pixel 1, Snapdragon 821): [ RUN ] ThreadLocalStoragePerfTest.ThreadLocalStorage *RESULT TLS read throughput: ThreadLocalStorage= 48410.911819524124 operations/ms *RESULT TLS write throughput: ThreadLocalStorage= 29321.041952546824 operations/ms *RESULT TLS read-write throughput: ThreadLocalStorage= 18727.64387512407 operations/ms *RESULT TLS read throughput: ThreadLocalStorage 4 threads= 34612.97501981593 operations/ms *RESULT TLS write throughput: ThreadLocalStorage 4 threads= 22686.79741824245 operations/ms *RESULT TLS read-write throughput: ThreadLocalStorage 4 threads= 14610.463137070981 operations/ms [ RUN ] ThreadLocalStoragePerfTest.PlatformTls *RESULT TLS read throughput: PlatformTls= 40691.75991861648 operations/ms *RESULT TLS write throughput: PlatformTls= 43693.49884430696 operations/ms *RESULT TLS read-write throughput: PlatformTls= 23500.547562758213 operations/ms *RESULT TLS read throughput: PlatformTls 4 threads= 31334.701615303868 operations/ms *RESULT TLS write throughput: PlatformTls 4 threads= 33404.26171570969 operations/ms *RESULT TLS read-write throughput: PlatformTls 4 threads= 19587.027120197752 operations/ms [ RUN ] ThreadLocalStoragePerfTest.Cpp11Tls *RESULT TLS read throughput: C++ thread_local TLS= 205532.9469313931 operations/ms *RESULT TLS write throughput: C++ thread_local TLS= 19075.81491881333 operations/ms *RESULT TLS read-write throughput: C++ thread_local TLS= 15905.078491562355 operations/ms *RESULT TLS read throughput: C++ thread_local TLS 4 threads= 81040.56080068075 operations/ms *RESULT TLS write throughput: C++ thread_local TLS 4 threads= 11412.84127248615 operations/ms *RESULT TLS read-write throughput: C++ thread_local TLS 4 threads= 9210.180934004447 operations/ms Bug: 998048 Change-Id: I018c3a7989f3ae48406ba86c282f5c4e4b205bea Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1873751Reviewed-by:François Doray <fdoray@chromium.org> Commit-Queue: Benoit L <lizeb@chromium.org> Cr-Commit-Position: refs/heads/master@{#708539}
Showing
Please register or sign in to comment