summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-03-29 05:56:37 +0000
committerDean Michael Berris <dberris@google.com>2017-03-29 05:56:37 +0000
commiteacaa8fb837ccbfb65e100a6c12259c78428f3b1 (patch)
tree038de25a41d18bd9c339a43d98d713aaf4193e93 /include
parent8b987788165d15b1c5980751392c179defa86ab7 (diff)
[XRay] [compiler-rt] Write buffer length to FDR log before writing buffer.
Summary: Currently the FDR log writer, upon flushing, dumps a sequence of buffers from its freelist to disk. A reader can read the first buffer up to an EOB record, but then it is unclear how far ahead to scan to find the next threads traces. There are a few ways to handle this problem. 1. The reader has externalized knowledge of the buffer size. 2. The size of buffers is in the file header or otherwise encoded in the log. 3. Only write out the portion of the buffer with records. When released, the buffers are marked with a size. 4. The reader looks for memory that matches a pattern and synchronizes on it. 2 and 3 seem the most flexible and 2 does not rule 3 out. This is an implementation of 2. In addition, the function handler for fdr more aggressively checks for finalization and makes an attempt to release its buffer. Reviewers: pelikan, dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31384 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298982 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/xray/xray_records.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/xray/xray_records.h b/include/xray/xray_records.h
index 71637d1fe..feb8d228b 100644
--- a/include/xray/xray_records.h
+++ b/include/xray/xray_records.h
@@ -24,6 +24,14 @@ enum FileTypes {
FDR_LOG = 1,
};
+// FDR mode use of the union field in the XRayFileHeader.
+struct alignas(16) FdrAdditionalHeaderData {
+ uint64_t ThreadBufferSize;
+};
+
+static_assert(sizeof(FdrAdditionalHeaderData) == 16,
+ "FdrAdditionalHeaderData != 16 bytes");
+
// This data structure is used to describe the contents of the file. We use this
// for versioning the supported XRay file formats.
struct alignas(32) XRayFileHeader {
@@ -42,10 +50,15 @@ struct alignas(32) XRayFileHeader {
// The frequency by which TSC increases per-second.
alignas(8) uint64_t CycleFrequency = 0;
- // The current civiltime timestamp, as retrived from 'clock_gettime'. This
- // allows readers of the file to determine when the file was created or
- // written down.
- struct timespec TS;
+ union {
+ char FreeForm[16];
+ // The current civiltime timestamp, as retrived from 'clock_gettime'. This
+ // allows readers of the file to determine when the file was created or
+ // written down.
+ struct timespec TS;
+
+ struct FdrAdditionalHeaderData FdrData;
+ };
} __attribute__((packed));
static_assert(sizeof(XRayFileHeader) == 32, "XRayFileHeader != 32 bytes");