Skip to content

[ISSUE 2637] Fix jvm_memory_direct_bytes_used metrics when using jdk11+ - #3252

Merged
zymap merged 2 commits into
apache:masterfrom
hezhangjian:issue-2637
Jul 29, 2022
Merged

[ISSUE 2637] Fix jvm_memory_direct_bytes_used metrics when using jdk11+#3252
zymap merged 2 commits into
apache:masterfrom
hezhangjian:issue-2637

Conversation

@hezhangjian

Copy link
Copy Markdown
Member

Fix #2637 #3247

Motivation

The mertics about jvm_memory_direct_bytes_used is acquired by netty's PlatformDependent#DIRECT_MEMORY_COUNTER. Which can only acquired the memory used by netty.

Changes

  • use java.nio.Bits#RESERVED_MEMORY for jvm direct memory metrics.
  • add tests to ensure jvm_memory_direct_bytes_max and jvm_memory_direct_bytes_used gets value.

@hezhangjian

Copy link
Copy Markdown
Member Author

rerun failure checks

@dlg99 dlg99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more officially supported way of doing this?
mx bean or something like that.

E.g. I can't tell if this works in JDK 17 or the next one.

@dlg99

dlg99 commented Apr 29, 2022

Copy link
Copy Markdown
Contributor

e.g. see #3234 : "Starting from JDK17 the reflection is not allowed in the jdk internals modules"

@hezhangjian
hezhangjian force-pushed the issue-2637 branch 3 times, most recently from 33e9b35 to 33e3e3b Compare April 29, 2022 08:30

@dlg99 dlg99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StevenLuMT StevenLuMT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@zymap
zymap merged commit cefe9d4 into apache:master Jul 29, 2022
zymap pushed a commit that referenced this pull request Aug 1, 2022
…1+ (#3252)

Fix #2637 #3247

### Motivation
The mertics about `jvm_memory_direct_bytes_used` is acquired by netty's `PlatformDependent#DIRECT_MEMORY_COUNTER`. Which can only acquired the memory used by netty.

### Changes
- use `java.nio.Bits#RESERVED_MEMORY` for jvm direct memory metrics.
- add tests to ensure `jvm_memory_direct_bytes_max` and `jvm_memory_direct_bytes_used` gets value.

(cherry picked from commit cefe9d4)
hangc0276 pushed a commit to hangc0276/bookkeeper that referenced this pull request Nov 7, 2022
…1+ (apache#3252)

Fix apache#2637 apache#3247

### Motivation
The mertics about `jvm_memory_direct_bytes_used` is acquired by netty's `PlatformDependent#DIRECT_MEMORY_COUNTER`. Which can only acquired the memory used by netty.

### Changes
- use `java.nio.Bits#RESERVED_MEMORY` for jvm direct memory metrics.
- add tests to ensure `jvm_memory_direct_bytes_max` and `jvm_memory_direct_bytes_used` gets value.

(cherry picked from commit cefe9d4)
hangc0276 pushed a commit to hangc0276/bookkeeper that referenced this pull request Nov 7, 2022
…1+ (apache#3252)

Fix apache#2637 apache#3247

### Motivation
The mertics about `jvm_memory_direct_bytes_used` is acquired by netty's `PlatformDependent#DIRECT_MEMORY_COUNTER`. Which can only acquired the memory used by netty.

### Changes
- use `java.nio.Bits#RESERVED_MEMORY` for jvm direct memory metrics.
- add tests to ensure `jvm_memory_direct_bytes_max` and `jvm_memory_direct_bytes_used` gets value.

(cherry picked from commit cefe9d4)
@horizonzy

Copy link
Copy Markdown
Member

This may be a breaking change, after this pr. The old user who used jdk8 didn't record the direct memory metrics.

nicoloboschi pushed a commit to datastax/bookkeeper that referenced this pull request Jan 11, 2023
…1+ (apache#3252)

Fix apache#2637 apache#3247

### Motivation
The mertics about `jvm_memory_direct_bytes_used` is acquired by netty's `PlatformDependent#DIRECT_MEMORY_COUNTER`. Which can only acquired the memory used by netty.

### Changes
- use `java.nio.Bits#RESERVED_MEMORY` for jvm direct memory metrics.
- add tests to ensure `jvm_memory_direct_bytes_max` and `jvm_memory_direct_bytes_used` gets value.

(cherry picked from commit cefe9d4)
(cherry picked from commit 523ffcf)
@hezhangjian
hezhangjian deleted the issue-2637 branch May 26, 2024 11:06
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
…1+ (apache#3252)

Fix apache#2637 apache#3247

### Motivation
The mertics about `jvm_memory_direct_bytes_used` is acquired by netty's `PlatformDependent#DIRECT_MEMORY_COUNTER`. Which can only acquired the memory used by netty.

### Changes
- use `java.nio.Bits#RESERVED_MEMORY` for jvm direct memory metrics.
- add tests to ensure `jvm_memory_direct_bytes_max` and `jvm_memory_direct_bytes_used` gets value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The metrics about jvm_memory_direct_bytes_used

6 participants