Re: [PATCH] memory: batch allocate ioeventfds[] in address_space_update_ioeventfds()

2020-02-19 Thread Stefan Hajnoczi
On Wed, Feb 19, 2020 at 12:36:04PM +0100, Paolo Bonzini wrote: > On 18/02/20 19:22, Stefan Hajnoczi wrote: > > + * It is likely that the number of ioeventfds hasn't changed much, so > > use > > + * the previous size as the starting value. > > + */ > > +ioeventfd_max = as->ioeventfd

Re: [PATCH] memory: batch allocate ioeventfds[] in address_space_update_ioeventfds()

2020-02-19 Thread Paolo Bonzini
On 19/02/20 10:18, Stefan Hajnoczi wrote: >> ... do exponential increase here (max*=2) instead so still easy to >> converge? > I'm happy to tweak the policy. Let's see what Paolo thinks. I included Peter's suggestion in my own tweak. Thanks to both of you! Paolo

Re: [PATCH] memory: batch allocate ioeventfds[] in address_space_update_ioeventfds()

2020-02-19 Thread Paolo Bonzini
On 18/02/20 19:22, Stefan Hajnoczi wrote: > + * It is likely that the number of ioeventfds hasn't changed much, so use > + * the previous size as the starting value. > + */ > +ioeventfd_max = as->ioeventfd_nb; > +ioeventfds = g_new(MemoryRegionIoeventfd, ioeventfd_max); This wo

Re: [PATCH] memory: batch allocate ioeventfds[] in address_space_update_ioeventfds()

2020-02-19 Thread Stefan Hajnoczi
On Tue, Feb 18, 2020 at 9:50 PM Peter Xu wrote: > > On Tue, Feb 18, 2020 at 06:22:26PM +, Stefan Hajnoczi wrote: > > Reallocing the ioeventfds[] array each time an element is added is very > > expensive as the number of ioeventfds increases. Batch allocate instead > > to amortize the cost of

Re: [PATCH] memory: batch allocate ioeventfds[] in address_space_update_ioeventfds()

2020-02-18 Thread Peter Xu
On Tue, Feb 18, 2020 at 06:22:26PM +, Stefan Hajnoczi wrote: > Reallocing the ioeventfds[] array each time an element is added is very > expensive as the number of ioeventfds increases. Batch allocate instead > to amortize the cost of realloc. > > This patch reduces Linux guest boot times fro

[PATCH] memory: batch allocate ioeventfds[] in address_space_update_ioeventfds()

2020-02-18 Thread Stefan Hajnoczi
Reallocing the ioeventfds[] array each time an element is added is very expensive as the number of ioeventfds increases. Batch allocate instead to amortize the cost of realloc. This patch reduces Linux guest boot times from 362s to 140s when there are 2 virtio-blk devices with 1 virtqueue and 99