<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">+ Stephen Canon, because he probably has good ideas in this domain.</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Fri, Dec 18, 2015 at 3:42 PM, Nadav Rotem via swift-dev <span dir="ltr"><<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div><b><u><br></u></b></div><div><b><u>What’s next?</u></b></div><div><br></div><div>The small experiment I described above showed that compressing the names in the string table has a huge potential for reducing the size of swift binaries. I’d like for us (swift-developers) to talk about the implications of this change and start working on the two tasks of tightening our existing mangling format and on implementing a new compression layer on top. </div></div></blockquote><div><br></div><div>Hi Nadav,</div><div><br></div><div>This is a great start that shows that there is a potential for improvement in our mangled names!</div><div><br></div><div>To make this effort more visible, I would suggest creating a bug on <a href="https://bugs.swift.org/">https://bugs.swift.org/</a> .</div><div><br></div><div>I think we survey existing solutions that industry has developed for compressing short messages. What comes to mind:</div><div><br></div><div>- header compression in HTTP2:</div><div><a href="https://http2.github.io/http2-spec/compression.html" target="_blank">https://http2.github.io/http2-spec/compression.html</a><br></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">- PPM algorithms are one of the best-performing compression algorithms for text.</div><div class="gmail_extra"><br></div><div class="gmail_extra">- Arithmetic coding is also a natural starting point for experimentation.</div><div class="gmail_extra"><br></div>Since the input mangled name also comes in a restricted character set, we could also remove useless bits first, and try an existing compression algorithm on the resulting binary string.</div><div class="gmail_extra"><br></div><div class="gmail_extra">We should also build a scheme that uses shortest one between the compressed and non-compressed names.</div><div class="gmail_extra"><br></div><div class="gmail_extra">For running experiments it would be useful to publish a sample corpus of mangled names that we will be using for comparing the algorithms and approaches.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I also have a concern about making mangled names completely unreadable. Today, I can frequently at least get a gist of what the referenced entity is without a demangler. What we could do is make the name consist of a human-readable prefix that encodes just the base name and a compressed suffix that encodes the rest of the information.</div><div class="gmail_extra"><br></div><div class="gmail_extra">_T<length><class name><length><method name><compressed suffix></div><div class="gmail_extra"><br></div><div class="gmail_extra">We would be able to use references to the class and the method name from the compressed part, so that character data isn't completely wasted.</div><div class="gmail_extra"><br></div><div class="gmail_extra">This scheme that injects human-readable parts will also allow the debugger to quickly match the names without the need to decompress them.</div><div class="gmail_extra"><br></div><div class="gmail_extra">We should also investigate improving existing mangling scheme to produce shorter results. For example, one idea that comes to mind is using base-60 instead of base-10 for single-digit numbers that that specify identifier length, falling back to base-10 for longer numbers to avoid ambiguity. This would save one character for every identifier longer than 9 characters and shorter than 60, which is actually the common case.<br clear="all"><div><br></div><div>Dmitri</div><div><br></div>-- <br><div>main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>>*/</div>
</div></div>