Remove std::cout
Now we have an allocation free formatting routine, remove std::cout from tracing.
This commit is contained in:
committed by
Matthew Parkinson
parent
bb82ac15e3
commit
bdb3183989
@@ -277,8 +277,7 @@ namespace snmalloc
|
||||
auto p = local_state.object_range->alloc_range(size);
|
||||
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Alloc chunk: " << p.unsafe_ptr() << " (" << size << ")"
|
||||
<< std::endl;
|
||||
message<1024>("Alloc chunk: {} ({})", p.unsafe_ptr(), size);
|
||||
#endif
|
||||
if (p == nullptr)
|
||||
{
|
||||
@@ -286,7 +285,7 @@ namespace snmalloc
|
||||
meta_cap, PAGEMAP_METADATA_STRUCT_SIZE);
|
||||
errno = ENOMEM;
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Out of memory" << std::endl;
|
||||
message<1024>("Out of memory");
|
||||
#endif
|
||||
return {p, nullptr};
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace snmalloc
|
||||
{
|
||||
FlagLock lock{initialisation_lock};
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Run init_impl" << std::endl;
|
||||
message<1024>("Run init_impl");
|
||||
#endif
|
||||
|
||||
if (initialised)
|
||||
|
||||
@@ -205,6 +205,13 @@ namespace snmalloc
|
||||
*/
|
||||
template<size_t BufferSize = 1024, typename... Args>
|
||||
[[noreturn]] inline void report_fatal_error(Args... args);
|
||||
|
||||
/**
|
||||
* Forward declaration so that this can be called before the pal header is
|
||||
* included.
|
||||
*/
|
||||
template<size_t BufferSize = 1024, typename... Args>
|
||||
inline void message(Args... args);
|
||||
} // namespace snmalloc
|
||||
|
||||
#ifdef SNMALLOC_CHECK_CLIENT
|
||||
|
||||
@@ -342,8 +342,10 @@ namespace snmalloc
|
||||
#endif
|
||||
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Slab " << start_of_slab.unsafe_ptr()
|
||||
<< " is unused, Object sizeclass " << sizeclass << std::endl;
|
||||
message<1024>(
|
||||
"Slab {} is unused, Object sizeclass {}",
|
||||
start_of_slab.unsafe_ptr(),
|
||||
sizeclass);
|
||||
#else
|
||||
UNUSED(start_of_slab);
|
||||
#endif
|
||||
@@ -412,7 +414,7 @@ namespace snmalloc
|
||||
size_t size = bits::one_at_bit(entry_sizeclass);
|
||||
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Large deallocation: " << size << std::endl;
|
||||
message<1024>("Large deallocation: {}", size);
|
||||
#else
|
||||
UNUSED(size);
|
||||
#endif
|
||||
@@ -437,7 +439,7 @@ namespace snmalloc
|
||||
alloc_classes[sizeclass].length++;
|
||||
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Slab is woken up" << std::endl;
|
||||
message<1024>("Slab is woken up");
|
||||
#endif
|
||||
|
||||
ticker.check_tick();
|
||||
@@ -483,7 +485,7 @@ namespace snmalloc
|
||||
auto cb = [this,
|
||||
&need_post](freelist::HeadPtr msg) SNMALLOC_FAST_PATH_LAMBDA {
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Handling remote" << std::endl;
|
||||
message<1024>("Handling remote");
|
||||
#endif
|
||||
|
||||
auto& entry =
|
||||
@@ -562,7 +564,7 @@ namespace snmalloc
|
||||
void init()
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Making an allocator." << std::endl;
|
||||
message<1024>("Making an allocator.");
|
||||
#endif
|
||||
// Entropy must be first, so that all data-structures can use the key
|
||||
// it generates.
|
||||
@@ -776,8 +778,7 @@ namespace snmalloc
|
||||
size_t slab_size = sizeclass_to_slab_size(sizeclass);
|
||||
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "rsize " << rsize << std::endl;
|
||||
std::cout << "slab size " << slab_size << std::endl;
|
||||
message<1024>("small_alloc_slow rsize={} slab size={}", rsize, slab_size);
|
||||
#endif
|
||||
|
||||
auto [slab, meta] = SharedStateHandle::alloc_chunk(
|
||||
@@ -872,7 +873,7 @@ namespace snmalloc
|
||||
void attach(LocalCache* c)
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Attach cache to " << this << std::endl;
|
||||
message<1024>("Attach cache to {}", this);
|
||||
#endif
|
||||
attached_cache = c;
|
||||
|
||||
@@ -916,7 +917,7 @@ namespace snmalloc
|
||||
init_message_queue();
|
||||
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "debug_is_empty - done" << std::endl;
|
||||
message<1024>("debug_is_empty - done");
|
||||
#endif
|
||||
return sent_something;
|
||||
}
|
||||
@@ -934,7 +935,7 @@ namespace snmalloc
|
||||
bool debug_is_empty(bool* result)
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "debug_is_empty" << std::endl;
|
||||
message<1024>("debug_is_empty");
|
||||
#endif
|
||||
if (attached_cache == nullptr)
|
||||
{
|
||||
@@ -943,7 +944,7 @@ namespace snmalloc
|
||||
LocalCache temp(public_state());
|
||||
attach(&temp);
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "debug_is_empty - attach a cache" << std::endl;
|
||||
message<1024>("debug_is_empty - attach a cache");
|
||||
#endif
|
||||
auto sent_something = debug_is_empty_impl(result);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace snmalloc
|
||||
auto* alloc = AllocPool<SharedStateHandle>::iterate();
|
||||
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "debug check empty: first " << alloc << std::endl;
|
||||
message<1024>("debug check empty: first {}", alloc);
|
||||
# endif
|
||||
bool done = false;
|
||||
bool okay = true;
|
||||
@@ -102,7 +102,7 @@ namespace snmalloc
|
||||
while (!done)
|
||||
{
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "debug_check_empty: Check all allocators!" << std::endl;
|
||||
message<1024>("debug_check_empty: Check all allocators!");
|
||||
# endif
|
||||
done = true;
|
||||
alloc = AllocPool<SharedStateHandle>::iterate();
|
||||
@@ -111,7 +111,7 @@ namespace snmalloc
|
||||
while (alloc != nullptr)
|
||||
{
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "debug check empty: " << alloc << std::endl;
|
||||
message<1024>("debug check empty: {}", alloc);
|
||||
# endif
|
||||
// Check that the allocator has freed all memory.
|
||||
// repeat the loop if empty caused message sends.
|
||||
@@ -119,13 +119,12 @@ namespace snmalloc
|
||||
{
|
||||
done = false;
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "debug check empty: sent messages " << alloc
|
||||
<< std::endl;
|
||||
message<1024>("debug check empty: sent messages {}", alloc);
|
||||
# endif
|
||||
}
|
||||
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "debug check empty: okay = " << okay << std::endl;
|
||||
message<1024>("debug check empty: okay = {}", okay);
|
||||
# endif
|
||||
alloc = AllocPool<SharedStateHandle>::iterate(alloc);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace snmalloc
|
||||
if (post_teardown)
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "post_teardown flush()" << std::endl;
|
||||
message<1024>("post_teardown flush()");
|
||||
#endif
|
||||
// We didn't have an allocator because the thread is being torndown.
|
||||
// We need to return any local state, so we don't leak it.
|
||||
@@ -188,8 +188,7 @@ namespace snmalloc
|
||||
// set up meta data so sizeclass is correct, and hence alloc size, and
|
||||
// external pointer.
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "size " << size << " pow2 size "
|
||||
<< bits::next_pow2_bits(size) << std::endl;
|
||||
message<1024>("size {} pow2size {}", size, bits::next_pow2_bits(size));
|
||||
#endif
|
||||
|
||||
// Initialise meta data for a successful large allocation.
|
||||
@@ -263,8 +262,10 @@ namespace snmalloc
|
||||
if (core_alloc != nullptr)
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Remote dealloc post" << p.unsafe_ptr() << " size "
|
||||
<< alloc_size(p.unsafe_ptr()) << std::endl;
|
||||
message<1024>(
|
||||
"Remote dealloc post {} ({})",
|
||||
p.unsafe_ptr(),
|
||||
alloc_size(p.unsafe_ptr()));
|
||||
#endif
|
||||
const MetaslabMetaEntry& entry =
|
||||
SharedStateHandle::Pagemap::template get_metaentry<MetaslabMetaEntry>(
|
||||
@@ -364,8 +365,7 @@ namespace snmalloc
|
||||
c->attach(&local_cache);
|
||||
core_alloc = c;
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "init(): core_alloc=" << core_alloc << "@" << &local_cache
|
||||
<< std::endl;
|
||||
message<1024>("init(): core_alloc={} @ {}", core_alloc, &local_cache);
|
||||
#endif
|
||||
// local_cache.stats.sta rt();
|
||||
}
|
||||
@@ -407,7 +407,7 @@ namespace snmalloc
|
||||
// it is new to hit slow paths.
|
||||
core_alloc = nullptr;
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "flush(): core_alloc=" << core_alloc << std::endl;
|
||||
message<1024>("flush(): core_alloc={}", core_alloc);
|
||||
#endif
|
||||
local_cache.remote_allocator = &SharedStateHandle::unused_remote;
|
||||
local_cache.remote_dealloc_cache.capacity = 0;
|
||||
@@ -651,8 +651,8 @@ namespace snmalloc
|
||||
local_cache.remote_dealloc_cache.template dealloc<sizeof(CoreAlloc)>(
|
||||
entry.get_remote()->trunc_id(), p_tame, key_global);
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "Remote dealloc fast" << p_raw << " size "
|
||||
<< alloc_size(p_raw) << std::endl;
|
||||
message<1024>(
|
||||
"Remote dealloc fast {} ({})", p_raw, alloc_size(p_raw));
|
||||
# endif
|
||||
return;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ namespace snmalloc
|
||||
snmalloc_check_client(p_tame == nullptr, "Not allocated by snmalloc.");
|
||||
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "nullptr deallocation" << std::endl;
|
||||
message<1024>("nullptr deallocation");
|
||||
# endif
|
||||
return;
|
||||
#endif
|
||||
@@ -689,8 +689,7 @@ namespace snmalloc
|
||||
void teardown()
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Teardown: core_alloc=" << core_alloc << "@" << &local_cache
|
||||
<< std::endl;
|
||||
message<1024>("Teardown: core_alloc={} @ {}", core_alloc, &local_cache);
|
||||
#endif
|
||||
post_teardown = true;
|
||||
if (core_alloc != nullptr)
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace snmalloc
|
||||
static char p_teardown_val = 1;
|
||||
pthread_setspecific(p_key.get(), &p_teardown_val);
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "Using pthread clean up" << std::endl;
|
||||
message<1024>("Using pthread clean up");
|
||||
# endif
|
||||
}
|
||||
# elif defined(SNMALLOC_USE_CXX_THREAD_DESTRUCTORS)
|
||||
@@ -157,7 +157,7 @@ namespace snmalloc
|
||||
[]() { ThreadAlloc::get().teardown(); });
|
||||
UNUSED(dummy);
|
||||
# ifdef SNMALLOC_TRACING
|
||||
std::cout << "Using C++ destructor clean up" << std::endl;
|
||||
message<1024>("Using C++ destructor clean up");
|
||||
# endif
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -336,8 +336,7 @@ namespace snmalloc
|
||||
if (p != MAP_FAILED)
|
||||
{
|
||||
#ifdef SNMALLOC_TRACING
|
||||
std::cout << "Pal_posix reserved: " << p << " (" << size << ")"
|
||||
<< std::endl;
|
||||
snmalloc::message<1024>("Pal_posix reserved: {} ({})", p, size);
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user