Skip to content

Commit

Permalink
Cache string creation for logging. (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjp41 authored Nov 21, 2024
1 parent da170de commit 7579e66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rt/debug/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace Logging
};

// Filled in later by the scheduler thread
std::string get_systematic_id();
const std::string& get_systematic_id();

class LocalLog : public snmalloc::Pooled<LocalLog>
{
Expand Down
8 changes: 7 additions & 1 deletion src/rt/sched/schedulerthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ namespace Logging
{
using namespace verona::rt;

inline std::string get_systematic_id()
inline std::string create_systematic_id()
{
#if defined(USE_SYSTEMATIC_TESTING) || defined(USE_FLIGHT_RECORDER)
static std::atomic<size_t> external_id_source = 1;
Expand Down Expand Up @@ -367,4 +367,10 @@ namespace Logging
return "";
#endif
}

inline const std::string& get_systematic_id()
{
static thread_local std::string id = create_systematic_id();
return id;
}
}

0 comments on commit 7579e66

Please sign in to comment.