JooHyukKim opened a new pull request, #20808: URL: https://github.com/apache/pulsar/pull/20808
### Motivation The current implementation of `StatsOutputStream` uses `java.util.Stack`, which is a thread-safe class and extends `Vector`, implying that its operations are `synchronized`. This introduces unnecessary performance overhead in contexts where a thread-safe data structure isn't required. The goal of this PR is to enhance the performance of `StatsOutputStream` by eliminating unneeded synchronization. ### Modifications This PR replaces `java.util.Stack` with `java.util.ArrayDeque`. The `ArrayDeque` class offers superior memory efficiency compared to `Stack` and delivers faster stack operation performance. It typically outperforms `LinkedList` for stack operations because it doesn't need to manage node instances. By switching to `ArrayDeque`, we're reducing unnecessary synchronization, resulting in a performance improvement for `StatsOutputStream`. ### Verifying this change - [x] Make sure that the change passes the CI checks. ### Does this pull request potentially affect one of the following parts: <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> *If the box was checked, please highlight the changes* - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The schema - [ ] The default values of configurations - [ ] The threading model - [ ] The binary protocol - [ ] The REST endpoints - [ ] The admin CLI options - [ ] The metrics - [ ] Anything that affects deployment ### Documentation <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. --> - [ ] `doc` <!-- Your PR contains doc changes. --> - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-complete` <!-- Docs have been already added --> ### Matching PR in forked repository PR in forked repository: x -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
