0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-28 14:58:20 +02:00

ircd::ios: Add tsc counters to hook state.

This commit is contained in:
Jason Volk 2019-03-26 22:03:48 -07:00
parent 28063823dd
commit 20d0ea70c2
3 changed files with 19 additions and 1 deletions

View file

@ -78,6 +78,8 @@ struct ircd::ios::descriptor
uint64_t alloc_bytes{0};
uint64_t frees {0};
uint64_t free_bytes{0};
uint64_t slice_total {0};
uint64_t slice_last {0};
descriptor(const string_view &name);
descriptor(descriptor &&) = delete;
@ -94,6 +96,7 @@ struct ircd::ios::handler
static bool fault(handler *const &);
ios::descriptor *descriptor;
uint64_t slice_start {0};
};
template<class function>

View file

@ -144,7 +144,17 @@ ircd::ios::handler::fault(handler *const &handler)
assert(handler && handler->descriptor);
auto &descriptor(*handler->descriptor);
++descriptor.faults;
return false;
bool ret(false);
// leave() isn't called if we return false so the tsc counter
// needs to be tied off here instead.
if(!ret)
{
descriptor.slice_last = rdtsc() - handler->slice_start;
descriptor.slice_total += descriptor.slice_last;
}
return ret;
}
void
@ -152,6 +162,8 @@ ircd::ios::handler::leave(handler *const &handler)
{
assert(handler && handler->descriptor);
auto &descriptor(*handler->descriptor);
descriptor.slice_last = rdtsc() - handler->slice_start;
descriptor.slice_total += descriptor.slice_last;
}
void
@ -160,6 +172,7 @@ ircd::ios::handler::enter(handler *const &handler)
assert(handler && handler->descriptor);
auto &descriptor(*handler->descriptor);
++descriptor.calls;
handler->slice_start = rdtsc();
}
void

View file

@ -811,6 +811,7 @@ console_cmd__ios(opt &out, const string_view &line)
<< " " << std::left << std::setw(48) << "NAME"
<< " " << std::right << std::setw(6) << "FAULTS"
<< " " << std::right << std::setw(10) << "CALLS"
<< " " << std::right << std::setw(15) << "CYCLES"
<< " " << std::right << std::setw(10) << "ALLOCS"
<< " " << std::right << std::setw(10) << "FREES"
<< " " << std::right << std::setw(26) << "ALLOCATED"
@ -827,6 +828,7 @@ console_cmd__ios(opt &out, const string_view &line)
<< " " << std::left << std::setw(48) << d.name
<< " " << std::right << std::setw(6) << d.faults
<< " " << std::right << std::setw(10) << d.calls
<< " " << std::right << std::setw(15) << d.slice_total
<< " " << std::right << std::setw(10) << d.allocs
<< " " << std::right << std::setw(10) << d.frees
<< " " << std::right << std::setw(26) << pretty(iec(d.alloc_bytes))