Skip to content

Commit

Permalink
Make TypedSize.getEstimatedSize more accurate
Browse files Browse the repository at this point in the history
Previously we excluded the size of the instance itself, which is
significant since this is used in grouped aggregations. Also, we only
included the logical size of the BlockBuilder rather than the full
retained size
  • Loading branch information
cberner committed Dec 22, 2015
1 parent 09e1b89 commit 9e5835e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.util.array.IntBigArray;
import io.airlift.units.DataSize;
import org.openjdk.jol.info.ClassLayout;

import static com.facebook.presto.ExceededMemoryLimitException.exceededLocalLimit;
import static com.facebook.presto.type.TypeUtils.hashPosition;
Expand All @@ -30,6 +31,7 @@

public class TypedSet
{
private static final int INSTANCE_SIZE = ClassLayout.parseClass(TypedSet.class).instanceSize();
private static final float FILL_RATIO = 0.75f;
private static final long FOUR_MEGABYTES = new DataSize(4, MEGABYTE).toBytes();

Expand Down Expand Up @@ -63,7 +65,7 @@ public TypedSet(Type elementType, int expectedSize)

public long getEstimatedSize()
{
return elementBlock.getSizeInBytes() + blockPositionByHash.sizeOf();
return INSTANCE_SIZE + elementBlock.getRetainedSizeInBytes() + blockPositionByHash.sizeOf();
}

public boolean contains(Block block, int position)
Expand Down

0 comments on commit 9e5835e

Please sign in to comment.