Skip to content

Commit 8a9567f

Browse files
rkennkeclaude
andcommitted
refactor(nativemem): rename CODECACHE category to NATIVE_SYMBOLS
The "CodeCache" name is async-profiler's, and collides with the JVM's JIT code cache. This category measures something unrelated: the profiler's own per-native-library symbol tables (used to symbolicate native frames), not JVM-managed code. Rename the NativeMem category and its JFR label to native_symbols so the metric is unambiguous. The existing CODECACHE_NATIVE_SIZE_BYTES counter keeps its name for continuity; only the new NativeMem category is renamed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ac8c128 commit 8a9567f

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

ddprof-lib/src/main/cpp/nativeMem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
X(CALLTRACE, "calltrace") \
3232
X(DICTIONARY, "dictionary") \
3333
X(THREAD_FILTER, "thread_filter") \
34-
X(CODECACHE, "codecache") \
34+
X(NATIVE_SYMBOLS, "native_symbols") \
3535
X(LINE_TABLES, "line_tables") \
3636
X(PERF, "perf") \
3737
X(THREAD_LOCAL, "thread_local") \

ddprof-lib/src/main/cpp/profiler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,9 +1696,10 @@ Error Profiler::dump(const char *path, const int length) {
16961696
Counters::set(CODECACHE_NATIVE_SIZE_BYTES, native_libs.memoryUsage());
16971697
Counters::set(CODECACHE_RUNTIME_STUBS_SIZE_BYTES,
16981698
native_libs.memoryUsage());
1699-
// CodeCache size is a recomputed gauge (not alloc/free deltas), so mirror it
1700-
// as an absolute. It shares the accuracy caveats of the counter above.
1701-
NativeMem::setLive(NM_CODECACHE, native_libs.memoryUsage());
1699+
// CodeCache here is the profiler's native-symbol tables (not the JVM code
1700+
// cache). Its size is a recomputed gauge (not alloc/free deltas), so mirror
1701+
// it as an absolute. It shares the accuracy caveats of the counter above.
1702+
NativeMem::setLive(NM_NATIVE_SYMBOLS, native_libs.memoryUsage());
17021703

17031704
Error err = Error::OK;
17041705
// rotateDictsAndRun rotates the dictionaries, takes lockAll() around the

ddprof-lib/src/test/cpp/nativeMem_ut.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ TEST_F(NativeMemTest, NegativeLiveClampedInSample) {
9494
// setLive() overwrites the live value (gauge semantics) but still advances the
9595
// peak, which is retained when the gauge shrinks.
9696
TEST_F(NativeMemTest, SetLiveOverwritesAndAdvancesMax) {
97-
NativeMem::setLive(NM_CODECACHE, 4096);
98-
EXPECT_EQ(4096, NativeMem::live(NM_CODECACHE));
99-
EXPECT_EQ(4096, NativeMem::max(NM_CODECACHE));
100-
NativeMem::setLive(NM_CODECACHE, 1024); // gauge shrinks
101-
EXPECT_EQ(1024, NativeMem::live(NM_CODECACHE));
102-
EXPECT_EQ(4096, NativeMem::max(NM_CODECACHE)); // peak retained
97+
NativeMem::setLive(NM_NATIVE_SYMBOLS, 4096);
98+
EXPECT_EQ(4096, NativeMem::live(NM_NATIVE_SYMBOLS));
99+
EXPECT_EQ(4096, NativeMem::max(NM_NATIVE_SYMBOLS));
100+
NativeMem::setLive(NM_NATIVE_SYMBOLS, 1024); // gauge shrinks
101+
EXPECT_EQ(1024, NativeMem::live(NM_NATIVE_SYMBOLS));
102+
EXPECT_EQ(4096, NativeMem::max(NM_NATIVE_SYMBOLS)); // peak retained
103103
}
104104

105105
// Every category exposes a distinct, non-empty name.

0 commit comments

Comments
 (0)