<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Interesting discussion on simplepush happening<br><div><br><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>From: </b></span><span style="font-family:'Helvetica'; font-size:medium;">JR Conlin &lt;<a href="mailto:jrconlin@mozilla.com">jrconlin@mozilla.com</a>&gt;<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>Subject: </b></span><span style="font-family:'Helvetica'; font-size:medium;"><b>Re: packet truncating for wire exchange.</b><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>Date: </b></span><span style="font-family:'Helvetica'; font-size:medium;">November 5, 2013 3:27:21 PM EST<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>To: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Doug Turner &lt;<a href="mailto:doug.turner@gmail.com">doug.turner@gmail.com</a>&gt;<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>Cc: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Jeremiah Orem &lt;<a href="mailto:oremj@mozilla.com">oremj@mozilla.com</a>&gt;, <a href="mailto:dev-simplepush@mozilla.org">dev-simplepush@mozilla.org</a><br></span></div><br><div>First off, this was merely a proposal, not a demand or request. I simply<br>was noting that some efficiency could be introduced with minimal impact.<br><br>That said, I can also offer the following helpful points:<br><br>TCP structures are not set to a static length. The TCP header specifies<br>the "window size" of the data packet.<br><a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure">http://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure</a><br><br>TCP window sizes can be between 2 and 65,535 bytes by default or a<br>scaling factor may be used (see RFC 1323) which can expand a window size<br>up to 1GB. Packets of that size are generally not recommended for most<br>systems due to the increasing chance of corruption on non dedicated links.<br><br>There are other considerations regarding TCP tuning that can effect<br>retransmission or optimization of data packets, but our data is<br>generally far, far below that.<br><br>Where things become more of a concern is that metering is generally done<br>not by packets but by bits. (This is why carriers tend to refer to<br>connections using the small "b" indicating a given link can exchange<br>56Kbs or 56,000,000 bits per second). In this case, sending<br>{"messageType":"hello"} (using ASCII) would require 24 Bytes of<br>information, or 192 bits. Sending {"m":"h"} would require 10 bytes of<br>information, or 80 bits. While this is purely an example, it should be<br>noted that the following would help show the bandwidth consumption of<br>repeated transmission:<br><br>long form &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;short form<br> &nbsp;1: &nbsp;192 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1: &nbsp;80<br> &nbsp;2: &nbsp;384 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2: 160<br> &nbsp;3: &nbsp;576 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3: 320<br> &nbsp;4: &nbsp;768 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4: 400<br> &nbsp;5: &nbsp;960 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5: 480<br> &nbsp;6: 1152 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6: 540<br><br>So after six of these exchanges, we're seeing 612 bits of savings.<br>Enough to send another 7 short form messages.<br><br>This implementation could be performed without impacting existing code.<br>We're using the same data format for exchange (string encoded JavaScript<br>Object Notation). JSON provides a very loose binding for data (in that<br>data exchanged may have optional components or definitions). This is<br>useful in cases where the actual function to process the data may be<br>different depending on a sole value within the data being defined. In<br>this case, we are using the value of the key "messageType". These<br>values, while descriptive, are a bit like me calling you Douglas Turner<br>of Mozilla Incorporated located in Mountain View California in the<br>United States of America on planet Earth of the Sol System contained in<br>the Orion sub-arm of the the Milky Way Galaxy of the Local Galaxy<br>Group... Since no one else in this group is called "Doug", it's a<br>viable, non confusing means of noting the individual to whom I wish to<br>address. Instead of prepping a good deal of memory and instructions to<br>cycle over a string, we can simply tell the program to match the first<br>character and move on.<br><br>Does this help clarify my thinking?<br><br>On 2013/11/5 11:50 AM, Doug Turner wrote:<br><blockquote type="cite">No change without data. &nbsp;We need to understand exactly the bandwidth saving (in terms of tcp packets). &nbsp;Hearing about random reports from people deploying isn’t good enough. &nbsp;Lets get the hard data, analyze, then figure out what we should do.<br><br><br><br>On Nov 5, 2013, at 11:48 AM, JR Conlin &lt;jrconlin@mozilla.com&gt; wrote:<br><br><blockquote type="cite">True, but that would also mean scrapping SimplePush as it stands<br>currently, since there's no provision for versions. (How does a client<br>or server know before data exchange which protocol is being used?)<br><br>So far, we've not experienced any problems with SimplePush, mostly<br>because it has yet to get wide traction.<br><br>While tossing out the protocol may have minimal impact to ourselves, it<br>does mean that we've wasted a good deal of time and marketing from both<br>ourselves and groups like Aerogear. I don't think they'd appreciate us<br>tossing things, and might not be as welcoming to the next version of<br>whatever we release.<br><br>(on a somewhat personal note, this is why I tend to advocate for<br>quieter, internal releases and iterations of projects like this before<br>we try to seek wide adoption.)<br><br>On 2013/11/5 11:39 AM, Doug Turner wrote:<br><blockquote type="cite">If we make any change to the wire protocol, we should start form the beginning and design a binary protocol (not what we have now). &nbsp;We also may want to move away from web sockets.<br><br>Has this become any significant problem?<br><br><br><br><br>On Nov 5, 2013, at 11:35 AM, Jeremiah Orem &lt;oremj@mozilla.com&gt; wrote:<br><br><blockquote type="cite">If we are thinking about changing the format of the messages, I'd like to throw an additional idea in to the ring.<br><br>Right now, with Go, we have to decode the message to a map instead of a struct, because we don't know the message fields ahead of time. If we changed the structure to {"m":"h", "d": {"u":"123abcd...","c":[...]}}, we could use the RawMessage decoder. for example:<br><br>type Message struct {<br>MessageType string `json:"m"`<br>Data *json.RawMessage `json:"d"`<br>}<br><br>type HelloMessage struct {<br>Uaid string `json:"u"`<br>C []string `json:"c"`<br>}<br><br>var d Message<br>json.Unmarshal(msg, &amp;d)<br>switch d.MessageType {<br>case "h":<br>var h HelloMessage<br>d.Data.UnMarshal(&amp;h)<br>fmt.Println(h.Uaid, h.C)<br>....<br><br>Any reason not to do this?<br><br>-Jeremy<br><br>JR Conlin wrote:<br><blockquote type="cite">Looking at the packets being exchanged between server and client, it<br>strikes me that they're a bit... wordy. That's great for docs and demo<br>code, not so hot for user bandwidth costs.<br><br>Fortunately, it looks like we can trim things down quite a bit by just<br>doing lead character checks. For example: the "hello" packet is:<br><br>{"messageType":"hello", "uaid":"123abcd...", "channelIDs":[...]}<br><br>This could be trimmed down to just:<br>{"m":"h", "u":"123abcd...","c":[...]}<br><br>We could do the same trick with most of the other packets as well. I'm<br>betting you can probably figure out which these are:<br><br>{"m":"r","u":"234cdef..."}<br>{"m":"p"}<br>{"m":"u","u":"234cdef..."}<br>{"m":"n","u":[{"c":"123abcd...","v":1},{"c":"234cdef...","v":2}]}<br><br>Since the context of the message is already determined by the message<br>type, and there's only a few message types presented, it's easy to<br>determine the data.<br><br>Granted, we're not saving a ton per message, but a fair bit in<br>aggregate. In addition, key matches would obviously be a fair bit<br>faster, since your only matching single values. Or you could add a<br>wrapper that detects the short "m" key, and converts things back to<br>"long form".<br><br>granted, this is somewhat complicated because there's no version. While<br>not strictly required for this (short keys are a pretty good indicator<br>of the change being used), it does mean that any future change might be<br>a bit difficult to do, and limits us to 52 potential message types.<br><br>Thoughts?<br>_______________________________________________<br>Dev-simplepush mailing list<br>Dev-simplepush@mozilla.org<br>https://mail.mozilla.org/listinfo/dev-simplepush<br></blockquote>_______________________________________________<br>Dev-simplepush mailing list<br>Dev-simplepush@mozilla.org<br>https://mail.mozilla.org/listinfo/dev-simplepush<br></blockquote><br></blockquote><br></blockquote><br></blockquote><br>_______________________________________________<br>Dev-simplepush mailing list<br>Dev-simplepush@mozilla.org<br>https://mail.mozilla.org/listinfo/dev-simplepush<br></div></blockquote></div><br></body></html>