1. trace_span_start() is always called with a string literal, so no copy needed (and we can use a macro to enforce this). 2. trace_span_tag() name and value are always longer-lived than the span, so no need to copy these either. Before: real 0m18.524000-19.100000(18.7674+/-0.21)s user 0m16.171000-16.833000(16.424+/-0.26)s sys 0m2.259000-2.400000(2.337+/-0.059)s After: real 0m16.421000-18.407000(17.8128+/-0.72)s user 0m14.242000-16.041000(15.5382+/-0.67)s sys 0m2.179000-2.363000(2.273+/-0.061)s Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
27 lines
1.1 KiB
C
27 lines
1.1 KiB
C
#ifndef LIGHTNING_COMMON_TRACE_H
|
|
#define LIGHTNING_COMMON_TRACE_H
|
|
#include "config.h"
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#define SPAN_ID_SIZE 8
|
|
#define TRACE_ID_SIZE 16
|
|
#undef TRACE_DEBUG
|
|
|
|
/* name must be a string constant */
|
|
#define trace_span_start(name, key) trace_span_start_(name "", (key))
|
|
void trace_span_start_(const char *name, const void *key);
|
|
void trace_span_end(const void *key);
|
|
void trace_span_tag(const void *key, const char *name, const char *value);
|
|
void trace_cleanup(void);
|
|
void trace_span_remote(u8 trace_id[TRACE_ID_SIZE], u8 span_id[SPAN_ID_SIZE]);
|
|
|
|
#define TRACE_LBL __FILE__ ":" stringify(__LINE__)
|
|
void trace_span_suspend_(const void *key, const char *lbl);
|
|
void trace_span_suspend_may_free_(const void *key, const char *lbl);
|
|
void trace_span_resume_(const void *key, const char *lbl);
|
|
#define trace_span_suspend(key) trace_span_suspend_(key, TRACE_LBL)
|
|
#define trace_span_suspend_may_free(key) trace_span_suspend_may_free_(key, TRACE_LBL)
|
|
#define trace_span_resume(key) trace_span_resume_(key, TRACE_LBL)
|
|
|
|
#endif /* LIGHTNING_COMMON_TRACE_H */
|