RFR: 8329431: Improve speed of writing CDS heap objects
Calvin Cheung
ccheung at openjdk.org
Tue Apr 2 22:06:00 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.
A few comments below.
src/hotspot/share/cds/archiveHeapWriter.cpp line 233:
> 231: static int oop_sorting_rank(oop o) {
> 232: bool has_oop_ptr, has_native_ptr;
> 233: HeapShared::get_pointer_info(o, has_oop_ptr, has_native_ptr);
Please align line 233 with line 232.
src/hotspot/share/cds/heapShared.cpp line 289:
> 287: CachedOopInfo info = make_cached_oop_info(obj);
> 288: archived_object_cache()->put(obj, info);
> 289: archived_object_cache()->maybe_grow();
Is it possible to use `put_if_absent()` and only calls `maybe_grow()` if an entry has been created? Similar to what is being done in `HeapShared::add_to_dumped_interned_strings()`.
src/hotspot/share/cds/heapShared.cpp line 1413:
> 1411: assert(!has_been_seen_during_subgraph_recording(obj), "sanity");
> 1412: _seen_objects_table->put(obj, true);
> 1413: _seen_objects_table->maybe_grow();
Same comment as above.
-------------
PR Review: https://git.openjdk.org/jdk/pull/18572#pullrequestreview-1975139864
PR Review Comment: https://git.openjdk.org/jdk/pull/18572#discussion_r1548660200
PR Review Comment: https://git.openjdk.org/jdk/pull/18572#discussion_r1548666956
PR Review Comment: https://git.openjdk.org/jdk/pull/18572#discussion_r1548664676
More information about the hotspot-runtime-dev
mailing list