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

ASF GitHub Bot commented on GOSSIP-44:
--------------------------------------

GitHub user edwardcapriolo opened a pull request:

    https://github.com/apache/incubator-gossip/pull/27

    GOSSIP-44 Remove 4 byte header

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/edwardcapriolo/incubator-gossip GOSSIP-44

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-gossip/pull/27.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #27
    
----
commit de9b7be381abf9ac8ee01b6558f89e9d2444e56f
Author: Edward Capriolo <[email protected]>
Date:   2017-01-20T16:40:52Z

    GOSSIP-44 Remove 4 byte header

----


> Remove 4 byte size header
> -------------------------
>
>                 Key: GOSSIP-44
>                 URL: https://issues.apache.org/jira/browse/GOSSIP-44
>             Project: Gossip
>          Issue Type: Improvement
>            Reporter: Edward Capriolo
>            Assignee: Edward Capriolo
>             Fix For: 0.1.2
>
>
> Currently we turn our messages into a byte array and append a 4 byte header. 
> We also calculate the size of the object before sending. 
> {noformat}
>    int packet_length = UdpUtil.readPacketLengthFromBuffer(buf);
>         if (packet_length <= GossipManager.MAX_PACKET_SIZE) {
>           byte[] json_bytes = new byte[packet_length];
>           for (int i = 0; i < packet_length; i++) {
>             json_bytes[i] = buf[i + 4];
>           }
>           debug(pac
> {noformat}
> While this protection is valid. I believe it hurts performance more than it 
> helps because 
> * we make more memory pressure.
> * create a data payload that is harder to send and harder to parse
> * currently we are computer the payload twice 
> We should optimize by not creating the data twice, removing the header, 2 
> attempting to write it directly to the stream (not store as a byte [] first)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to