> The static `ThreadHeapSampler::_log_table` is currently initialized on JVM > bootstrap to an overhead of ~67k instructions (linux-x64). By turning the > initialization into a constexpr, we can precalculate the helper table at > compile time, which trades a runtime overhead for a small, 8kb, static > footprint increase. > > I compared `fast_log2` with the `log2` builtin with a naive benchmarking > experiment[1] (not included in this PR) and show that the `fast_log2` is > ~2.5x faster than `log2` on my system. And that without the lookup table we'd > be much worse. So I think it makes sense to preserve this optimization, but > get rid of the startup overhead: > > [5.428s][debug][heapsampling] log2, 0.0751173 secs > [5.457s][debug][heapsampling] fast_log2, 0.0298244 secs > [5.622s][debug][heapsampling] fast_log2_uncached, 0.1645569 secs > > I've verified that this refactoring does not affect performance in this naive > setup. > > [1] https://github.com/openjdk/jdk/compare/master...cl4es:log2_micro?expand=1
Claes Redestad has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 11 additional commits since the last revision: - Merge branch 'master' into threadHeapSampler_constexpr - Check log_table on startup in debug builds - Add explicit include of logging - Add const, fix copyright - Desugar constexpr into code generator and output - Merge branch 'master' into threadHeapSampler_constexpr - Declare and define log_table as a static constexpr inside threadHeapSampler.cpp - Merge branch 'master' into threadHeapSampler_constexpr - Merge branch 'master' into threadHeapSampler_constexpr - Remove _log_table_initialized assert - ... and 1 more: https://git.openjdk.java.net/jdk/compare/b5bd0028...0eebe57c ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/880/files - new: https://git.openjdk.java.net/jdk/pull/880/files/a802814f..0eebe57c Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=880&range=06 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=880&range=05-06 Stats: 11692 lines in 331 files changed: 6229 ins; 3920 del; 1543 mod Patch: https://git.openjdk.java.net/jdk/pull/880.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/880/head:pull/880 PR: https://git.openjdk.java.net/jdk/pull/880