RFR: JDK-8304421: Introduce malloc size feedback [v3]
Justin King
jcking at openjdk.org
Fri Mar 17 17:36:46 UTC 2023
> Memory allocated by `malloc()` is frequently larger than the size actually requested. Some `malloc()` implementations allow querying this information. This can be useful as an optimization for some use cases, such as an arena allocator, as it allows using the entire memory block.
>
> This change updates `os::malloc()` by appending an additional argument that can request the actual usable size. On platforms that support it, the actual usable size of the allocation returned by `malloc()` will be filled in. Callers should then use `os::free_sized`, as with NMT enabled it can assert that the size is correct. This also is a precursor to eventually supporting `free_sized` from C23, which is an optimization usabled by some `malloc()` implementations to make `free()` quicker.
>
> This change also upgrades and refactors Chunk to use this facility.
>
> **Observations**
>
> NMT could use this same facility to keep track of the actual allocated size, instead of the requested size it has today, making it more accurate. Doing so is out of scope for this change.
Justin King has updated the pull request incrementally with one additional commit since the last revision:
Handle size overflow
Signed-off-by: Justin King <jcking at google.com>
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13081/files
- new: https://git.openjdk.org/jdk/pull/13081/files/e0d87ec0..f5037c8c
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13081&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13081&range=01-02
Stats: 7 lines in 1 file changed: 7 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/13081.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/13081/head:pull/13081
PR: https://git.openjdk.org/jdk/pull/13081
More information about the hotspot-runtime-dev
mailing list