Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netty allocator wrapper #1754

Merged
merged 3 commits into from
Oct 25, 2018
Merged

Netty allocator wrapper #1754

merged 3 commits into from
Oct 25, 2018

Conversation

merlimat
Copy link
Contributor

@merlimat merlimat commented Oct 22, 2018

Motivation

Configuring the correct JVM memory settings and cache sizes for a BookKeeper cluster should be simplified.

There are currently many knobs in Netty or JVM flags for different components and while with a good setup the systems is very stable, it's easy to setup non-optimal configurations which might result in OutOfMemory errors under load.

Ideally, there should be very minimal configuration required to bring up a BookKeeper cluster that can work under a wide set of traffic loads. In any case, we should prefer to automatically fallback to slower alternatives, when possible, instead of throwing OOM exceptions.

  • Provide a wrapper to have a single unified configuration point for Netty allocator configuration.
  • Provide fallback policy when dealing with direct memory OOM errors

Changes

  • This is the first PR. It only contains the allocator wrapper implementation. Subsequent PR will add the changes to use it.
  • Added bookkeeper-common-allocator module to have a no-dependencues module that can be used directly from Pulsar client library too (which doesn't depend on BK).

@merlimat merlimat force-pushed the allocator branch 2 times, most recently from fe6d5dc to adb8bcf Compare October 23, 2018 05:22
Copy link
Contributor

@ivankelly ivankelly left a comment

Choose a reason for hiding this comment

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

lgtm. Please update the description with the relevant section. Specifically, the 'why'

*
* <p>Default is to use a new instance of {@link PooledByteBufAllocator}.
*/
ByteBufAllocatorBuilder pooledAllocator(ByteBufAllocator ooledAllocator);
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: missing 'p'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

any reason why we add another module, not add this to bookkeeper-common? I think allocator is a common enough component in current bookkeeper codebase, since bookkeeper heavily dependend on netty's buffers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's to include bookkeeper-common-allocator in pulsar-client that currently doesn't depend on bookkeeper-common, because it would pull in another set of dependencies.

<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
Copy link
Member

Choose a reason for hiding this comment

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

these classes only dependend on netty-buffer. netty-all includes all classes which are not needed for a "common" module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only reason is that throughout the code we use netty-all everywhere. If we use netty-buffer here, then we need to exclude it later or we'd be pulling both dependencies.

In any case, I agree that netty-all is a bit overkill, not just here but throughout the modules. We should take a look at breaking all netty dependencies down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed to require netty-buffer

Copy link
Member

Choose a reason for hiding this comment

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

okay

@merlimat
Copy link
Contributor Author

run integration tests

@merlimat
Copy link
Contributor Author

run integration tests

@codingwangqi
Copy link
Contributor

This allocator is very useful to address some of the issues I have encountered using netty.

@sijie
Copy link
Member

sijie commented Oct 25, 2018

IGNORE IT CI

@sijie sijie merged commit 379d2ba into apache:master Oct 25, 2018
merlimat added a commit that referenced this pull request Jan 8, 2019
### Motivation

This is based on #1754. Adding the code to configure and use the allocator wrapper in bookie and client.

(I'll rebase once the first PR is merged)

Reviewers: Ivan Kelly <ivank@apache.org>, Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org>

This closes #1755 from merlimat/use-allocator
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.

5 participants