brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 81bb190 Raw
74 lines · c
1//===-- xray_profile_collector.h -------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file is a part of XRay, a dynamic runtime instrumentation system.10//11// This file defines the interface for a data collection service, for XRay12// profiling. What we implement here is an in-process service where13// FunctionCallTrie instances can be handed off by threads, to be14// consolidated/collected.15//16//===----------------------------------------------------------------------===//17#ifndef XRAY_XRAY_PROFILE_COLLECTOR_H18#define XRAY_XRAY_PROFILE_COLLECTOR_H19 20#include "xray_function_call_trie.h"21 22#include "xray/xray_log_interface.h"23 24namespace __xray {25 26/// The ProfileCollectorService implements a centralised mechanism for27/// collecting FunctionCallTrie instances, indexed by thread ID. On demand, the28/// ProfileCollectorService can be queried for the most recent state of the29/// data, in a form that allows traversal.30namespace profileCollectorService {31 32/// Posts the FunctionCallTrie associated with a specific Thread ID. This33/// will:34///35/// Moves the collection of FunctionCallTrie, Allocators, and Buffers associated36/// with a thread's data to the queue. This takes ownership of the memory37/// associated with a thread, and manages those exclusively.38///39void post(BufferQueue *Q, FunctionCallTrie &&T,40          FunctionCallTrie::Allocators &&A,41          FunctionCallTrie::Allocators::Buffers &&B, ThreadID TId);42 43/// The serialize will process all FunctionCallTrie instances in memory, and44/// turn those into specifically formatted blocks, each describing the45/// function call trie's contents in a compact form. In memory, this looks46/// like the following layout:47///48///   - block size (32 bits)49///   - block number (32 bits)50///   - thread id (64 bits)51///   - list of records:52///     - function ids in leaf to root order, terminated by53///       0 (32 bits per function id)54///     - call count (64 bit)55///     - cumulative local time (64 bit)56///     - record delimiter (64 bit, 0x0)57///58void serialize();59 60/// The reset function will clear out any internal memory held by the61/// service. The intent is to have the resetting be done in calls to the62/// initialization routine, or explicitly through the flush log API.63void reset();64 65/// This nextBuffer function is meant to implement the iterator functionality,66/// provided in the XRay API.67XRayBuffer nextBuffer(XRayBuffer B);68 69} // namespace profileCollectorService70 71} // namespace __xray72 73#endif // XRAY_XRAY_PROFILE_COLLECTOR_H74