[FFmpeg-devel] Copy-on-write pages statistics

Diego 'Flameeyes' Pettenò flameeyes
Sun Jan 13 02:49:46 CET 2008

So, since Mike asked me to see if I could write a script to make
automated (or semi-automated, I suppose) the detection for tables that
might be hardcoded, or need to be made constant, I've written a simple
script, still rough for now, to get copy-on-write statistics out of ELF
object files.

The script reads the object files given at the command line, and check
for the symbols that are present in .data.*, .data.rel.* and .bss
sections. You can call them variables, as the functions would be in
.text, and the constants in .rodata; .data.rel.ro would also contain
constants from a C standpoint, but they are de-facto variables because
of relocations.

To get the script (and the Ruby extension it uses to parse ELF files),
just clone my repository at git://flameeyes.is-a-geek.org/ruby-elf.git .
Yes it's in Ruby, sorry but I already had the ELF parser there, and it's
quite complete too, so I preferred using that even if it's probably
slower than doing the whole thing in C.

Note that this only works on ELF files, it's a limitation which is hard
to get rid of unless someone wants to reimplement the logic using C and
libbfd (from GNU binutils).

To use this, run cowstats.rb --statistics libavcodec/*.o (for
example). You might add the --total option to get some nice total sizes
for the various sections.

If you want to get details on a particular file, just run cowstats.rb
libavcodec/h263.o, and it will tell you which symbols fall into the
three considered categories. (and a bit of a nitpickery here, do you
think that --statistics should be the default while --detail should be
used for get detailed info?)

Tomorrow (if the fever allows me), I'll see to write an ar parser in
Ruby so that it can also check the object files inside static libraries
without having to manually extract them, it should be interesting.

I'm attaching the output of the run on my (partially patched) checkout
of libavcodec, the results aren't great, but in comparison libvorbis
(which is far from being as big as FFmpeg) has 54KB of writeable

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: libavcodec-cowstats.txt
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080113/e4576103/attachment.txt>
-------------- next part --------------

Diego "Flameeyes" Petten?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080113/e4576103/attachment.pgp>

More information about the ffmpeg-devel mailing list