-
Notifications
You must be signed in to change notification settings - Fork 2.2k
programs/timefn: Don't use clock() on Unix when C < 11 to improve multi-thread benchmark #3165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I just came to the same conclusion. The "bad performance" is a measurement error in zstdcli, not an actual performance issue. The libzstd produced with c11 and c99 are identical. |
I think this patch goes in the right direction. I'm actually surprised we don't use minor : I understand that edit : I just checked, and indeed |
Note : It does fix It's not necessarily a problem for this PR, which provides It just shows there is a bit more to do to address #3163 specifically. |
- cmake/meson pass -std=gnu99 which hits clock() fallback - clock() fallback skews multi-threading benchmarks - TIME_UTC (C11) is similar to CLOCK_REALTIME (POSIX) - GNU may hide CLOCK_REALTIME in -std=c99 (__STRICT_ANSI__) - Switch to CLOCK_MONOTONIC like before 36d2dfd
Addressed via file-local |
@@ -8,6 +8,7 @@ | |||
* You may select, at your option, one of the above-listed licenses. | |||
*/ | |||
|
8000
|||
#define _POSIX_C_SOURCE 200809L /* clock_gettime */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should rather be defined in timefn.h
, just before the #include <time.h>
,
otherwise, UTIL_time_t
declaration in timefn.h
will be out of sync with timefn.c
.
edit : although, note the following compilation issue :
../programs/timefn.h:22:0: error: "_POSIX_C_SOURCE" redefined [-Werror]
With #3163 out of the way, let's now focus on this PR. |
which restore clock_gettime() as a way to get a usable timer for posix systems. Original PR by @jbeich
which restore clock_gettime() as a way to get a usable timer for posix systems. Original PR by @jbeich
Fixes #3163
See also freebsd/freebsd-src@6882d53b7fb8
See also aosp-mirror/platform_bionic@78e9ebc3b968
C90 aka
clock()
fallback being suboptimal seems to be known issue:zstd/programs/timefn.c
Lines 138 to 143 in b7b7edb