You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "BELUGA BEHR (JIRA)" <ji...@apache.org> on 2017/07/22 15:21:00 UTC

[jira] [Comment Edited] (AVRO-2056) DirectBinaryEncoder Creates Buffer For Each Call To writeDouble

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

BELUGA BEHR edited comment on AVRO-2056 at 7/22/17 3:20 PM:
------------------------------------------------------------

With the patch applied, writing Doubles is between 1% and 2% faster and has the added benefit of cutting down on garbage collection

{code}
# Avro Master + Patch

DoubleWrite:   2762 ms      72.407       579.258       2000000
DoubleWrite:   2786 ms      71.787       574.293       2000000
DoubleWrite:   2755 ms      72.570       580.561       2000000							   

# Avro Master

DoubleWrite:   2822 ms      70.871       566.965       2000000
DoubleWrite:   2830 ms      70.667       565.336       2000000
DoubleWrite:   2807 ms      71.230       569.842       2000000
{code}


was (Author: belugabehr):
With the patch applied, writing Doubles is between 1% and 2% faster and has the added benefit of cutting down on garbage collection

{code}
# Buffer Removed

DoubleWrite:   2762 ms      72.407       579.258       2000000
DoubleWrite:   2786 ms      71.787       574.293       2000000
DoubleWrite:   2755 ms      72.570       580.561       2000000							   

# Buffer Present

DoubleWrite:   2822 ms      70.871       566.965       2000000
DoubleWrite:   2830 ms      70.667       565.336       2000000
DoubleWrite:   2807 ms      71.230       569.842       2000000
{code}

> DirectBinaryEncoder Creates Buffer For Each Call To writeDouble
> ---------------------------------------------------------------
>
>                 Key: AVRO-2056
>                 URL: https://issues.apache.org/jira/browse/AVRO-2056
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.7.7, 1.8.2
>            Reporter: BELUGA BEHR
>            Assignee: BELUGA BEHR
>            Priority: Minor
>         Attachments: AVRO-2056.1.patch
>
>
> Each call to {{writeDouble}} creates a new buffer and promptly throws it away even though the class has a re-usable buffer and is used in other methods such as {{writeFloat}}.  Remove this extra buffer.
> {code:title=org.apache.avro.io.DirectBinaryEncoder}
>   // the buffer is used for writing floats, doubles, and large longs.
>   private final byte[] buf = new byte[12];
>   @Override
>   public void writeFloat(float f) throws IOException {
>     int len = BinaryData.encodeFloat(f, buf, 0);
>     out.write(buf, 0, len);
>   }
>   @Override
>   public void writeDouble(double d) throws IOException {
>     byte[] buf = new byte[8];
>     int len = BinaryData.encodeDouble(d, buf, 0);
>     out.write(buf, 0, len);
>   }
> {code}



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