RFR: JDK-8304421: Introduce malloc size feedback [v5]

Justin King jcking at openjdk.org
Fri Mar 17 20:08:41 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:

  Undo some optional refactoring
  
  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/0d807ce1..ed27c217

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=13081&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=13081&range=03-04

  Stats: 27 lines in 2 files changed: 0 ins; 13 del; 14 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