All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Daniel P. Berrange" <berrange@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>,
	qemu-devel@nongnu.org, Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v2 04/12] i386: Register feature bit properties as class properties
Date: Tue, 15 Dec 2020 10:01:18 -0500	[thread overview]
Message-ID: <20201215150118.GU1289986@habkost.net> (raw)
In-Reply-To: <87pn3b2m85.fsf@dusky.pond.sub.org>

On Tue, Dec 15, 2020 at 03:11:06PM +0100, Markus Armbruster wrote:
> Eduardo Habkost <ehabkost@redhat.com> writes:
> 
> > Class properties make QOM introspection simpler and easier, as
> > they don't require an object to be instantiated.
> >
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> 
> This is significantly more than just "simpler and easier".
> 
> The other day, I played with the QMP core to reduce its appetite for
> malloc.  I came up with patches that should approximately halve it, and
> felt quite pleased with myself.  I looked for a simple test to
> demonstrate the effect.  Something with plenty of output.  Hmm, why not
> query-cpu-definitions, it produces about 32KiB.  Instrument, instrument,
> run, ... whaaaat?!?
> 
> My patches save some 7000 allocations (670 KiB total), roughly matching
> my expectations.
> 
> Turns out this is a drop in the bucket: query-cpu-definitions still
> takes some 180,000 allocations (almost 12 MiB total).  They're hiding
> behind this line in qmp_query_cpu_definitions():
> 
>     g_slist_foreach(list, x86_cpu_definition_entry, &cpu_list);
> 
> The line takes more than a quarter second for me.
> 
> Hogging the main loop for a quarter second is not good.

Wow!

> 
> Eduardo's patch reduces run time to 0.02 seconds (40,000 allocations, 9
> MiB total).  It's a smaller pig now.

Thanks for investigating this!  I'll amend the commit message with:

  Also, the hundreds of instance properties were having an impact
  on QMP commands that create temporary CPU objects.  On my
  machine, run time of qmp_query_cpu_definitions() patch changed
  from ~200ms to ~16ms after applying this patch.

Numbers were obtained with:

 $ sudo perf probe -v -x ./qemu-system-x86_64 -a 'qmp_query_cpu_definitions%return' -a 'qmp_query_cpu_definitions'
 $ echo -e '{"execute": "qmp_capabilities"}\n{"execute": "query-cpu-definitions"}\n{"execute": "quit"}' | sudo perf trace -e 'probe_qemu:*' ./qemu-system-x86_64 -S -display none -qmp stdio > /dev/null

Before:

     0.000 qemu-system-x8/3103211 probe_qemu:qmp_query_cpu_definitions(__probe_ip: 94851767056275)
   204.072 qemu-system-x8/3103211 probe_qemu:qmp_query_cpu_definitions__return(__probe_func: 94851767056275, __probe_ret_ip: 94851768499362)

After:

     0.000 qemu-system-x8/3105969 probe_qemu:qmp_query_cpu_definitions(__probe_ip: 94554723186579)
    16.445 qemu-system-x8/3105969 probe_qemu:qmp_query_cpu_definitions__return(__probe_func: 94554723186579, __probe_ret_ip: 94554724629631)


-- 
Eduardo



  reply	other threads:[~2020-12-15 15:02 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 18:38 [PATCH v2 00/12] qom: Convert some properties to class properties Eduardo Habkost
2020-11-11 18:38 ` [PATCH v2 01/12] vexpress: Register "secure" as class property Eduardo Habkost
2020-11-11 19:59   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 02/12] vexpress-a15: Register "virtualization" " Eduardo Habkost
2020-11-11 19:59   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 03/12] tmp421: Register properties as class properties Eduardo Habkost
2020-11-11 19:59   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 04/12] i386: Register feature bit " Eduardo Habkost
2020-12-15 14:11   ` Markus Armbruster
2020-12-15 15:01     ` Eduardo Habkost [this message]
2020-12-16  5:35       ` Markus Armbruster
2020-11-11 18:38 ` [PATCH v2 05/12] arm/virt: Register most " Eduardo Habkost
2020-11-11 20:03   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 06/12] virt: Register "its" as class property Eduardo Habkost
2020-11-11 20:03   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 07/12] arm/cpu64: Register "aarch64" " Eduardo Habkost
2020-11-11 20:04   ` Peter Maydell
2020-11-11 18:38 ` [PATCH v2 08/12] can_host: Use class properties Eduardo Habkost
2020-11-11 23:02   ` Pavel Pisa
2020-11-11 18:38 ` [PATCH v2 09/12] colo: " Eduardo Habkost
2020-11-13  3:04   ` Zhang, Chen
2020-12-11 20:59     ` Eduardo Habkost
2020-11-11 18:38 ` [PATCH v2 10/12] netfilter: Reorder functions Eduardo Habkost
2020-11-11 18:38 ` [PATCH v2 11/12] netfilter: Use class properties Eduardo Habkost
2020-11-11 18:38 ` [PATCH v2 12/12] input: " Eduardo Habkost
2020-11-11 21:48   ` Eduardo Habkost
2020-12-11 21:00 ` [PATCH v2 00/12] qom: Convert some properties to " Eduardo Habkost

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=20201215150118.GU1289986@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.