Skip to content

Implementation of recycling memory pool. - #72

Merged
kidkun merged 8 commits into
linkedin:2.3-lifrom
kidkun:2.3-li
Feb 12, 2020
Merged

Implementation of recycling memory pool.#72
kidkun merged 8 commits into
linkedin:2.3-lifrom
kidkun:2.3-li

Conversation

@kidkun

@kidkun kidkun commented Feb 6, 2020

Copy link
Copy Markdown

Add a new memory pool implementation in socket server.

This implementation is able to recycle the buffers of common request size(configurable via a new config, SocketRequestCommonBytes) to reuse the buffers for future request. Doing so can avoid many expense system call if the incoming requests` size are relatively fixed or distributed in normal distribution.

An example is like below,
received request1 of size1 byte -> allocate buffer for request 1
request 1 is processed by API layer -> instead of deallocate the buffer, clear it and save it in cache
received request2 of (size1- 100 byte) -> reuse the cached buffer for request 2 since request size is close and buffer is large enough

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/test/java/org/apache/kafka/common/memory/RecyclingMemoryPoolTest.java Outdated
Comment thread clients/src/test/java/org/apache/kafka/common/memory/RecyclingMemoryPoolTest.java Outdated
@radai-rosenblatt

radai-rosenblatt commented Feb 10, 2020

Copy link
Copy Markdown

sean is correct - lets drop down to something simpler (pre-allocated deque of the correct size) so we could measure impact on GC and decide on further optimizations later.

Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated
Comment thread clients/src/main/java/org/apache/kafka/common/memory/RecyclingMemoryPool.java Outdated

@radai-rosenblatt radai-rosenblatt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

one last change requested :-)

@radai-rosenblatt

Copy link
Copy Markdown

failing unit test:
kafka.server.KafkaConfigTest > testFromPropsInvalid FAILED
org.scalatest.exceptions.TestFailedException: Expected exception java.lang.Exception to be thrown, but no exception was thrown
at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:530)
at org.scalatest.Assertions$.newAssertionFailedException(Assertions.scala:1389)
at org.scalatest.Assertions$class.intercept(Assertions.scala:824)
at org.scalatest.Assertions$.intercept(Assertions.scala:1389)

@kidkun
kidkun merged commit 42673dc into linkedin:2.3-li Feb 12, 2020
gitlw pushed a commit that referenced this pull request Jun 1, 2020
TICKET =
LI_DESCRIPTION =
EXIT_CRITERIA = MANUAL [""]
gitlw pushed a commit that referenced this pull request Jun 12, 2020
TICKET =
LI_DESCRIPTION =
EXIT_CRITERIA = MANUAL [""]
gitlw pushed a commit that referenced this pull request Jun 13, 2020
TICKET =
LI_DESCRIPTION =
EXIT_CRITERIA = MANUAL [""]
lmr3796 pushed a commit to lmr3796/kafka that referenced this pull request Feb 9, 2022
TICKET =
LI_DESCRIPTION =
EXIT_CRITERIA = MANUAL [""]
lmr3796 pushed a commit to lmr3796/kafka that referenced this pull request Feb 9, 2022
TICKET =
LI_DESCRIPTION =
EXIT_CRITERIA = MANUAL [""]
lmr3796 pushed a commit to lmr3796/kafka that referenced this pull request Mar 25, 2022
TICKET =
LI_DESCRIPTION =
EXIT_CRITERIA = MANUAL [""]
lmr3796 pushed a commit to lmr3796/kafka that referenced this pull request Jun 2, 2022
TICKET =
LI_DESCRIPTION =
EXIT_CRITERIA = MANUAL [""]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants