Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-18 Thread Dmitry Konishchev
On Wed, May 18, 2011 at 1:40 PM, Peter Maydell wrote: > You could assert() this: >  assert(argc % (4 * sizeof(long)) == 0); Yeah, but actually I'm not really like the idea to include asserts in the little bottleneck functions if the configuration script doesn't include -DNDEBUG in the compiler cf

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-18 Thread Dmitry Konishchev
On 18.05.2011 13:31, Kevin Wolf wrote: Please move the declarations to the start of the function. I also would use a single line like "long d0, d1, d2, d3;", but that's up to you. + +for(i = 0; i< len; i += 4) { +d0 = ((const long*) sector)[i + 0]; +d1 = ((const long*) sec

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-18 Thread Peter Maydell
On 18 May 2011 10:40, Peter Maydell wrote: > On 18 May 2011 10:18, Dmitry Konishchev wrote: > >> + * Attention! The len must be a multiple of 4 * sizeof(long) due to >> + * restriction of optimizations in this function. > > You could assert() this: >  assert(argc % (4 * sizeof(long)) == 0); s/le

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-18 Thread Peter Maydell
On 18 May 2011 10:18, Dmitry Konishchev wrote: > + * Attention! The len must be a multiple of 4 * sizeof(long) due to > + * restriction of optimizations in this function. You could assert() this: assert(argc % (4 * sizeof(long)) == 0); -- PMM

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-18 Thread Kevin Wolf
Am 18.05.2011 11:18, schrieb Dmitry Konishchev: > On 18.05.2011 11:57, Stefan Hajnoczi wrote: >> Yes, optimizing is_not_zero() is good. The only additional thing I >> suggest is adding a comment before the function to document the length >> constraint. > > OK, fixed. > > > On 18.05.2011 12:05,

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-18 Thread Dmitry Konishchev
On 18.05.2011 11:57, Stefan Hajnoczi wrote: Yes, optimizing is_not_zero() is good. The only additional thing I suggest is adding a comment before the function to document the length constraint. OK, fixed. On 18.05.2011 12:05, Kevin Wolf wrote: A future bdrv_is_allocated() patch must make su

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-18 Thread Kevin Wolf
Am 18.05.2011 09:57, schrieb Stefan Hajnoczi: > On Wed, May 18, 2011 at 7:55 AM, Dmitry Konishchev > wrote: >> So, if you are agreed with the said above, you can accept this patch >> and then I'll write an enchancement for it with bdrv_is_allocated() >> because it is going to include this patch.

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-18 Thread Stefan Hajnoczi
On Wed, May 18, 2011 at 7:55 AM, Dmitry Konishchev wrote: > So, if you are agreed with the said above, you can accept this patch > and then I'll write an enchancement for it with bdrv_is_allocated() > because it is going to include this patch. Yes, optimizing is_not_zero() is good. The only addi

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-17 Thread Dmitry Konishchev
On Tue, May 17, 2011 at 7:35 PM, Stefan Hajnoczi wrote: > Please see http://wiki.qemu.org/Contribute/SubmitAPatch, which asks > that patches are sent inline (not as attachments) for easy review and > that you follow the coding style (see the CODING_STYLE file).  Patches > also need a Signed-off-by

Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-17 Thread Stefan Hajnoczi
On Tue, May 17, 2011 at 3:33 PM, Dmitry Konishchev wrote: > Hi! I was wondering why qemu-img consumes so much CPU when it converts > one partially allocated qcow2 image to another qcow2 image and I've > written a patch which improves the situation a little. Please see http://wiki.qemu.org/Contrib

[Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization

2011-05-17 Thread Dmitry Konishchev
Hi! I was wondering why qemu-img consumes so much CPU when it converts one partially allocated qcow2 image to another qcow2 image and I've written a patch which improves the situation a little. I have an image: > $ qemu-img info ubuntu.10.04.qcow2 > image: ubuntu.10.04.qcow2 > file format: qcow2 >