drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-5601) Rollup of External Sort memory management fixes
Date Thu, 13 Jul 2017 22:21:00 GMT

    [ https://issues.apache.org/jira/browse/DRILL-5601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16086497#comment-16086497
] 

ASF GitHub Bot commented on DRILL-5601:
---------------------------------------

Github user Ben-Zvi commented on a diff in the pull request:

    https://github.com/apache/drill/pull/860#discussion_r127067063
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/record/SmartAllocationHelper.java
---
    @@ -0,0 +1,156 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.drill.exec.record;
    +
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +
    +import org.apache.drill.exec.vector.AllocationHelper;
    +import org.apache.drill.exec.vector.ValueVector;
    +import org.apache.drill.exec.vector.complex.AbstractMapVector;
    +import org.apache.drill.exec.vector.complex.RepeatedMapVector;
    +
    +/**
    + * Prototype mechanism to allocate vectors based on expected
    + * data sizes. This version uses a name-based map of fields
    + * to sizes. Better to represent the batch structurally and
    + * simply iterate over the schema rather than doing a per-field
    + * lookup. But, the mechanisms needed to do the efficient solution
    + * don't exist yet.
    + */
    +
    +public class SmartAllocationHelper {
    +
    +  public static class AllocationHint {
    +    public final int entryWidth;
    +    public final int elementCount;
    +
    +    private AllocationHint(int width, int elements) {
    +      entryWidth = width;
    +      elementCount = elements;
    +    }
    +
    +    @Override
    +    public String toString() {
    +      StringBuilder buf = new StringBuilder()
    --- End diff --
    
    This whole method can be written in only 4 lines of code \:
    
    if ( entryWidth > 0 && elementCount > 0 ) { return String.format("{width=%d,
elements=%d}",entryWidth,entryCount); }
    if ( entryWidth > 0 ) { return String.format("{width=%d}",entryWidth); }
    if ( elementCount > 0 ) { return String.format("{elements=%d}",entryCount); }
    return String.format("{}");
    
    or
    
    String ew = ( entryWidth > 0 ) ? String.format("width=%d",entryWidth) : "";
    String comma = ( entryWidth > 0 && elementCount > 0 ) ? ", " : "";
    String ec = ( elementCount > 0 ) ? String.format("elements=%d",entryCount) : "";
    return "{" + ew + comma + ec + "}" ;
    
    The above can even be pushed into a single line !!! A la APL :-) 


> Rollup of External Sort memory management fixes
> -----------------------------------------------
>
>                 Key: DRILL-5601
>                 URL: https://issues.apache.org/jira/browse/DRILL-5601
>             Project: Apache Drill
>          Issue Type: Task
>    Affects Versions: 1.11.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>             Fix For: 1.12.0
>
>
> Rollup of a set of specific JIRA entries that all relate to the very difficult problem
of managing memory within Drill in order for the external sort to stay within a memory budget.
In general, the fixes relate to better estimating memory used by the three ways that Drill
allocates vector memory (see DRILL-5522) and to predicting the size of vectors that the sort
will create, to avoid repeated realloc-copy cycles (see DRILL-5594).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message