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

[FLINK-7745][tests] add tests for ensuring NetworkBufferPool overprovisioning behaviour #4758

Closed
wants to merge 3 commits into from

Conversation

NicoK
Copy link
Contributor

@NicoK NicoK commented Oct 2, 2017

What is the purpose of the change

Currently, there are no unit tests verifying NetworkBufferPool's behaviour in the case that the available number of buffers is too small for it to create LocalBufferPool instances. This PR adds some.

Brief change log

  • add unit tests for NetworkBufferPool not having as many buffers as required

Verifying this change

This change only adds unit tests.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)

Documentation

  • Does this pull request introduce a new feature? (no)
  • If yes, how is the feature documented? (JavaDocs)

int buffersToTakeFromPool2 = numBuffers - buffersToTakeFromPool1;

List<Buffer> buffers = new ArrayList<>(numBuffers);
BufferPool lbp1 = null, lbp2 = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

lbp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LocalBufferPool

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, after ~30 seconds I was able to decrypt this name, but please do not use abbreviations :)

List<Buffer> buffers = new ArrayList<>(numBuffers);
BufferPool lbp1 = null, lbp2 = null;
try {
lbp1 = networkBufferPool.createBufferPool(buffersToTakeFromPool2, numBuffers);
Copy link
Contributor

Choose a reason for hiding this comment

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

lbp1 vs buffersToTakeFromPool2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's correct - although I also had to think about this one more time, last time I looked at this commit: buffersToTakeFromPool2 is the minimum number of buffers reserved for this pool while buffersToTakeFromPool1 is the actual number of buffers we request from the pool - I could add a comment regarding this to the variable declaration

assertEquals(buffersToTakeFromPool1, lbp1.bestEffortGetNumOfUsedBuffers());
assertEquals(numBuffers, lbp1.getNumBuffers());

// create a second pool which requires more than are freely available at the moment
Copy link
Contributor

Choose a reason for hiding this comment

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

freely available?


Buffer buffer = lbp2.requestBuffer();
buffers.add(buffer);
assertNotNull(buffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

move this check one line above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right - also the same code some lines above (to be on the safe side if this ever fails the check)

for (Buffer buffer : buffers) {
buffer.recycle();
}
if (lbp1 != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of this null checking use guava's Closer class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, we don't want to extend further/add dependencies on guava, afaik

Copy link
Contributor

Choose a reason for hiding this comment

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

Shame :( Maybe we need our own Closer. It's a nice useful concept.

The testOverprovisioned() unit test wasn't really testing that a buffer returned
from lbp1 is available to lbp2 afterwards, which is also fixed in addition to
the improved comments in the tests.
@NicoK
Copy link
Contributor Author

NicoK commented Nov 1, 2017

Added some comments and also found out that the testOverprovisioned() test wasn't really testing what it was supposed to test :( - also fixed now.

Copy link
Contributor

@pnowojski pnowojski left a comment

Choose a reason for hiding this comment

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

Besides lbp - LGTM

- rename occurences of `lbp` to more meaningful names
Copy link
Contributor

@pnowojski pnowojski left a comment

Choose a reason for hiding this comment

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

LGTM

@tillrohrmann
Copy link
Contributor

Thanks for your contribution @NicoK and the review @pnowojski. Merging this PR.

tillrohrmann pushed a commit to tillrohrmann/flink that referenced this pull request Nov 6, 2017
…isioning behaviour

[FLINK-7745][tests] address PR comments, fix test

The testOverprovisioned() unit test wasn't really testing that a buffer returned
from lbp1 is available to lbp2 afterwards, which is also fixed in addition to
the improved comments in the tests.

[FLINK-7745][network] address PR comments

- rename occurences of `lbp` to more meaningful names

This closes apache#4758.
@asfgit asfgit closed this in e285a41 Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants