Eric Blake <ebl...@redhat.com> writes:

> On 02/11/2018 03:36 AM, Markus Armbruster wrote:
>> In my "build everything" tree, a change to the types in
>> qapi-schema.json triggers a recompile of about 4800 out of 5100
>> objects.
>>
>> The previous commit split up qmp-commands.h, qmp-event.h, qmp-visit.h,
>> qapi-types.h.  Each of these headers still includes all its shards.
>> Reduce compile time by including just the shards we actually need.
>>
>> To illustrate the benefits: adding a type to qapi/migration.json now
>> recompiles some 2300 instead of 4800 objects.  The next commit will
>> improve it further.
>>
>> Signed-off-by: Markus Armbruster <arm...@redhat.com>
>> ---
>>   backends/cryptodev.c             |  1 -
>>   backends/hostmem.c               |  3 ++-
>
> How did you determine which shards to include where? Remove all
> shards, try compiling, and see what fails, then add back in the right
> includes? Or was it scripted somehow?  (Trying to figure out, in case
> I have to rebase this patch)

Remove the monolithic include, fix compilation failures in my
"everything" and my mingw configuration.  Additionally, verify headers
don't regress with an embarrassingly crude script (appended).

By "regress" I mean headers need more headers to be included first than
before.  Ideally, *no* headers need to be included first, but we aren't
there (yet?).

>> +++ b/block/crypto.c
>> @@ -24,9 +24,9 @@
>>   #include "sysemu/block-backend.h"
>>   #include "crypto/block.h"
>>   #include "qapi/opts-visitor.h"
>> +#include "qapi/qapi-visit-crypto.h"
>>   #include "qapi/qmp/qdict.h"
>>   #include "qapi/qobject-input-visitor.h"
>> -#include "qapi-visit.h"
>>   #include "qapi/error.h"
>
> Any rhyme or reason to the resulting include order that I should be
> looking for (we aren't alphabetical in general, but if your changes
> were trying to honor a particular pattern among the few affected
> lines, that's useful to know).

Sane headers can be include in any order.  Ours are almost sane, which
prevents me from wholesale sorting.  I still try to keep things locally
sorted.  Feel free not to bother :)

>> +++ b/scripts/qapi/commands.py
>
> The non-mechanical portion of the patch :)
>
>> @@ -241,6 +241,9 @@ class 
>> QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor):
>>         def _begin_module(self, name):
>>           self._visited_ret_types[self._genc] = set()
>> +        commands = self._module_basename('qapi-commands', name)
>> +        types = self._module_basename('qapi-types', name)
>> +        visit = self._module_basename('qapi-visit', name)
>>           self._genc.add(mcgen('''
>>   #include "qemu/osdep.h"
>>   #include "qemu-common.h"
>> @@ -251,18 +254,17 @@ class 
>> QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor):
>>   #include "qapi/qobject-input-visitor.h"
>>   #include "qapi/dealloc-visitor.h"
>>   #include "qapi/error.h"
>> -#include "%(prefix)sqapi-types.h"
>> -#include "%(prefix)sqapi-visit.h"
>> -#include "%(prefix)sqmp-commands.h"
>> +#include "%(visit)s.h"
>> +#include "%(commands)s.h"
>>     ''',
>> -                             prefix=self._prefix))
>> +                             commands=commands, visit=visit))
>>           self._genh.add(mcgen('''
>> -#include "%(prefix)sqapi-types.h"
>> +#include "%(types)s.h"
>>   #include "qapi/qmp/dispatch.h"
>>     ''',
>> -                             prefix=self._prefix))
>> +                             types=types))
>
> Makes sense.
>
> The compiler will catch anything we did wrong.
>
> Reviewed-by: Eric Blake <ebl...@redhat.com>

Thanks!


#!/bin/sh
git-log -1 --oneline | cat

make -C bld qapi-types.h

cat >t.c <<EOF
#include "qemu/osdep.h"
#ifdef H
#include H
#endif
EOF

x=
for d in target/*
do
    t=${d#target/}
    bt=`ls -d bld/$t*-softmmu 2>/dev/null | head -n 1`
    [ "$bt" ] || continue
    h=`git-ls-files include/hw/$t`
    x="$x|include/hw/$t"
    cd $bt
    for i in $h
    do
        echo "= $i ="
        gcc -I/home/armbru/work/qemu/tcg -I/home/armbru/work/qemu/tcg/$t 
-I/home/armbru/work/qemu/tcg/i386 -I/home/armbru/work/qemu/linux-headers 
-I/home/armbru/work/qemu/bld/linux-headers -I. -I/home/armbru/work/qemu 
-I/home/armbru/work/qemu/include -I/home/armbru/work/qemu -I. 
-I/usr/include/pixman-1   -DHAS_LIBSSH2_SFTP_FSYNC -fPIE -DPIE -m64 
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
-fno-strict-aliasing -fno-common  -Wendif-labels -Wmissing-include-dirs 
-Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self 
-Wignored-qualifiers -Wold-style-declaration -Wold-style-definition 
-Wtype-limits -fstack-protector-strong  -I/usr/include/p11-kit-1     
-I/usr/include/libpng16  -I/usr/include/spice-server -I/usr/include/cacard 
-I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/glib-2.0 
-I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/spice-1  
-I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4  
-I/usr/include/libusb-1.0    -I../linux-headers -I.. 
-I/home/armbru/work/qemu/$d -DNEED_CPU_H -I/home/armbru/work/qemu/include -MMD 
-MP -MT t.o -MF ./t.d -pthread -I/usr/include/glib-2.0 
-I/usr/lib64/glib-2.0/include  -g   -c -o t.o /home/armbru/work/qemu/t.c -H 
-DH='"'$i'"'
    done
    cd - >/dev/null
done

x=${x#|}
h=`git-ls-files include | egrep -v "$x"`
cd bld
for i in $h
do
    echo "= $i ="
    gcc -I/home/armbru/work/qemu/tcg -I/home/armbru/work/qemu/tcg/i386 
-I/home/armbru/work/qemu/linux-headers 
-I/home/armbru/work/qemu/bld/linux-headers -I. -I/home/armbru/work/qemu 
-I/home/armbru/work/qemu/include -I/home/armbru/work/qemu -I. 
-I/usr/include/pixman-1   -DHAS_LIBSSH2_SFTP_FSYNC -fPIE -DPIE -m64 
-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
-fno-strict-aliasing -fno-common  -Wendif-labels -Wmissing-include-dirs 
-Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self 
-Wignored-qualifiers -Wold-style-declaration -Wold-style-definition 
-Wtype-limits -fstack-protector-strong  -I/usr/include/p11-kit-1     
-I/usr/include/libpng16  -I/usr/include/spice-server -I/usr/include/cacard 
-I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/glib-2.0 
-I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/spice-1  
-I/usr/include/cacard -I/usr/include/nss3 -I/usr/include/nspr4  
-I/usr/include/libusb-1.0   -I/home/armbru/work/qemu/tests -MMD -MP -MT t.o -MF 
./t.d -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include  -g   -c 
-o t.o /home/armbru/work/qemu/t.c -H -DH='"'$i'"'
done
exit 0

Reply via email to