[xsd-users] Unexplained code size increase

Glenn Nieuwenhuyse glenn.nieuwenhuyse at gmail.com
Mon Apr 23 17:01:52 EDT 2007


Hi all,

In the process of compiling code out of XML Schema files with the xsd
--cxx-tree tool, I was surprised about the vast amount of binary code
increase I saw in my binary. My original code was 5.2MB binary whilst after
the addition of the code for XML generation the binary code size went up to
16MB. I was able to reduce that amount, thanks to your help on the
--suppress-parsing bug and thanks to the --generate-inline switch, to
~11.5MB.

Having xerces linked statically costs about 2MB of the 6.5MB increase which
leaves about 4.5MB open for the generated code and of course the code using
it.

To illustrate my problem I have made a small test case (see attachment):
Currently my XML Schema is written as in the Large.xsd-file . The
Small.xsd-file is one of the possible solutions I'm looking into. The
XMLGenerator.h-file is similar to what I'm using in my software.

When compiling the example (instructions below) and using "size" to view the
size of each of the binary sections this is the result: (Using GCC 3.4.3)

(note that "nothing" is an almost-empty binary while small uses the Small
schema and LARGE uses the Large schema)

small  :                                  LARGE  :
        nothing  :
section               size        addr    section               size
addr    section               size        addr
.interp                 13   268435796    .interp                 13
268435796    .interp                 13   268435796
.note.ABI-tag           32   268435812    .note.ABI-tag           32
268435812    .note.ABI-tag           32   268435812
.hash                 1660   268435844    .hash                 1664
268435844    .hash                  208   268435844
.dynsym               3456   268437504    .dynsym               3472
268437508    .dynsym                528   268436052
.dynstr               4569   268440960    .dynstr               4519
268440980    .dynstr               1017   268436580
.gnu.version           432   268445530    .gnu.version           434
268445500    .gnu.version            66   268437598
.gnu.version_r         128   268445964    .gnu.version_r         128
268445936    .gnu.version_r         128   268437664
.rela.dyn              336   268446092    .rela.dyn              360
268446064    .rela.dyn              120   268437792
.rela.plt              744   268446428    .rela.plt              756
268446424    .rela.plt              216   268437912
.init                   40   268447172    .init                   40
268447180    .init                   40   268438128
.text                58852   268447212    .text               105916
268447220    .text                 2336   268438168
.fini                   32   268506064    .fini                   32
268553136    .fini                   32   268440504
.rodata               3896   268506096    .rodata               6960
268553168    .rodata                110   268440536
.sdata2                  0   268509992    .sdata2                  0
268560128    .sdata2                  0   268440648
.eh_frame_hdr         1828   268509992    .eh_frame_hdr         3068
268560128    .eh_frame_hdr           52   268440648
.eh_frame             8072   268511820    .eh_frame            14168
268563196    .eh_frame              200   268440700
.gcc_except_table     5348   268519892    .gcc_except_table    11904
268577364    .gcc_except_table       76   268440900
.ctors                  12   268591104    .ctors                  16
268656640    .ctors                  12   268506512
.dtors                   8   268591116    .dtors                   8
268656656    .dtors                   8   268506524
.jcr                     4   268591124    .jcr                     4
268656664    .jcr                     4   268506532
.got2                   16   268591128    .got2                   16
268656668    .got2                   16   268506536
.dynamic               232   268591144    .dynamic               232
268656684    .dynamic               224   268506552
.data                    8   268591376    .data                    8
268656916    .data                    8   268506776
.got                    20   268591384    .got                    20
268656924    .got                    20   268506784
.sdata                  80   268591404    .sdata                 100
268656944    .sdata                   8   268506804
.sbss                   27   268591488    .sbss                   27
268657048    .sbss                    2   268506812
.plt                   816   268591516    .plt                   828
268657076    .plt                   288   268506816
.bss                   644   268592336    .bss                  1084
268657904    .bss                   372   268507104
.comment               520           0    .comment
585           0    .comment               455           0
.debug_aranges        1744           0    .debug_aranges
2520           0    .debug_aranges         216           0
.debug_pubnames      24925           0    .debug_pubnames
37488           0    .debug_pubnames       3412           0
.debug_info         285224           0    .debug_info
422446           0    .debug_info          44659           0
.debug_abbrev         6204           0    .debug_abbrev
9444           0    .debug_abbrev         2522           0
.debug_line          32279           0    .debug_line
54768           0    .debug_line           3251           0
.debug_frame          9004           0    .debug_frame
15392           0    .debug_frame           284           0
.debug_str          165635           0    .debug_str
179847           0    .debug_str           52735           0
.debug_ranges         6392           0    .debug_ranges
9232           0    .debug_ranges           88           0
Total               623232    Total               887531
Total               113758

For merely 10 small classes ~50KB of stripped binary code (.text section)
seems huge.
Taken that my real XSD-file is a lot bigger, you can imagine where the
4.5MBis coming from.

Looking at the generated code I see lots of simple functions (empty
constructors using initializer lists, functions returning immediately, the
DOM-generating functions, ...). None of them look like they can produce that
amount of code. Even when nosing through the gcc-generated assembly I can
not spot anything irregular.

The example allows you to generate these results using the included example
file.
There's a makeExample shell-script included which you can adjust for your
specific configuration (compiler, stripper and XSD directory) however when
everything is standard it should work out of the box.

I'm hoping you can help me out in finding (and perhaps eliminating) where
the extra binary code is coming from between the Large.xsd and the
Small.xsdfile.

Kind regards,

Glenn.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.tar.gz
Type: application/x-gzip
Size: 2603 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070423/da4b0add/example.tar.bin


More information about the xsd-users mailing list