0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 07:23:53 +01:00

ircd::fs::aio: Integrate stats structure into ircd::stats system.

This commit is contained in:
Jason Volk 2020-12-17 17:22:28 -08:00
parent 3eb664bbe9
commit af59cc1378
4 changed files with 284 additions and 48 deletions

View file

@ -45,36 +45,43 @@ namespace ircd::fs::aio
///
struct ircd::fs::aio::stats
{
uint64_t requests {0}; ///< count of requests created
uint64_t complete {0}; ///< count of requests completed
uint64_t submits {0}; ///< count of io_submit calls
uint64_t chases {0}; ///< count of chase calls
uint64_t handles {0}; ///< count of event_fd callbacks
uint64_t events {0}; ///< count of events from io_getevents
uint64_t cancel {0}; ///< count of requests canceled
uint64_t errors {0}; ///< count of response errcodes
uint64_t reads {0}; ///< count of read complete
uint64_t writes {0}; ///< count of write complete
uint64_t stalls {0}; ///< count of io_submit's blocking.
using item = ircd::stats::item<uint64_t *>;
uint64_t bytes_requests {0}; ///< total bytes for requests created
uint64_t bytes_complete {0}; ///< total bytes for requests completed
uint64_t bytes_errors {0}; ///< total bytes for completed w/ errc
uint64_t bytes_cancel {0}; ///< total bytes for cancels
uint64_t bytes_read {0}; ///< total bytes for read completed
uint64_t bytes_write {0}; ///< total bytes for write completed
uint64_t value[32];
size_t items;
uint32_t cur_bytes_write {0}; ///< pending write bytes
uint16_t cur_reads {0}; ///< pending reads
uint16_t cur_writes {0}; ///< pending write
uint16_t cur_queued {0}; ///< nr of requests in userspace queue
uint16_t cur_submits {0}; ///< nr requests in flight with kernel
item requests; ///< count of requests created
item complete; ///< count of requests completed
item submits; ///< count of io_submit calls
item chases; ///< count of chase calls
item handles; ///< count of event_fd callbacks
item events; ///< count of events from io_getevents
item cancel; ///< count of requests canceled
item errors; ///< count of response errcodes
item reads; ///< count of read complete
item writes; ///< count of write complete
item stalls; ///< count of io_submit's blocking.
uint16_t max_requests {0}; ///< maximum observed pending requests
uint16_t max_reads {0}; ///< maximum observed pending reads
uint16_t max_writes {0}; ///< maximum observed pending write
uint16_t max_queued {0}; ///< maximum observed in queue.
uint16_t max_submits {0}; ///< maximum observed in flight.
item bytes_requests; ///< total bytes for requests created
item bytes_complete; ///< total bytes for requests completed
item bytes_errors; ///< total bytes for completed w/ errc
item bytes_cancel; ///< total bytes for cancels
item bytes_read; ///< total bytes for read completed
item bytes_write; ///< total bytes for write completed
item cur_bytes_write; ///< pending write bytes
item cur_reads; ///< pending reads
item cur_writes; ///< pending write
item cur_queued; ///< nr of requests in userspace queue
item cur_submits; ///< nr requests in flight with kernel
item max_requests; ///< maximum observed pending requests
item max_reads; ///< maximum observed pending reads
item max_writes; ///< maximum observed pending write
item max_queued; ///< maximum observed in queue.
item max_submits; ///< maximum observed in flight.
stats();
};
struct ircd::fs::aio::init

View file

@ -29,7 +29,6 @@ extern "C"
namespace ircd::fs::iou
{
struct init;
struct stats;
struct system;
struct request;
enum state :uint8_t;
@ -44,7 +43,7 @@ namespace ircd::fs::iou
extern conf::item<size_t> max_submit;
// runtime state
extern struct stats stats;
extern struct aio::stats &stats;
extern struct system *system;
// util
@ -88,13 +87,6 @@ enum ircd::fs::iou::state
_NUM
};
/// Reuse the same stats structure as fs::aio in fs::iou
struct ircd::fs::iou::stats
:aio::stats
{
using aio::stats::stats;
};
/// Internal use; this is simply declared here for when internal headers are
/// not available for this build so a weak no-op definition can be defined.
struct ircd::fs::iou::init

View file

@ -1673,6 +1673,206 @@ noexcept
}
#endif
//
// stats
//
ircd::fs::aio::stats::stats()
:value{0}
,items{0}
,requests
{
value + items++,
{
{ "name", "ircd.fs.aio.requests" },
}
}
,complete
{
value + items++,
{
{ "name", "ircd.fs.aio.complete" },
}
}
,submits
{
value + items++,
{
{ "name", "ircd.fs.aio.submits" },
}
}
,chases
{
value + items++,
{
{ "name", "ircd.fs.aio.chases" },
}
}
,handles
{
value + items++,
{
{ "name", "ircd.fs.aio.handles" },
}
}
,events
{
value + items++,
{
{ "name", "ircd.fs.aio.events" },
}
}
,cancel
{
value + items++,
{
{ "name", "ircd.fs.aio.cancel" },
}
}
,errors
{
value + items++,
{
{ "name", "ircd.fs.aio.errors" },
}
}
,reads
{
value + items++,
{
{ "name", "ircd.fs.aio.reads" },
}
}
,writes
{
value + items++,
{
{ "name", "ircd.fs.aio.writes" },
}
}
,stalls
{
value + items++,
{
{ "name", "ircd.fs.aio.stalls" },
}
}
,bytes_requests
{
value + items++,
{
{ "name", "ircd.fs.aio.bytes.requests" },
}
}
,bytes_complete
{
value + items++,
{
{ "name", "ircd.fs.aio.bytes.complete" },
}
}
,bytes_errors
{
value + items++,
{
{ "name", "ircd.fs.aio.bytes.errors" },
}
}
,bytes_cancel
{
value + items++,
{
{ "name", "ircd.fs.aio.bytes.cancel" },
}
}
,bytes_read
{
value + items++,
{
{ "name", "ircd.fs.aio.bytes.read" },
}
}
,bytes_write
{
value + items++,
{
{ "name", "ircd.fs.aio.bytes.write" },
}
}
,cur_bytes_write
{
value + items++,
{
{ "name", "ircd.fs.aio.cur.bytes.write" },
}
}
,cur_reads
{
value + items++,
{
{ "name", "ircd.fs.aio.cur.reads" },
}
}
,cur_writes
{
value + items++,
{
{ "name", "ircd.fs.aio.cur.writes" },
}
}
,cur_queued
{
value + items++,
{
{ "name", "ircd.fs.aio.cur.queued" },
}
}
,cur_submits
{
value + items++,
{
{ "name", "ircd.fs.aio.cur.submits" },
}
}
,max_requests
{
value + items++,
{
{ "name", "ircd.fs.aio.max.requests" },
}
}
,max_reads
{
value + items++,
{
{ "name", "ircd.fs.aio.max.reads" },
}
}
,max_writes
{
value + items++,
{
{ "name", "ircd.fs.aio.max.writes" },
}
}
,max_queued
{
value + items++,
{
{ "name", "ircd.fs.aio.max.queued" },
}
}
,max_submits
{
value + items++,
{
{ "name", "ircd.fs.aio.max.submits" },
}
}
{
assert(items <= (sizeof(value) / sizeof(value[0])));
}
///////////////////////////////////////////////////////////////////////////////
//
// fs/iou.h
@ -1700,7 +1900,10 @@ ircd::fs::iou::enable
/// Global stats structure
decltype(ircd::fs::iou::stats)
ircd::fs::iou::stats;
ircd::fs::iou::stats
{
fs::aio::stats
};
/// Non-null when iou is available for use
decltype(ircd::fs::iou::system)

View file

@ -233,8 +233,15 @@ ircd::fs::aio::read(const fd &fd,
waiter, fd, opts, bufs
};
const scope_count cur_reads{stats.cur_reads};
stats.max_reads = std::max(stats.max_reads, stats.cur_reads);
const scope_count cur_reads
{
static_cast<uint64_t &>(stats.cur_reads)
};
stats.max_reads = std::max
(
uint64_t(stats.max_reads), uint64_t(stats.cur_reads)
);
request.submit();
const size_t bytes
@ -287,8 +294,15 @@ ircd::fs::aio::read(const vector_view<read_op> &op)
}
// Update stats
const scope_count cur_reads{stats.cur_reads, ushort(num)};
stats.max_reads = std::max(stats.max_reads, stats.cur_reads);
const scope_count cur_reads
{
static_cast<uint64_t &>(stats.cur_reads), num
};
stats.max_reads = std::max
(
uint64_t(stats.max_reads), uint64_t(stats.cur_reads)
);
// Send requests
for(size_t i(0); i < num; ++i)
@ -375,8 +389,15 @@ ircd::fs::aio::write(const fd &fd,
};
// track current write count
const scope_count cur_writes{stats.cur_writes};
stats.max_writes = std::max(stats.max_writes, stats.cur_writes);
const scope_count cur_writes
{
static_cast<uint64_t &>(stats.cur_writes)
};
stats.max_writes = std::max
(
uint64_t(stats.max_writes), uint64_t(stats.cur_writes)
);
// track current write bytes count
stats.cur_bytes_write += req_bytes;
@ -503,8 +524,15 @@ ircd::fs::aio::request::submit()
stats.bytes_requests += submitted_bytes;
stats.requests++;
const uint16_t &curcnt(stats.requests - stats.complete);
stats.max_requests = std::max(stats.max_requests, curcnt);
const auto &curcnt
{
stats.requests - stats.complete
};
stats.max_requests = std::max
(
static_cast<uint64_t &>(stats.max_requests), curcnt
);
// Wait here until there's room to submit a request
system->dock.wait([]
@ -878,8 +906,11 @@ ircd::fs::aio::system::submit(request &request)
queue.at(qcount++) = static_cast<iocb *>(&request);
stats.cur_queued++;
stats.max_queued = std::max(stats.max_queued, stats.cur_queued);
assert(stats.cur_queued == qcount);
stats.max_queued = std::max
(
uint64_t(stats.max_queued), uint64_t(stats.cur_queued)
);
// Determine whether this request will trigger a flush of the queue
// and be submitted itself as well.
@ -984,10 +1015,13 @@ noexcept try
stats.submits += bool(submitted);
stats.cur_queued -= submitted;
stats.cur_submits += submitted;
stats.max_submits = std::max(stats.max_submits, stats.cur_submits);
stats.max_submits = std::max
(
uint64_t(stats.max_submits), uint64_t(stats.cur_submits)
);
assert(stats.cur_queued == qcount);
assert(stats.cur_submits == in_flight);
if(idle && submitted > 0 && !handle_set)
set_handle();