Improve ioctx wait diagnostic message

parent 9ebed60c
......@@ -592,6 +592,8 @@ fellow_io_ring_size(const char *envvar)
struct fellow_fd_ioctx {
unsigned magic;
#define FELLOW_FD_IOCTX_MAGIC 0x3b19f0e1
unsigned waits;
vtim_mono waits_t0;
struct bitf bitf[1];
char _spc[bitf_sz1(FELLOW_NIOCTX) -
sizeof(struct bitf)];
......@@ -725,6 +727,8 @@ static void
fellow_fd_ioctx_get(struct fellow_fd *ffd, struct fellow_fd_ioctx_lease *fdil)
{
struct fellow_fd_ioctx *fdio;
unsigned waits = 0;
vtim_dur waits_d = -1; // flint
size_t f;
CHECK_OBJ_NOTNULL(ffd, FELLOW_FD_MAGIC);
......@@ -742,18 +746,34 @@ fellow_fd_ioctx_get(struct fellow_fd *ffd, struct fellow_fd_ioctx_lease *fdil)
/* this should never happen, but if it does,
* we do not want it to be fatal
*/
ffd->diag("WARN: ioctx wait\n");
if (fdio->waits > 0)
fdio->waits++;
else {
fdio->waits = 1;
fdio->waits_t0 = VTIM_mono();
}
AZ(pthread_cond_wait(&fdio->cond, &fdio->mtx));
f = bitf_ffs(fdio->bitf);
}
AN(f);
f--;
AN(bitf_clr(fdio->bitf, f));
if (fdio->waits > 0 &&
(waits_d = VTIM_mono() - fdio->waits_t0) > 1.0) {
waits = fdio->waits;
fdio->waits = 0;
fdio->waits_t0 = 0;
}
AZ(pthread_mutex_unlock(&fdio->mtx));
fdil->fdio = fdio;
fdil->ioctxp = &fdio->ioctx[f];
TAKEZN(fdil->ioctx, *fdil->ioctxp);
if (waits) {
ffd->diag("WARN: %u ioctx waits in %.2fs (%.2f/s)",
waits, waits_d, (double)waits / waits_d);
}
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment