1
- // ===- fdrmode-bench.cc - XRay Instrumentation Benchmarks ------------------ ===//
1
+ // ===- fdrmode-bench.cc - XRay Instrumentation Benchmarks -----------------===//
2
2
//
3
3
// The LLVM Compiler Infrastructure
4
4
//
@@ -26,14 +26,13 @@ namespace {
26
26
// stores performed on this variable.
27
27
volatile int val = 0 ;
28
28
29
- __xray::FDRLoggingOptions Options;
30
-
31
29
} // namespace
32
30
33
31
// We define a multi-threaded benchmark which measures the overall costs
34
32
// introduced by the XRay handlers upstream. This will exercise a tight loop
35
33
// calling a single function that practically does nothing.
36
- [[clang::xray_always_instrument]] __attribute__((noinline)) __attribute__((weak)) int
34
+ [[clang::xray_always_instrument]] __attribute__((noinline))
35
+ __attribute__ ((weak)) int
37
36
EmptyFunction() {
38
37
return 0 ;
39
38
}
@@ -45,11 +44,14 @@ volatile bool log_initialized = false;
45
44
[[clang::xray_never_instrument]] void SetUpXRayFDRMultiThreaded (
46
45
benchmark::State& state) {
47
46
if (!log_initialized) {
48
- Options.ReportErrors = true ;
49
- Options.Fd = open (" /dev/null" , O_WRONLY);
50
- assert ((Options.Fd != -1 ) && " Cannot open /dev/null!" );
51
- __xray_log_init (getpagesize (), 1 << 16 , &Options,
52
- sizeof (__xray::FDRLoggingOptions));
47
+ if (__xray_log_select_mode (" xray-fdr" ) !=
48
+ XRayLogRegisterStatus::XRAY_REGISTRATION_OK)
49
+ std::abort ();
50
+
51
+ std::string flags = " no_file_flush=true:buffer_size=" ;
52
+ flags += std::to_string (getpagesize ()) + " :buffer_max=" ;
53
+ flags += std::to_string (1 << 16 );
54
+ __xray_log_init_mode (" xray-fdr" , flags.c_str ());
53
55
__xray_remove_customevent_handler ();
54
56
__xray_patch ();
55
57
log_initialized = true ;
@@ -67,7 +69,7 @@ volatile bool log_initialized = false;
67
69
}
68
70
69
71
[[clang::xray_never_instrument]] static void BM_XRayFDRMultiThreaded (
70
- benchmark::State& state) {
72
+ benchmark::State& state) {
71
73
if (state.thread_index == 0 ) {
72
74
SetUpXRayFDRMultiThreaded (state);
73
75
}
@@ -80,7 +82,6 @@ volatile bool log_initialized = false;
80
82
}
81
83
}
82
84
83
- BENCHMARK (BM_XRayFDRMultiThreaded)
84
- ->ThreadRange(1 , 32 ); // Number of threads
85
+ BENCHMARK (BM_XRayFDRMultiThreaded)->ThreadRange(1 , 32 ); // Number of threads
85
86
86
87
BENCHMARK_MAIN ();
0 commit comments