Skip to content

eagerly allocate the intermediate computation buffers - #3628

Merged
fjy merged 1 commit into
apache:masterfrom
himanshug:eager_processing_buffers
Oct 31, 2016
Merged

fjy merged 1 commit into
apache:masterfrom
himanshug:eager_processing_buffers

Conversation

@himanshug

Copy link
Copy Markdown
Contributor

for better predictability and more importantly sometimes allocation may take significant amount of times (~ minute) resulting in very unpredictable query performance.

@himanshug himanshug added this to the 0.9.3 milestone Oct 31, 2016

@gianm gianm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@fjy

fjy commented Oct 31, 2016

Copy link
Copy Markdown
Contributor

👍

@leventov leventov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If intermediate buffers are effectively used in thread-local manner (what getNumThreads() as the number of pre-allocated buffers suggests), it should probably be rewritten with ThreadLocal<ByteBuffer>.

@fjy
fjy merged commit 32c5494 into apache:master Oct 31, 2016
@himanshug

Copy link
Copy Markdown
Contributor Author

@leventov that makes sense for the specific context of processing threads and i can imaging things being adjusted that way. however StupidPool is used in other places too where same thread might ask for multiple different buffers. my intention with this PR is to solve the problem mentioned in the description.

@cheddar

cheddar commented Nov 1, 2016

Copy link
Copy Markdown
Contributor

Actually, using it as a ThreadLocal is also incorrect because this isn't something that actually follows the lifecycle of the threads. If one of the processing threads dies for some unknown reason, that doesn't necessarily mean that we want new objects to be created.

The reason to use ThreadLocal is when an object is necessarily tied to the lifecycle of a thread or if the cost of management of those objects is sufficiently small that you don't care about spurious instantiations. Neither of those statements are true in this case.

@leventov

leventov commented Nov 2, 2016

Copy link
Copy Markdown
Member

@cheddar ThreadLocal isn't necessarily tied only with a Thread, it could be tied with a pair of a Thread and some object (i. e. ThreadLocal field is not static).

I'm pretty sure StupidPool is overused in the Druid codebase and could be avoided somewhere. Recently we have issues with GC and OOMs in production which most likely come from StupidPool's "finalized" direct buffers. The issue is probably mitigated by #3629 and #3631, but I'm not sure is gone entirely.

fundead pushed a commit to fundead/druid that referenced this pull request Dec 7, 2016
@himanshug
himanshug deleted the eager_processing_buffers branch January 3, 2017 16:22
dgolitsyn pushed a commit to metamx/druid that referenced this pull request Feb 14, 2017
@gianm

gianm commented Feb 28, 2017

Copy link
Copy Markdown
Contributor

@himanshug what did you want included in the release notes for this? (you tagged it "Release Notes")

@himanshug

Copy link
Copy Markdown
Contributor Author

@gianm i wanted to mention just a note that don't set druid.processing.numThreads and druid.processing.buffer.sizeBytes to arbitrarily large values or historical/peon startup might fail to start.

added it under "Other Notes"

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