Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/868#discussion_r126825276
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
 ---
    @@ -72,7 +72,16 @@ public SimpleParallelizer(QueryContext context) {
         OptionManager optionManager = context.getOptions();
         long sliceTarget = 
optionManager.getOption(ExecConstants.SLICE_TARGET).num_val;
         this.parallelizationThreshold = sliceTarget > 0 ? sliceTarget : 1;
    -    this.maxWidthPerNode = 
optionManager.getOption(ExecConstants.MAX_WIDTH_PER_NODE_KEY).num_val.intValue();
    +    // If the max_width is not set in the validator compute from the cpu 
load average
    +    long maxWidth = 
optionManager.getOption(ExecConstants.MAX_WIDTH_PER_NODE);
    +    if(maxWidth == 0) {
    +      Double cpu_load_average = 
optionManager.getOption(ExecConstants.CPU_LOAD_AVERAGE);
    +      this.maxWidthPerNode = (int)  
Math.ceil(Runtime.getRuntime().availableProcessors() * cpu_load_average);
    --- End diff --
    
    Probably should:
    
    * round result, not take the ceiling
    * clamp the number at 1 and the number of processors
    ```
    Math.max(1, Math.min( availProc, Math.round(... * ...) ) )
    ```
    We didn't do this before, but we should have...
    
    This is true if the value was set by a property, so the clamping should be 
done regardless of whether the value is retrieved or computed. (Gracefully 
handle the case where someone sets the value to 0 or 1 million, say.)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to