RFR: 8329431: Improve speed of writing CDS heap objects
Matias Saavedra Silva
matsaave at openjdk.org
Thu Apr 4 21:43:09 UTC 2024
On Tue, 2 Apr 2024 03:08:27 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> [1] Change fixed sized ResourceHashtable used by CDS heap object dumping to ResizeableResourceHashtable. Before, the ArchivedObjectCache table has only 36k buckets. When running the LotsOfClasses.java test, this table would contain 721751 entries, so each bucket will have 200 entries. After the fix, the table will automatically expand so that each bucket will have about 8 entries.
>
> [2] ArchiveHeapWriter::sort_source_objs() used to do O(N*logN) lookup in ArchivedObjectCache (each lookup computes the "rank" of the object). Now the rank is computed once for each object, so the lookup has been reduced to O(N).
>
> [3] I also fixed TestCommon.findAllClasses() -- it used to try to recurse on even the non-directory entries. This causes 1 exception for each class in the jrt:// file system. Now we recurse only on directory entries.
>
> On my machine, the execution time of LotsOfClasses.java reduced from 40 seconds to 27 seconds.
I have a few comments below but overall this looks great!
src/hotspot/share/cds/archiveHeapWriter.cpp line 82:
> 80: Universe::heap()->collect(GCCause::_java_lang_system_gc);
> 81:
> 82: _buffer_offset_to_source_obj_table = new BufferOffsetToSourceObjectTable(36137, 1 * M);
Is there a variable we can use instead of the hard coded value 36137? It isn't immediately clear why this value is used and I think a named variable would clear that up.
src/hotspot/share/cds/archiveHeapWriter.cpp line 294:
> 292:
> 293: _buffer_offset_to_source_obj_table->put(buffer_offset, src_obj);
> 294: _buffer_offset_to_source_obj_table->maybe_grow();
Similar to Calvin's comment, is it better to call `put_if_absent()` and then `maybe_grow()` if a new entry is created?
src/hotspot/share/cds/archiveHeapWriter.hpp line 153:
> 151: struct HeapObjOrder {
> 152: int _index; // The location of this object in _source_objs
> 153: int _rank; // A lower rank means the object will be writte at a lower location.
Typo: writte -> written
-------------
PR Review: https://git.openjdk.org/jdk/pull/18572#pullrequestreview-1981220420
PR Review Comment: https://git.openjdk.org/jdk/pull/18572#discussion_r1552473175
PR Review Comment: https://git.openjdk.org/jdk/pull/18572#discussion_r1552482171
PR Review Comment: https://git.openjdk.org/jdk/pull/18572#discussion_r1552483230
More information about the hotspot-runtime-dev
mailing list