From: Juan Quintela <quintela@redhat.com>
To: Scott Cheloha <cheloha@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, "Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH] migration: savevm_state_insert_handler: constant-time element insertion
Date: Thu, 17 Oct 2019 10:43:08 +0200 [thread overview]
Message-ID: <87lftjpxsz.fsf@trasno.org> (raw)
In-Reply-To: <20191016164156.4506-1-cheloha@linux.vnet.ibm.com> (Scott Cheloha's message of "Wed, 16 Oct 2019 11:41:56 -0500")
Scott Cheloha <cheloha@linux.vnet.ibm.com> wrote:
Hi
> Registering a SaveStateEntry object via savevm_state_insert_handler()
> is an O(n) operation because the list is a priority queue maintained by
> walking the list from head to tail to find a suitable insertion point.
>
> This adds considerable overhead for VMs with many such objects. For
> instance, ppc64 machines with large maxmem (8T+) spend ~10% or more of
> their CPU time in savevm_state_insert_handler() before attempting to
> boot a kernel.
Ouch ...
> If we track the head for each priority's subqueue we can insert new
> elements in constant time.
We are adding a subqueue by priority, right? (see later comments)
> This commit also introduces a new function,
> savevm_state_remove_handler(),
savevm_state_handler_remove()
search didn't find it O:-)
> which abstracts the logic for replacing the head of an element's subqueue
> when removing it.
I think that it is better if you split the new function creation. Make
commit easier to write O:-)
> static SaveState savevm_state = {
> .handlers = QTAILQ_HEAD_INITIALIZER(savevm_state.handlers),
> + .handler_pri_head = { [MIG_PRI_DEFAULT ... MIG_PRI_MAX] = NULL },
Why are you still maintaining the handlers QTAILQ? Once here will not
be easier to just change handlers field to be an array
handlers[MIG_PRI_MAX] field, and adjust callers?
Changes are only inside this file.
The code to maintain the subqueue inside the other queue is just as
complex as chaning all the callers. What do you think?
savevm_state_handler_insert() for instance becomes even easier, just a
QTALIQ_INSERT_TAIL() in the proper queue, right?
I agree with the idea of the patch. Especially when you told us how bad
the performance of the current code is.
Out of curiosity, how many objects are we talking about?
Later, Juan.
next prev parent reply other threads:[~2019-10-17 8:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 16:41 [PATCH] migration: savevm_state_insert_handler: constant-time element insertion Scott Cheloha
2019-10-17 8:43 ` Juan Quintela [this message]
2019-10-17 19:25 ` Scott Cheloha
2019-10-18 22:15 ` Juan Quintela
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=87lftjpxsz.fsf@trasno.org \
--to=quintela@redhat.com \
--cc=cheloha@linux.vnet.ibm.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.