Skip to contentSkip to conversation

Basic block statistics

Qemu-devel Johan Rydberg 2 participants 3 messages Nov 11, 2003

lore
Share & tools
lore
#0 lore raw

Hi,

I hacked QEMU to dump some statistics regarding the length of the basic blocks with respect of their length. I booted the Debian image suppblied by Leigh Dyer til the login prompt.

It seems that the avg basic block length is ~ 5 insns. This seems as a reasonable number for C code.

What is a bit supprising to me is that only ~ 0.3 % of these blocks has internal loops (the CTI insn at the end has the first insn in the BB as target). If you treat basic blocks that has just includes a single insn with a rep/repz prefix, the amount of basic blocks that contain loops increases to ~ 2.38 %.

I have yet not figured out a way to alter QEMU to see how much of the execution time these blocks consume. Say that the ~2.38% of the blocks consume 10% of the time, it might be worth doing extra optmizations on then. Fabrice, do you know how I could hack QEMU to get this kind of information?

Signature · 2 lines
Johan Rydberg, Free Software Developer, Sweden
http://rtmk.sf.net | http://www.nongnu.org/guss/
#1 lore raw

Johan Rydberg <[email protected]> wrote: (Yes, I did)

: I have yet not figured out a way to alter QEMU to see how much of : the execution time these blocks consume. Say that the ~2.38% of : the blocks consume 10% of the time, it might be worth doing extra : optmizations on then. Fabrice, do you know how I could hack QEMU : to get this kind of information?

I disabled chaining and counted each invoking of basic blocks, and maintained a separate counter for those blocks that contain internal loops. Booting the Debian image to the login prompt gave that the blocks with internal loops stod for 33.7% of all invoked blocks. Can anyone verify this? (by hacking QEMU yourself, both verifying the numbers and that I collect the statistics correctly) It should not take more than 20 minutes all together.

Assume that the values are correct. Then optimization of the blocks that contain loops could result in a rather huge performance boost. You could for example try to move register stores and loads out of the it and just work with host registers in the actual loop.

Signature · 2 lines
Johan Rydberg, Free Software Developer, Sweden
http://rtmk.sf.net | http://www.nongnu.org/guss/
#2 lore raw
Quoted 8 lines · Johan Rydberg

Johan Rydberg <[email protected]> wrote: (Yes, I did)

: I have yet not figured out a way to alter QEMU to see how much of : the execution time these blocks consume. Say that the ~2.38% of : the blocks consume 10% of the time, it might be worth doing extra : optmizations on then. Fabrice, do you know how I could hack QEMU : to get this kind of information?

Quoted 7 lines

I disabled chaining and counted each invoking of basic blocks, and maintained a separate counter for those blocks that contain internal loops. Booting the Debian image to the login prompt gave that the blocks with internal loops stod for 33.7% of all invoked blocks. Can anyone verify this? (by hacking QEMU yourself, both verifying the numbers and that I collect the statistics correctly) It should not take more than 20 minutes all together.

I would have done about the same to get the stats :-) I read that wabi was able to optimize these kind of loops, so I guess it is really interesting.

Quoted 4 lines

Assume that the values are correct. Then optimization of the blocks that contain loops could result in a rather huge performance boost. You could for example try to move register stores and loads out of the it and just work with host registers in the actual loop.

I don't have time yet to optimize QEMU, but I'll think about that. Of course if someone does the patch I will accept it !

Fabrice.