OSDN Git Service

Write dex files to oat file early.
authorVladimir Marko <vmarko@google.com>
Thu, 26 Nov 2015 14:44:16 +0000 (14:44 +0000)
committerVladimir Marko <vmarko@google.com>
Fri, 15 Jan 2016 12:28:06 +0000 (12:28 +0000)
commit625a64aad13905d8a2454bf3cc0e874487b110d5
tree49035d031166ce9fe0c5dd2f4b34157100e1703f
parente1b0f475e851072d0083faf6e07d274e9f1fe6a5
Write dex files to oat file early.

Write dex files to oat file before we actually open and
verify them. Instead, open and verify the copies from the
oat file and use these. This way, in the most common case
of zipped dex files, we have mmapped dex files instead of
inflated dex files. That reduces the number of dirty pages
used by dex2oat.

Reading /proc/self/statm after we write the oat file for
a compilation of a certain large app on Nexus 5 AOSP build
with -j1, three attempts before and after this CL gave
    before: 346061 189462 6269 26 0 140723 0
            346189 189450 6269 26 0 140851 0
            346061 189463 6269 26 0 140723 0
    after:  346186 185808 23040 27 0 140468 0
            346186 185819 23040 27 0 140468 0
            346186 185822 23040 27 0 140468 0
These values are in pages (4KiB), so while the "size"
(=VmSize) is essentially unchanged, the "resident" (=VmRSS)
is over 14MiB less and the "shared" (i.e. backed by a file)
is 65.5MiB more. That is, the amount of dirty non-pageable
memory used is reduced by about 80MiB.

The oat file format has changed slightly, the class offset
table has been moved from the OatDexFile to its own section.
This actually fixes the alignment of these offsets as they
could have been unaligned previously, yet accessed as normal
with significant performance impact if the kernel has to
emulate the unaligned access (say, mips).

Change-Id: I0f4799bb1f1ca28e3533156a3494f55345c3e10a
19 files changed:
compiler/elf_builder.h
compiler/image_test.cc
compiler/oat_test.cc
compiler/oat_writer.cc
compiler/oat_writer.h
compiler/utils/test_dex_file_builder.h
dex2oat/dex2oat.cc
runtime/dex_file.cc
runtime/dex_file.h
runtime/mem_map.cc
runtime/mem_map.h
runtime/oat.h
runtime/oat_file.cc
runtime/parsed_options.cc
runtime/runtime.cc
runtime/runtime_options.cc
runtime/runtime_options.def
runtime/type_lookup_table.cc
runtime/type_lookup_table.h