forked from luceracloud/libfasttime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
84 lines (57 loc) · 2.68 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
LIBFASTTIME
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This was open sourced before I expected. Much of the work was done
half a year ago and still has rough edges from what I remember,
specifically around gettimeofday(). The test code is also quite messy.
Please spend some time verifying behavior before putting in
production. Improvements will be eagerly accepted.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Fast time calls from user space.
SUMMARY
Overrides several time-related system library functions, providing
the same functionality without incurring the syscall penalty. It
is meant for applications with tight loops on time calls such as
gettimeofday(3C) and clock_gettime(3C), requiring latency of tens
of nanoseconds.
OVERRIDDEN FUNCTIONS
* gettimeofday(3C) -- Get wall clock time as period of seconds +
microseconds since Unix epoch.
* clock_gettime(3C) -- POSIX API providing access to several
different types of clocks.
- CLOCK_REALTIME -- System-wide wall clock as period of seconds
+ nanoseconds since Unix epoch.
- CLOCK_MONOTONIC -- System-wide clock relative to some
arbitrary point in time, only moves forward, and is not
affected by system time changes.
* gethrtime(3C) -- System-wide clock relative to some arbitrary
point in time and is not affected by system time changes. Only
available on illumos.
CAVEATS
* All functions are built on the CPU's TSC register. To provide
the expected latency no fencing (LFENCE) or synchronization
(CPUID/RDTSCP) is done. Out-of-order execution is free to
rearrange these calls with its surrounding instructions. This is
probably acceptable for the library's intended purpose. It would
be a different story if used for precise cycle count in
microbenchmarks.
INSTALL
CentOS 6.6
# yum install gcc glibc-devel.i686 libgcc-4.4.7-11.el6.i686 libstdc++-devel.i686
# make
# make test
# make install
USAGE
There are three different ways to link libfasttime to your
program.
1) Link to an individual program at compile time via the -L and -l
linker flags.
Linux:
gcc -m64 -L/opt/lucera/lib64 -lfasttime \
-Wl,-rpath,/opt/lucera/lib64 -o my_program my_program.c
2) Link to an individual program at runtime via the LD_PRELOAD
environment variable.
Linux:
LD_PRELOAD=/opt/lucera/\${LIB}/libfasttime.so my_program
3) Link to all programs at runtime.
Linux:
Uncomment line in /etc/ld.so.preload.