From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
xiaoguangrong@cn.fujitsu.com
Subject: Re: [RFC PATCH 0/3] Weight-balanced binary tree + KVM growable memory slots using wbtree
Date: Wed, 02 Mar 2011 15:34:52 +0200 [thread overview]
Message-ID: <4D6E477C.7050303@redhat.com> (raw)
In-Reply-To: <20110301194703.GA7736@amt.cnet>
On 03/01/2011 09:47 PM, Marcelo Tosatti wrote:
> On Sun, Feb 27, 2011 at 11:54:29AM +0200, Avi Kivity wrote:
> > On 02/24/2011 07:35 PM, Alex Williamson wrote:
> > >On Thu, 2011-02-24 at 12:06 +0200, Avi Kivity wrote:
> > >> On 02/23/2011 09:28 PM, Alex Williamson wrote:
> > >> > I had forgotten about<1M mem, so actually the slot configuration was:
> > >> >
> > >> > 0:<1M
> > >> > 1: 1M - 3.5G
> > >> > 2: 4G+
> > >> >
> > >> > I stacked the deck in favor of the static array (0: 4G+, 1: 1M-3.5G, 2:
> > >> > <1M), and got these kernbench results:
> > >> >
> > >> > base (stdev) reorder (stdev) wbtree (stdev)
> > >> > --------+-----------------+----------------+----------------+
> > >> > Elapsed | 42.809 (0.19) | 42.160 (0.22) | 42.305 (0.23) |
> > >> > User | 115.709 (0.22) | 114.358 (0.40) | 114.720 (0.31) |
> > >> > System | 41.605 (0.14) | 40.741 (0.22) | 40.924 (0.20) |
> > >> > %cpu | 366.9 (1.45) | 367.4 (1.17) | 367.6 (1.51) |
> > >> > context | 7272.3 (68.6) | 7248.1 (89.7) | 7249.5 (97.8) |
> > >> > sleeps | 14826.2 (110.6) | 14780.7 (86.9) | 14798.5 (63.0) |
> > >> >
> > >> > So, wbtree is only slightly behind reordering, and the standard
> > >> > deviation suggests the runs are mostly within the noise of each other.
> > >> > Thanks,
> > >>
> > >> Doesn't this indicate we should use reordering, instead of a new data
> > >> structure?
> > >
> > >The original problem that brought this on was scaling. The re-ordered
> > >array still has O(N) scaling while the tree should have ~O(logN) (note
> > >that it currently doesn't because it needs a compaction algorithm added
> > >after insert and remove). So yes, it's hard to beat the results of a
> > >test that hammers on the first couple entries of a sorted array, but I
> > >think the tree has better than current performance and more predictable
> > >when scaled performance.
> >
> > Scaling doesn't matter, only actual performance. Even a guest with
> > 512 slots would still hammer only on the first few slots, since
> > these will contain the bulk of memory.
> >
> > >If we knew when we were searching for which type of data, it would
> > >perhaps be nice if we could use a sorted array for guest memory (since
> > >it's nicely bounded into a small number of large chunks), and a tree for
> > >mmio (where we expect the scaling to be a factor). Thanks,
> >
> > We have three types of memory:
> >
> > - RAM - a few large slots
> > - mapped mmio (for device assignment) - possible many small slots
> > - non-mapped mmio (for emulated devices) - no slots
> >
> > The first two are handled in exactly the same way - they're just
> > memory slots. We expect a lot more hits into the RAM slots, since
> > they're much bigger. But by far the majority of faults will be for
> > the third category - mapped memory will be hit once per page, then
> > handled by hardware until Linux memory management does something
> > about the page, which should hopefully be rare (with device
> > assignment, rare == never, since those pages are pinned).
> >
> > Therefore our optimization priorities should be
> > - complete miss into the slot list
> > - hit into the RAM slots
> > - hit into the other slots (trailing far behind)
>
> Whatever ordering considered optimal in one workload can be suboptimal
> in another. The binary search reduces the number of slots inspected
> in the average case. Using slot size as weight favours probability.
It's really difficult to come up with a workload that causes many hits
to small slots.
> > Of course worst-case performance matters. For example, we might
> > (not sure) be searching the list with the mmu spinlock held.
> >
> > I think we still have a bit to go before we can justify the new data
> > structure.
>
> Intensive IDE disk IO on guest with lots of assigned network devices, 3%
> improvement on netperf with rtl8139, 1% improvement on kernbench?
>
> Fail to see justification for not using it.
By itself it's great, but the miss cache will cause the code to be
called very rarely. So I prefer the sorted array which is simpler (and
faster for the few-large-slots case).
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-03-02 13:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-22 8:08 [PATCH 0/7] KVM: optimize memslots searching and cache GPN to GFN Xiao Guangrong
2011-02-22 8:09 ` [PATCH 1/7] KVM: cleanup memslot_id function Xiao Guangrong
2011-02-22 8:10 ` [PATCH 2/7] KVM: introduce KVM_MEM_SLOTS_NUM macro Xiao Guangrong
2011-02-22 8:11 ` [PATCH 1/3] KVM: introduce memslots_updated function Xiao Guangrong
2011-02-22 8:12 ` [PATCH 4/7] KVM: sort memslots and use binary search to search the right slot Xiao Guangrong
2011-02-22 14:25 ` Avi Kivity
2011-02-22 14:54 ` Alex Williamson
2011-02-22 18:54 ` [RFC PATCH 0/3] Weight-balanced binary tree + KVM growable memory slots using wbtree Alex Williamson
2011-02-22 18:55 ` [RFC PATCH 1/3] Weight-balanced tree Alex Williamson
2011-02-23 13:09 ` Avi Kivity
2011-02-23 17:02 ` Alex Williamson
2011-02-23 17:08 ` Avi Kivity
2011-02-23 20:19 ` Alex Williamson
2011-02-24 23:04 ` Andrew Morton
2011-02-22 18:55 ` [RFC PATCH 2/3] kvm: Allow memory slot array to grow on demand Alex Williamson
2011-02-24 10:39 ` Avi Kivity
2011-02-24 18:08 ` Alex Williamson
2011-02-27 9:44 ` Avi Kivity
2011-02-22 18:55 ` [RFC PATCH 3/3] kvm: Use weight-balanced tree for memory slot management Alex Williamson
2011-02-22 18:59 ` [RFC PATCH 0/3] Weight-balanced binary tree + KVM growable memory slots using wbtree Alex Williamson
2011-02-23 1:56 ` Alex Williamson
2011-02-23 13:12 ` Avi Kivity
2011-02-23 18:06 ` Alex Williamson
2011-02-23 19:28 ` Alex Williamson
2011-02-24 10:06 ` Avi Kivity
2011-02-24 17:35 ` Alex Williamson
2011-02-27 9:54 ` Avi Kivity
2011-02-28 23:04 ` Alex Williamson
2011-03-01 15:03 ` Avi Kivity
2011-03-01 18:20 ` Alex Williamson
2011-03-02 13:31 ` Avi Kivity
2011-03-01 19:47 ` Marcelo Tosatti
2011-03-02 13:34 ` Avi Kivity [this message]
2011-02-24 10:04 ` Avi Kivity
2011-02-23 1:30 ` [PATCH 4/7] KVM: sort memslots and use binary search to search the right slot Xiao Guangrong
2011-02-22 8:13 ` [PATCH 5/7] KVM: cache the last used slot Xiao Guangrong
2011-02-22 14:26 ` Avi Kivity
2011-02-22 8:15 ` [PATCH 6/7] KVM: cleanup traversal used slots Xiao Guangrong
2011-02-22 8:16 ` [PATCH 7/7] KVM: MMU: cache guest page number to guest frame number Xiao Guangrong
2011-02-22 14:32 ` Avi Kivity
2011-02-23 1:38 ` Xiao Guangrong
2011-02-23 9:28 ` Avi Kivity
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=4D6E477C.7050303@redhat.com \
--to=avi@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=xiaoguangrong@cn.fujitsu.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).