RFR: 8317453: NMT: Performance benchmarks are needed to measure speed and memory [v34]
Gerard Ziemski
gziemski at openjdk.org
Wed Feb 12 20:57:57 UTC 2025
> Here is another, hopefully, closer to the final iteration of NMT benchmarking mechanism.
>
> We create 2 static instances: one NMT_MemoryLogRecorder the other NMT_VirtualMemoryLogRecorder.
>
> VM interacts with these through these APIs:
>
> ```
> NMT_LogRecorder::initialize(NMTRecordMemoryAllocations, NMTRecordVirtualMemoryAllocations);
> NMT_LogRecorder::replay(NMTBenchmarkRecordedDir, NMTBenchmarkRecordedPID);
> NMT_LogRecorder::logThreadName(name);
> NMT_LogRecorder::finish();
>
>
> For controlling their liveness and through their "log" APIs for the actual logging.
>
> For memory logger those are:
>
>
> NMT_MemoryLogRecorder::log_malloc(mem_tag, outer_size, outer_ptr, &stack);
> NMT_MemoryLogRecorder::log_realloc(mem_tag, new_outer_size, new_outer_ptr, header, &stack);
> NMT_MemoryLogRecorder::log_free(old_outer_ptr);
>
>
> and for virtual memory logger, those are:
>
>
> NMT_VirtualMemoryLogRecorder::log_virtual_memory_reserve((address)addr, size, stack, mem_tag);
> NMT_VirtualMemoryLogRecorder::log_virtual_memory_release((address)addr, size);
> NMT_VirtualMemoryLogRecorder::log_virtual_memory_uncommit((address)addr, size);
> NMT_VirtualMemoryLogRecorder::log_virtual_memory_reserve_and_commit((address)addr, size, stack, mem_tag);
> NMT_VirtualMemoryLogRecorder::log_virtual_memory_commit((address)addr, size, stack);
> NMT_VirtualMemoryLogRecorder::log_virtual_memory_split_reserved((address)addr, size, split, mem_tag, split_tag);
> NMT_VirtualMemoryLogRecorder::log_virtual_memory_tag((address)addr, mem_tag);
>
>
> That's the entirety of the surface area of the new code.
>
> The actual implementation extends one existing VM API:
>
> `bool Arguments::copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen, int pid)
> `
>
> and adds a few APIs to permit_forbidden_function.hpp:
>
>
> inline char *strtok(char *str, const char *sep) { return ::strtok(str, sep); }
> inline long strtol(const char *str, char **endptr, int base) { return ::strtol(str, endptr, base); }
>
> #if defined(LINUX)
> inline size_t malloc_usable_size(void *_Nullable ptr) { return ::malloc_usable_size(ptr); }
> #elif defined(WINDOWS)
> inline size_t _msize(void *memblock) { return ::_msize(memblock); }
> #elif defined(__APPLE__)
> inline size_t malloc_size(const void *ptr) { return ::malloc_size(ptr); }
> #endif
>
>
> Those are need if we want to calculate the memory overhead
>
> To use, you first need to record the pattern of operations, ex:
>
> `./build/macosx-aarch64-server-release/xcode/build/jdk/bin/...
Gerard Ziemski has updated the pull request incrementally with two additional commits since the last revision:
- fix build
- fix build
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/23115/files
- new: https://git.openjdk.org/jdk/pull/23115/files/b652ee6e..27575a11
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=23115&range=33
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=23115&range=32-33
Stats: 12 lines in 3 files changed: 2 ins; 1 del; 9 mod
Patch: https://git.openjdk.org/jdk/pull/23115.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/23115/head:pull/23115
PR: https://git.openjdk.org/jdk/pull/23115
More information about the hotspot-dev
mailing list