You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gossip.apache.org by "Edward Capriolo (JIRA)" <ji...@apache.org> on 2017/01/20 14:52:26 UTC

[jira] [Assigned] (GOSSIP-44) Remove 4 byte size header

     [ https://issues.apache.org/jira/browse/GOSSIP-44?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Edward Capriolo reassigned GOSSIP-44:
-------------------------------------

    Assignee: Edward Capriolo

> 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)