1 //===-- xray_profile_collector.h -------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of XRay, a dynamic runtime instrumentation system.
12 // This file defines the interface for a data collection service, for XRay
13 // profiling. What we implement here is an in-process service where
14 // FunctionCallTrie instances can be handed off by threads, to be
15 // consolidated/collected.
17 //===----------------------------------------------------------------------===//
18 #ifndef XRAY_XRAY_PROFILE_COLLECTOR_H
19 #define XRAY_XRAY_PROFILE_COLLECTOR_H
21 #include "xray_function_call_trie.h"
23 #include "xray/xray_log_interface.h"
27 /// The ProfileCollectorService implements a centralised mechanism for
28 /// collecting FunctionCallTrie instances, indexed by thread ID. On demand, the
29 /// ProfileCollectorService can be queried for the most recent state of the
30 /// data, in a form that allows traversal.
31 namespace profileCollectorService {
33 /// Posts the FunctionCallTrie associated with a specific Thread ID. This
36 /// Moves the collection of FunctionCallTrie, Allocators, and Buffers associated
37 /// with a thread's data to the queue. This takes ownership of the memory
38 /// associated with a thread, and manages those exclusively.
40 void post(BufferQueue *Q, FunctionCallTrie &&T,
41 FunctionCallTrie::Allocators &&A,
42 FunctionCallTrie::Allocators::Buffers &&B, tid_t TId);
44 /// The serialize will process all FunctionCallTrie instances in memory, and
45 /// turn those into specifically formatted blocks, each describing the
46 /// function call trie's contents in a compact form. In memory, this looks
47 /// like the following layout:
49 /// - block size (32 bits)
50 /// - block number (32 bits)
51 /// - thread id (64 bits)
52 /// - list of records:
53 /// - function ids in leaf to root order, terminated by
54 /// 0 (32 bits per function id)
55 /// - call count (64 bit)
56 /// - cumulative local time (64 bit)
57 /// - record delimiter (64 bit, 0x0)
61 /// The reset function will clear out any internal memory held by the
62 /// service. The intent is to have the resetting be done in calls to the
63 /// initialization routine, or explicitly through the flush log API.
66 /// This nextBuffer function is meant to implement the iterator functionality,
67 /// provided in the XRay API.
68 XRayBuffer nextBuffer(XRayBuffer B);
70 } // namespace profileCollectorService
74 #endif // XRAY_XRAY_PROFILE_COLLECTOR_H