From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: kwolf@redhat.com, qemu-block@nongnu.org, mtosatti@redhat.com,
qemu-devel@nongnu.org, hreitz@redhat.com, pbonzini@redhat.com,
Nicolas Saenz Julienne <nsaenzju@redhat.com>
Subject: Re: [RFC] thread-pool: Add option to fix the pool size
Date: Thu, 3 Feb 2022 10:56:49 +0000 [thread overview]
Message-ID: <Yfu08bAJKnRC3eFD@redhat.com> (raw)
In-Reply-To: <Yfu0E5LwZ/x0EZrl@stefanha-x1.localdomain>
On Thu, Feb 03, 2022 at 10:53:07AM +0000, Stefan Hajnoczi wrote:
> On Wed, Feb 02, 2022 at 06:52:34PM +0100, Nicolas Saenz Julienne wrote:
> > The thread pool regulates itself: when idle, it kills threads until
> > empty, when in demand, it creates new threads until full. This behaviour
> > doesn't play well with latency sensitive workloads where the price of
> > creating a new thread is too high. For example, when paired with qemu's
> > '-mlock', or using safety features like SafeStack, creating a new thread
> > has been measured take multiple milliseconds.
> >
> > In order to mitigate this let's introduce a new option to set a fixed
> > pool size. The threads will be created during the pool's initialization,
> > remain available during its lifetime regardless of demand, and destroyed
> > upon freeing it. A properly characterized workload will then be able to
> > configure the pool to avoid any latency spike.
> >
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
> >
> > ---
> >
> > The fix I propose here works for my specific use-case, but I'm pretty
> > sure it'll need to be a bit more versatile to accommodate other
> > use-cases.
> >
> > Some questions:
> >
> > - Is unanimously setting these parameters for any pool instance too
> > limiting? It'd make sense to move the options into the AioContext the
> > pool belongs to. IIUC, for the general block use-case, this would be
> > 'qemu_aio_context' as initialized in qemu_init_main_loop().
>
> Yes, qemu_aio_context is the main loop's AioContext. It's used unless
> IOThreads are configured.
>
> It's nice to have global settings that affect all AioContexts, so I
> think this patch is fine for now.
>
> In the future IOThread-specific parameters could be added if individual
> IOThread AioContexts need tuning (similar to how poll-max-ns works
> today).
>
> > - Currently I'm setting two pool properties through a single qemu
> > option. The pool's size and dynamic behaviour, or lack thereof. I
> > think it'd be better to split them into separate options. I thought of
> > different ways of expressing this (min/max-size where static happens
> > when min-size=max-size, size and static/dynamic, etc..), but you might
> > have ideas on what could be useful to other use-cases.
>
> Yes, "min" and "max" is more flexible than fixed-size=n. fixed-size=n is
> equivalent to min=n,max=n. The current default policy is min=0,max=64.
> If you want more threads you could do min=0,max=128. If you want to
> reserve 1 thread all the time use min=1,max=64.
>
> I would go with min and max.
This commit also exposes this as a new top level command line
argument. Given our aim to eliminate QemuOpts and use QAPI/QOM
properties for everything I think we need a different approach.
I'm not sure which exisiting QAPI/QOM option it most appropriate
to graft these tunables onto ? -machine ? -accel ? Or is there
no good fit yet ?
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2022-02-03 10:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-02 17:52 [RFC] thread-pool: Add option to fix the pool size Nicolas Saenz Julienne
2022-02-03 10:53 ` Stefan Hajnoczi
2022-02-03 10:56 ` Daniel P. Berrangé [this message]
2022-02-03 14:19 ` Stefan Hajnoczi
2022-02-11 9:30 ` Nicolas Saenz Julienne
2022-02-11 11:32 ` Kevin Wolf
2022-02-14 10:09 ` Stefan Hajnoczi
2022-02-14 11:38 ` Kevin Wolf
2022-02-14 13:10 ` Stefan Hajnoczi
2022-02-14 14:09 ` Kevin Wolf
2022-02-07 12:00 ` Nicolas Saenz Julienne
2022-02-07 15:20 ` Stefan Hajnoczi
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=Yfu08bAJKnRC3eFD@redhat.com \
--to=berrange@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mtosatti@redhat.com \
--cc=nsaenzju@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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;
as well as URLs for NNTP newsgroup(s).