Search code examples
androidcapnprotoprotocol-buffers

Wire protocol buffers vs Cap'n proto - which one is better?


I'm currently using wire protocol buffers in one of my android apps and looks like it's parseFrom() method is not very efficient as it takes ~10 ms even to parse a very small amount of data.

So I came across this: https://capnproto.org/index.html

Does anyone know what's the key difference between these two protocol buffers, mainly in terms of performance and features?


Solution

  • For me the issue was creating the Wire instance every time I parse a message.

    // Sample code 
    Wire wireObj = new Wire(<extension>);
    output = wireObj.parseFrom(<buffer>, <extension>);
    

    It turns out that if you create a Wire instance every time you need to parse a message, then it is time consuming. However, if you create it only once and reuse it for all other parsing requests, then it takes very less time (< 1ms).

    EDIT:

    Note: It still takes slightly longer to parse very first request though.