mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Uzair Beg <uzairbeg11@gmail.com>
Cc: io-uring@vger.kernel.org, axboe@kernel.dk,
	asml.silence@gmail.com, lin2530632123@gmail.com,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 3/3] io_uring/rsrc: prefill the node cache when a file table is registered empty
Date: Fri, 25 Sep 2026 15:42:46 -0400	[thread overview]
Message-ID: <87cxu1yv61.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20260925163916.524653-1-uzairbeg11@gmail.com>

Uzair Beg <uzairbeg11@gmail.com> writes:

> Gabriel Krisman Bertazi <krisman@suse.de> writes:
>> Does it make
>> sense to pre-allocated up to 192KB in memory for short-lived
>> applications that might use only a couple of those nodes?
>
> As a default, I don't think it does. Would it be acceptable to drop the
> prefill and only let the node cache capacity follow the table size,
> capped?
>
> Nothing would be allocated up front beyond the pointer array,
> so registering a large table and using a few slots costs almost
> nothing, and nodes are only retained up to what the application
> actually had installed. That gives up the first fill result but keeps
> the churn case, and it needs neither the dedicated slab nor the bulk
> refill.
>
> I'll measure that variant and follow up with numbers before posting
> anything. If you would rather the node cache stay at a fixed size,
> that is useful to know too.

The problem with increasing the cache size is that we don't have (and
should not have) a reclaim mechanism for the cached nodes.  By
increasing the cache size arbitrarily for every ring in the system you
are now sitting on a much bigger pile of unreclaimable memory that most
applications are unlikely to need.  I think that would even be
worse as a general solution.

Beyond microbenchmarks, this would only be a "problem" for applications
with a working set that frequently recycles over 128 nodes at a time.
The question remains how well this microbenchmark replicates any
real-world scenarios.  And if 128 is not enough, what would be? To be
fair, this is true for all type of magazine-like caches we have in
io_uring. In addition, you install a fd because you want to do one or
more operations with it, diluting the update cost.  In this case, would
the cost of going to slab for a node update of a working set of >128 fds
be diluted by the other operations, and likely invisible?  If it is
really a problem, I guess I would be ok with the bulk refilling of the
128 nodes at a time when you have an empty cache missing, while keeping
the table the same size.

On another topic... it would be excellent if we could do bulk refill on the
shared slab without a separate a kmem_cache!

Thanks,

-- 
Gabriel Krisman Bertazi

      reply	other threads:[~2026-09-25 19:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  9:20 [RFC PATCH 0/3] io_uring/rsrc: reduce node allocation cost on sparse file table installs Uzair Beg
2026-09-14  9:20 ` [RFC PATCH 1/3] io_uring/rsrc: allocate io_rsrc_node from a dedicated kmem_cache Uzair Beg
2026-09-15 17:54   ` Gabriel Krisman Bertazi
2026-09-25 16:36     ` Uzair Beg
2026-09-14  9:20 ` [RFC PATCH 2/3] io_uring/rsrc: bulk refill the node cache on allocation miss Uzair Beg
2026-09-14  9:20 ` [RFC PATCH 3/3] io_uring/rsrc: prefill the node cache when a file table is registered empty Uzair Beg
2026-09-15 18:20   ` Gabriel Krisman Bertazi
2026-09-25 16:39     ` Uzair Beg
2026-09-25 19:42       ` Gabriel Krisman Bertazi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cxu1yv61.fsf@mailhost.krisman.be \
    --to=krisman@suse.de \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=lin2530632123@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=uzairbeg11@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®