Skip to content

Comments

More fine-grained DI for management node types. Don't allocate processing resources on Router#4429

Merged
gianm merged 6 commits intoapache:masterfrom
metamx:RouterProcessingModule
Jun 28, 2017
Merged

More fine-grained DI for management node types. Don't allocate processing resources on Router#4429
gianm merged 6 commits intoapache:masterfrom
metamx:RouterProcessingModule

Conversation

@leventov
Copy link
Member

  • Remove DruidProcessingModule, QueryableModule and QueryRunnerFactoryModule from DI for coordinator, overlord, middle-manager.
  • Add RouterDruidProcessing not to allocate processing resources on Router.

The same goal as in #4410.

…odule from DI for coordinator, overlord, middle-manager. Add RouterDruidProcessing not to allocate processing resources on router
@leventov leventov requested a review from gianm June 20, 2017 22:00
@leventov
Copy link
Member Author

@gianm could you please review this pr?

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

General approach looks reasonable. Didn't review all the X-Pool refactors yet.


# Processing threads and buffers
druid.processing.buffer.sizeBytes=256000000
druid.processing.numThreads=2
Copy link
Contributor

Choose a reason for hiding this comment

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

These are still useful since they're passed down to tasks. It would be better if the MM ignored them for its own processing pool (since it doesn't need one!) but still "remembered" them to pass down to each task.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't it configured as druid.indexer.fork.property.druid.processing.numThreads=2

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently both druid.indexer.fork.property.druid.processing.numThreads and druid.processing.numThreads would work (all druid.* properties are passed down automatically). A number of deployments depend on the latter form so it should keep working. fwiw, I also think it's prettier than the former, so I wouldn't want to deprecate it.

Copy link
Member Author

@leventov leventov Jun 23, 2017

Choose a reason for hiding this comment

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

Reverted those example configs but with druid.indexer.fork.property. prefixes because IMO it's less confusing, and leaves less room for mistakes (e. g. when configs for different node types are shared, or copied when people base configs for one node type on config for another node type, etc.)

if (numThreadsConfigured != DEFAULT_NUM_THREADS) {
return numThreadsConfigured;
} else {
return Runtime.getRuntime().availableProcessors() - 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect this code is unused (or maybe lightly used) or else someone would have complained by now that it doesn't work when you only have one processor. It should be max(1, Runtime.getRuntime().availableProcessors() - 1).

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

} else {
// default to leaving one core for background tasks
final int processors = Runtime.getRuntime().availableProcessors();
return processors > 1 ? processors - 1 : processors;
Copy link
Contributor

Choose a reason for hiding this comment

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

This overrides getNumThreads from ExecutorServiceConfig, which maybe explains why nobody has complained about the bug there yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this method, because it seems to be identical to the overridden method.

public BlockingPool<ByteBuffer> getMergeBufferPool(DruidProcessingConfig config)
{
if (config.getNumMergeBuffersConfigured() != DruidProcessingConfig.DEFAULT_NUM_MERGE_BUFFERS) {
log.error(
Copy link
Contributor

Choose a reason for hiding this comment

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

warn is probably more appropriate as nothing will really break here -- it's just a misguided configuration.

public ExecutorService getProcessingExecutorService(DruidProcessingConfig config)
{
if (config.getNumThreadsConfigured() != ExecutorServiceConfig.DEFAULT_NUM_THREADS) {
log.error("numThreads[%d] configured, that is ingnored on Router", config.getNumThreadsConfigured());
Copy link
Contributor

Choose a reason for hiding this comment

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

"ignored" (spelling). Also, as below, warn is probably more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed spelling.

Made it error deliberately, because in the future DruidProcessingConfig shouldn't be injected on Router.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, error sounds good then.

protected List<? extends Module> getModules()
{
return ImmutableList.of(
new DruidProcessingModule(),
Copy link
Contributor

Choose a reason for hiding this comment

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

DumpSegment needs this stuff?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, DumpSegment makes a segmentMetadata query!

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, cool :)

protected List<? extends Module> getModules()
{
return ImmutableList.<Module>of(
new DruidProcessingModule(),
Copy link
Contributor

Choose a reason for hiding this comment

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

InsertSegment needs this stuff?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, but since CreateTables and DumpSegment weirdly depend on this stuff, and we don't test InsertSegment at all (neither from unit tests nor integration tests), I decided to include everything, not to break it occasionally. The same for ResetCluster, ValidateSegments and DruidJsonValidator.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. Perhaps include a comment that we're not sure if these are actually needed or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added comments

protected List<? extends Module> getModules()
{
return ImmutableList.<Module>of(
new DruidProcessingModule(),
Copy link
Contributor

Choose a reason for hiding this comment

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

ResetCluster needs this stuff?

protected List<? extends Module> getModules()
{
return ImmutableList.of(
new DruidProcessingModule(),
Copy link
Contributor

Choose a reason for hiding this comment

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

ValidateSegments needs this stuff?

protected List<? extends com.google.inject.Module> getModules()
{
return ImmutableList.<com.google.inject.Module>of(
new DruidProcessingModule(),
Copy link
Contributor

Choose a reason for hiding this comment

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

DruidJsonValidator needs this stuff?


public static final int BUFFER_SIZE = 0x10000;
private static final StupidPool<BufferRecycler> bufferRecyclerPool = new StupidPool<BufferRecycler>(
private static final NonBlockingPool<com.ning.compress.BufferRecycler> bufferRecyclerPool = new StupidPool<BufferRecycler>(
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please remove com.ning.compress


public interface NonBlockingPool<T>
{
ResourceHolder<T> take();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should NonBlockingPool and BlockingPool extend some common interface like ResourcePool?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see the point. BlockingPool could extend NonBlockingPool but it would look surprising. Also it may create problems with DI

Copy link
Contributor

@drcrallen drcrallen left a comment

Choose a reason for hiding this comment

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

Looks cool! Changing around the module injection order can change the lifecycle ordering through. As such this probably needs good testing internally to make sure the different instance types can all run with this change.

@gianm
Copy link
Contributor

gianm commented Jun 26, 2017

Looks cool! Changing around the module injection order can change the lifecycle ordering through. As such this probably needs good testing internally to make sure the different instance types can all run with this change.

The integration tests, at least, check it for the major types.

@gianm gianm added this to the 0.10.1 milestone Jun 27, 2017
@gianm
Copy link
Contributor

gianm commented Jun 27, 2017

Moved into 0.10.1 as discussed in the dev sync

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

LGTM

@gianm gianm merged commit 2fa4b10 into apache:master Jun 28, 2017
gianm pushed a commit to gianm/druid that referenced this pull request Jun 28, 2017
…sing resources on Router (apache#4429)

* Remove DruidProcessingModule, QueryableModule and QueryRunnerFactoryModule from DI for coordinator, overlord, middle-manager. Add RouterDruidProcessing not to allocate processing resources on router

* Fix examples

* Fixes

* Revert Peon configs and add comments

* Remove qualifier
fjy pushed a commit that referenced this pull request Jun 28, 2017
…sing resources on Router (#4429) (#4478)

* Remove DruidProcessingModule, QueryableModule and QueryRunnerFactoryModule from DI for coordinator, overlord, middle-manager. Add RouterDruidProcessing not to allocate processing resources on router

* Fix examples

* Fixes

* Revert Peon configs and add comments

* Remove qualifier
@leventov leventov deleted the RouterProcessingModule branch June 28, 2017 21:02
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.

4 participants