[trace] Keep track of a uint64_t tracing context
The most common information that you want to track between begin() and end() is the timestamp of the begin function, so you can measure the duration of the (de)compression call. Allow the tracing library to put this information inside the `ZSTD_TraceCtx`, so it doesn't need to keep a global map in this case. If a single uint64_t is not enough, the tracing library can return a unique identifier (like the context pointer) instead, and use it as a key in a map. This keeps the simple case simple.
This commit is contained in:
@@ -789,8 +789,8 @@ static size_t ZSTD_setRleBlock(void* dst, size_t dstCapacity,
|
||||
static void ZSTD_DCtx_trace_end(ZSTD_DCtx const* dctx, U64 uncompressedSize, U64 compressedSize, unsigned streaming)
|
||||
{
|
||||
#if ZSTD_TRACE
|
||||
if (dctx->tracingEnabled) {
|
||||
ZSTD_trace trace;
|
||||
if (dctx->traceCtx) {
|
||||
ZSTD_Trace trace;
|
||||
ZSTD_memset(&trace, 0, sizeof(trace));
|
||||
trace.version = ZSTD_VERSION_NUMBER;
|
||||
trace.streaming = streaming;
|
||||
@@ -801,7 +801,8 @@ static void ZSTD_DCtx_trace_end(ZSTD_DCtx const* dctx, U64 uncompressedSize, U64
|
||||
}
|
||||
trace.uncompressedSize = (size_t)uncompressedSize;
|
||||
trace.compressedSize = (size_t)compressedSize;
|
||||
ZSTD_trace_decompress_end(dctx, &trace);
|
||||
trace.dctx = dctx;
|
||||
ZSTD_trace_decompress_end(dctx->traceCtx, &trace);
|
||||
}
|
||||
#else
|
||||
(void)dctx;
|
||||
@@ -1383,7 +1384,7 @@ size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx)
|
||||
{
|
||||
assert(dctx != NULL);
|
||||
#if ZSTD_TRACE
|
||||
dctx->tracingEnabled = ZSTD_trace_decompress_begin(dctx);
|
||||
dctx->traceCtx = ZSTD_trace_decompress_begin(dctx);
|
||||
#endif
|
||||
dctx->expected = ZSTD_startingInputLength(dctx->format); /* dctx->format must be properly set */
|
||||
dctx->stage = ZSTDds_getFrameHeaderSize;
|
||||
|
||||
Reference in New Issue
Block a user