hiero-ledger / hiero-ledger/hiero-consensus-node
Too many ThreadLocals in Hedera node
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
### Problem
`jmap` histogram of a Hedera node shows 1700+ `ThreadLocals` most of which come from `log4j`. There is performance impact on operations with Hedera's own `ThreadLocals`.
The reason is a misuse of `ThreadLocal` due to not understanding the basic patterns of its use: a new `ThreadLocal` is created for each instance of `ReusableMessageFactory` (i.e. for each `Logger`), `AppenderControl`, etc.
See f.e. https://github.com/apache/logging-log4j2/commit/e86d28bdb927f8047b924eb459f4c63bd2e43176
### Solution
- file a ticket against `log4j` explaining the pattern of `static ThreadLocal.withInitial()`
### Alternatives
_No response_
Contributor guide
Research direction
Start by reviewing the jmap histogram findings in the issue and the linked Log4j commit e86d28bdb927f8047b924eb459f4c63bd2e43176. Compare the described per-instance ThreadLocal pattern with static ThreadLocal.withInitial(), then file the requested Log4j ticket explaining the issue and its performance impact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- Half a day
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100