On Tue, 10 Jun 2025 13:02:15 GMT, Coleen Phillimore <cole...@openjdk.org> wrote:
>> src/hotspot/share/utilities/packedTable.hpp line 56: >> >>> 54: // Packed table does NOT support duplicate keys. >>> 55: virtual bool next(uint32_t* key, uint32_t* value) = 0; >>> 56: }; >> >> Does it make sense to take the cost of an indirect call for each kv pair? >> You can't inline it, so the stack frame needs to be popped and pushed, and >> you're taking 2 registers (16 bytes) to give 8 bytes and 1 bit of >> information. >> >> We can amortize the cost by implementing this signature instead: >> >> >> virtual uint32_t next(Pair<uint32_t, uint32_t>* kvs, uint32_t kvs_size); > > This was done this way with a "Supplier" because this package would be useful > for other Unsigned5 packed types. But then you'd need create an array of `Pair` in `create_search_table` and copy the data into that. You wouldn't need a Supplier at all, just pass the array and its length to the `fill` method. If you are worried about the virtual calls, I could do that. Alternatively, we could replace virtual calls with templated `fill` method. In that case the Comparator should be a template method as well, since that one is even more perf-critical? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24847#discussion_r2137952293