mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 19:28:52 +02:00
ircd::allocator: Add argument for options string to info() interface.
This commit is contained in:
parent
f069cdfca0
commit
c7b473485b
4 changed files with 23 additions and 6 deletions
|
@ -40,7 +40,7 @@ namespace ircd::allocator
|
||||||
profile operator+(const profile &, const profile &);
|
profile operator+(const profile &, const profile &);
|
||||||
profile operator-(const profile &, const profile &);
|
profile operator-(const profile &, const profile &);
|
||||||
|
|
||||||
string_view info(const mutable_buffer &);
|
string_view info(const mutable_buffer &, const string_view &opts = {});
|
||||||
string_view get(const string_view &var, const mutable_buffer &val);
|
string_view get(const string_view &var, const mutable_buffer &val);
|
||||||
string_view set(const string_view &var, const string_view &val, const mutable_buffer &cur = {});
|
string_view set(const string_view &var, const string_view &val, const mutable_buffer &cur = {});
|
||||||
bool trim(const size_t &pad = 0) noexcept; // malloc_trim(3)
|
bool trim(const size_t &pad = 0) noexcept; // malloc_trim(3)
|
||||||
|
|
|
@ -34,7 +34,8 @@ namespace ircd::allocator
|
||||||
|
|
||||||
#ifdef IRCD_ALLOCATOR_USE_GNU
|
#ifdef IRCD_ALLOCATOR_USE_GNU
|
||||||
ircd::string_view
|
ircd::string_view
|
||||||
ircd::allocator::info(const mutable_buffer &buf)
|
ircd::allocator::info(const mutable_buffer &buf,
|
||||||
|
[[unused]] const string_view &opts)
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
pubsetbuf(out, buf);
|
pubsetbuf(out, buf);
|
||||||
|
|
|
@ -125,7 +125,8 @@ catch(const std::bad_function_call &)
|
||||||
|
|
||||||
#if defined(IRCD_ALLOCATOR_JEMALLOC)
|
#if defined(IRCD_ALLOCATOR_JEMALLOC)
|
||||||
ircd::string_view
|
ircd::string_view
|
||||||
ircd::allocator::info(const mutable_buffer &buf)
|
ircd::allocator::info(const mutable_buffer &buf,
|
||||||
|
const string_view &opts_)
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
pubsetbuf(out, buf);
|
pubsetbuf(out, buf);
|
||||||
|
@ -136,9 +137,12 @@ ircd::allocator::info(const mutable_buffer &buf)
|
||||||
out << msg;
|
out << msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const &opts
|
thread_local char opts_buf[64];
|
||||||
|
const char *const opts
|
||||||
{
|
{
|
||||||
""
|
opts_?
|
||||||
|
data(strlcpy(opts_buf, opts_)):
|
||||||
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
malloc_stats_print(je::stats_handler, &out, opts);
|
malloc_stats_print(je::stats_handler, &out, opts);
|
||||||
|
|
|
@ -1028,6 +1028,18 @@ console_cmd__proc__smaps(opt &out, const string_view &line)
|
||||||
bool
|
bool
|
||||||
console_cmd__mem(opt &out, const string_view &line)
|
console_cmd__mem(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"opts"
|
||||||
|
}};
|
||||||
|
|
||||||
|
// Optional options string passed to implementation; might not be available
|
||||||
|
// or ignored. See jemalloc(3) etc.
|
||||||
|
const string_view &opts
|
||||||
|
{
|
||||||
|
param["opts"]
|
||||||
|
};
|
||||||
|
|
||||||
auto &this_thread
|
auto &this_thread
|
||||||
{
|
{
|
||||||
ircd::allocator::profile::this_thread
|
ircd::allocator::profile::this_thread
|
||||||
|
@ -1043,7 +1055,7 @@ console_cmd__mem(opt &out, const string_view &line)
|
||||||
|
|
||||||
thread_local char buf[48_KiB];
|
thread_local char buf[48_KiB];
|
||||||
out << "Allocator information:" << std::endl
|
out << "Allocator information:" << std::endl
|
||||||
<< allocator::info(buf) << std::endl
|
<< allocator::info(buf, opts) << std::endl
|
||||||
;
|
;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue