Re: asm.js size overhead

2017-10-24 Thread Floh
Good point, when I tried the previous version of that feature (which was 
called *duplicate* function elimination) it only removed a 2 or 3 kilobytes 
(less than 1%) with my code bases on average, so I didn't pay too much 
attention ;)

Am Montag, 23. Oktober 2017 20:02:17 UTC+2 schrieb caiiiycuk:
>
> Also, you defenitely should add this 
> https://github.com/achoudhury85/Similar-Function-Elimination to your 
> article. For big codebase it's work really cool, usually it reduce 
> code by 20% (in my case 2-3Mb). 
>
> 2017-10-24 0:49 GMT+07:00 Floh : 
> > I don't know why the .mem files have that extension, I just rename them 
> to 
> > .mem.txt afterwards for the same effect. If you have control over your 
> web 
> > server config that's not an issue though. Only with github and other 
> hosting 
> > solution you have no full control over. 
> > 
> > I'm tending towards moving the mem files back into the asm.js file 
> anyway 
> > though, my demos usually have small static data, so the separate 
> download 
> > isn't worth it. 
> > 
> > Cheers, 
> > -Floh. 
> > 
> > Am Montag, 23. Oktober 2017 19:45:42 UTC+2 schrieb caiiiycuk: 
> >> 
> >> Thank you :) I see that asm.js do not produce much overhead. Floh, 
> >> thank you for great article, btw why mem file have mem extension, not 
> >> mem.js? For my projects I rename this file to mem.js (and replace all 
> >> occurrences in js) to get auto gzip features, etc. 
> >> 
> >> 2017-10-19 0:03 GMT+07:00 Charles Vaughn : 
> >> > You could get rid of the |0 on HEAP[x]|0 and on constant expressions 
> >> > (like 
> >> > u=u+32|0). 
> >> > 
> >> > You can also forward propagate the integer coercion to elide the 
> >> > function 
> >> > preambles that coerce their parameters. An example would be taking 
> >> > 
> >> > function pG(a,b){a=a|0;b=b|0;return $FU(a,b,1217,4169,4177)|0} 
> >> > 
> >> > And converting it to 
> >> > function pG(a,b){return $FU(a|0,b|0,1217,4169,4177)|0} 
> >> > 
> >> > On Wednesday, October 18, 2017 at 8:29:56 AM UTC-7, Alon Zakai wrote: 
> >> >> 
> >> >> I agree with Floh that it probably won't help much on gzip size. 
> Also 
> >> >> it 
> >> >> might make things slower (some variables might have undefined 
> instead 
> >> >> of 0, 
> >> >> etc., so more types to track), and you'd need to be careful to only 
> >> >> remove 
> >> >> actually redundant things (some |0's are necessary). 
> >> >> 
> >> >> But you can test something close to this pretty easily, build with 
> >> >> --closure 2 which will run closure advanced on the asm.js code. That 
> >> >> should 
> >> >> remove obviously-redundant asm.js things. 
> >> >> 
> >> >> On Tue, Oct 17, 2017 at 10:58 PM, caiiiycuk  
> wrote: 
> >> >>> 
> >> >>> Hi. Beacuse of google-chrome bug, and some other reasons I can't 
> use 
> >> >>> asm.js in my scripts. Currently I just replace "use asm"; to ""; 
> For 
> >> >>> my case 
> >> >>> is very important to reduce js size as much as possible. If I 
> revert 
> >> >>> all 
> >> >>> asm.js stuff (type declarations and etc.) to plain js, how do you 
> >> >>> think how 
> >> >>> much size I can reduce? 
> >> >>> 
> >> >>> -- 
> >> >>> You received this message because you are subscribed to the Google 
> >> >>> Groups 
> >> >>> "emscripten-discuss" group. 
> >> >>> To unsubscribe from this group and stop receiving emails from it, 
> send 
> >> >>> an 
> >> >>> email to emscripten-discuss+unsubscr...@googlegroups.com 
> . 
> >> >>> For more options, visit https://groups.google.com/d/optout. 
> >> >> 
> >> >> 
> >> > -- 
> >> > You received this message because you are subscribed to the Google 
> >> > Groups 
> >> > "emscripten-discuss" group. 
> >> > To unsubscribe from this group and stop receiving emails from it, 
> send 
> >> > an 
> >> > email to emscripten-discuss+unsubscr...@googlegroups.com 
> . 
> >> > For more options, visit https://groups.google.com/d/optout. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "emscripten-discuss" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to emscripten-discuss+unsubscr...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: asm.js size overhead

2017-10-23 Thread Александр Гурьянов
Also, you defenitely should add this
https://github.com/achoudhury85/Similar-Function-Elimination to your
article. For big codebase it's work really cool, usually it reduce
code by 20% (in my case 2-3Mb).

2017-10-24 0:49 GMT+07:00 Floh :
> I don't know why the .mem files have that extension, I just rename them to
> .mem.txt afterwards for the same effect. If you have control over your web
> server config that's not an issue though. Only with github and other hosting
> solution you have no full control over.
>
> I'm tending towards moving the mem files back into the asm.js file anyway
> though, my demos usually have small static data, so the separate download
> isn't worth it.
>
> Cheers,
> -Floh.
>
> Am Montag, 23. Oktober 2017 19:45:42 UTC+2 schrieb caiiiycuk:
>>
>> Thank you :) I see that asm.js do not produce much overhead. Floh,
>> thank you for great article, btw why mem file have mem extension, not
>> mem.js? For my projects I rename this file to mem.js (and replace all
>> occurrences in js) to get auto gzip features, etc.
>>
>> 2017-10-19 0:03 GMT+07:00 Charles Vaughn :
>> > You could get rid of the |0 on HEAP[x]|0 and on constant expressions
>> > (like
>> > u=u+32|0).
>> >
>> > You can also forward propagate the integer coercion to elide the
>> > function
>> > preambles that coerce their parameters. An example would be taking
>> >
>> > function pG(a,b){a=a|0;b=b|0;return $FU(a,b,1217,4169,4177)|0}
>> >
>> > And converting it to
>> > function pG(a,b){return $FU(a|0,b|0,1217,4169,4177)|0}
>> >
>> > On Wednesday, October 18, 2017 at 8:29:56 AM UTC-7, Alon Zakai wrote:
>> >>
>> >> I agree with Floh that it probably won't help much on gzip size. Also
>> >> it
>> >> might make things slower (some variables might have undefined instead
>> >> of 0,
>> >> etc., so more types to track), and you'd need to be careful to only
>> >> remove
>> >> actually redundant things (some |0's are necessary).
>> >>
>> >> But you can test something close to this pretty easily, build with
>> >> --closure 2 which will run closure advanced on the asm.js code. That
>> >> should
>> >> remove obviously-redundant asm.js things.
>> >>
>> >> On Tue, Oct 17, 2017 at 10:58 PM, caiiiycuk  wrote:
>> >>>
>> >>> Hi. Beacuse of google-chrome bug, and some other reasons I can't use
>> >>> asm.js in my scripts. Currently I just replace "use asm"; to ""; For
>> >>> my case
>> >>> is very important to reduce js size as much as possible. If I revert
>> >>> all
>> >>> asm.js stuff (type declarations and etc.) to plain js, how do you
>> >>> think how
>> >>> much size I can reduce?
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google
>> >>> Groups
>> >>> "emscripten-discuss" group.
>> >>> To unsubscribe from this group and stop receiving emails from it, send
>> >>> an
>> >>> email to emscripten-discuss+unsubscr...@googlegroups.com.
>> >>> For more options, visit https://groups.google.com/d/optout.
>> >>
>> >>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "emscripten-discuss" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to emscripten-discuss+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: asm.js size overhead

2017-10-23 Thread Floh
I don't know why the .mem files have that extension, I just rename them to 
.mem.txt afterwards for the same effect. If you have control over your web 
server config that's not an issue though. Only with github and other 
hosting solution you have no full control over.

I'm tending towards moving the mem files back into the asm.js file anyway 
though, my demos usually have small static data, so the separate download 
isn't worth it.

Cheers,
-Floh.

Am Montag, 23. Oktober 2017 19:45:42 UTC+2 schrieb caiiiycuk:
>
> Thank you :) I see that asm.js do not produce much overhead. Floh, 
> thank you for great article, btw why mem file have mem extension, not 
> mem.js? For my projects I rename this file to mem.js (and replace all 
> occurrences in js) to get auto gzip features, etc. 
>
> 2017-10-19 0:03 GMT+07:00 Charles Vaughn : 
>
> > You could get rid of the |0 on HEAP[x]|0 and on constant expressions 
> (like 
> > u=u+32|0). 
> > 
> > You can also forward propagate the integer coercion to elide the 
> function 
> > preambles that coerce their parameters. An example would be taking 
> > 
> > function pG(a,b){a=a|0;b=b|0;return $FU(a,b,1217,4169,4177)|0} 
> > 
> > And converting it to 
> > function pG(a,b){return $FU(a|0,b|0,1217,4169,4177)|0} 
> > 
> > On Wednesday, October 18, 2017 at 8:29:56 AM UTC-7, Alon Zakai wrote: 
> >> 
> >> I agree with Floh that it probably won't help much on gzip size. Also 
> it 
> >> might make things slower (some variables might have undefined instead 
> of 0, 
> >> etc., so more types to track), and you'd need to be careful to only 
> remove 
> >> actually redundant things (some |0's are necessary). 
> >> 
> >> But you can test something close to this pretty easily, build with 
> >> --closure 2 which will run closure advanced on the asm.js code. That 
> should 
> >> remove obviously-redundant asm.js things. 
> >> 
> >> On Tue, Oct 17, 2017 at 10:58 PM, caiiiycuk  wrote: 
> >>> 
> >>> Hi. Beacuse of google-chrome bug, and some other reasons I can't use 
> >>> asm.js in my scripts. Currently I just replace "use asm"; to ""; For 
> my case 
> >>> is very important to reduce js size as much as possible. If I revert 
> all 
> >>> asm.js stuff (type declarations and etc.) to plain js, how do you 
> think how 
> >>> much size I can reduce? 
> >>> 
> >>> -- 
> >>> You received this message because you are subscribed to the Google 
> Groups 
> >>> "emscripten-discuss" group. 
> >>> To unsubscribe from this group and stop receiving emails from it, send 
> an 
> >>> email to emscripten-discuss+unsubscr...@googlegroups.com . 
>
> >>> For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "emscripten-discuss" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to emscripten-discuss+unsubscr...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: asm.js size overhead

2017-10-23 Thread Александр Гурьянов
Thank you :) I see that asm.js do not produce much overhead. Floh,
thank you for great article, btw why mem file have mem extension, not
mem.js? For my projects I rename this file to mem.js (and replace all
occurrences in js) to get auto gzip features, etc.

2017-10-19 0:03 GMT+07:00 Charles Vaughn :
> You could get rid of the |0 on HEAP[x]|0 and on constant expressions (like
> u=u+32|0).
>
> You can also forward propagate the integer coercion to elide the function
> preambles that coerce their parameters. An example would be taking
>
> function pG(a,b){a=a|0;b=b|0;return $FU(a,b,1217,4169,4177)|0}
>
> And converting it to
> function pG(a,b){return $FU(a|0,b|0,1217,4169,4177)|0}
>
> On Wednesday, October 18, 2017 at 8:29:56 AM UTC-7, Alon Zakai wrote:
>>
>> I agree with Floh that it probably won't help much on gzip size. Also it
>> might make things slower (some variables might have undefined instead of 0,
>> etc., so more types to track), and you'd need to be careful to only remove
>> actually redundant things (some |0's are necessary).
>>
>> But you can test something close to this pretty easily, build with
>> --closure 2 which will run closure advanced on the asm.js code. That should
>> remove obviously-redundant asm.js things.
>>
>> On Tue, Oct 17, 2017 at 10:58 PM, caiiiycuk  wrote:
>>>
>>> Hi. Beacuse of google-chrome bug, and some other reasons I can't use
>>> asm.js in my scripts. Currently I just replace "use asm"; to ""; For my case
>>> is very important to reduce js size as much as possible. If I revert all
>>> asm.js stuff (type declarations and etc.) to plain js, how do you think how
>>> much size I can reduce?
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to emscripten-discuss+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: asm.js size overhead

2017-10-18 Thread Charles Vaughn
You could get rid of the |0 on HEAP[x]|0 and on constant expressions 
(like u=u+32|0).

You can also forward propagate the integer coercion to elide the function 
preambles that coerce their parameters. An example would be taking

function pG(a,b){a=a|0;b=b|0;return $FU(a,b,1217,4169,4177)|0}

And converting it to
function pG(a,b){return $FU(a|0,b|0,1217,4169,4177)|0}

On Wednesday, October 18, 2017 at 8:29:56 AM UTC-7, Alon Zakai wrote:
>
> I agree with Floh that it probably won't help much on gzip size. Also it 
> might make things slower (some variables might have undefined instead of 0, 
> etc., so more types to track), and you'd need to be careful to only remove 
> actually redundant things (some |0's are necessary).
>
> But you can test something close to this pretty easily, build with 
> --closure 2 which will run closure advanced on the asm.js code. That should 
> remove obviously-redundant asm.js things.
>
> On Tue, Oct 17, 2017 at 10:58 PM, caiiiycuk  > wrote:
>
>> Hi. Beacuse of google-chrome bug, and some other reasons I can't use 
>> asm.js in my scripts. Currently I just replace "use asm"; to ""; For my 
>> case is very important to reduce js size as much as possible. If I revert 
>> all asm.js stuff (type declarations and etc.) to plain js, how do you think 
>> how much size I can reduce?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to emscripten-discuss+unsubscr...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: asm.js size overhead

2017-10-18 Thread Alon Zakai
I agree with Floh that it probably won't help much on gzip size. Also it
might make things slower (some variables might have undefined instead of 0,
etc., so more types to track), and you'd need to be careful to only remove
actually redundant things (some |0's are necessary).

But you can test something close to this pretty easily, build with
--closure 2 which will run closure advanced on the asm.js code. That should
remove obviously-redundant asm.js things.

On Tue, Oct 17, 2017 at 10:58 PM, caiiiycuk  wrote:

> Hi. Beacuse of google-chrome bug, and some other reasons I can't use
> asm.js in my scripts. Currently I just replace "use asm"; to ""; For my
> case is very important to reduce js size as much as possible. If I revert
> all asm.js stuff (type declarations and etc.) to plain js, how do you think
> how much size I can reduce?
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: asm.js size overhead

2017-10-18 Thread Floh
I doubt that it would make any difference in size to use asm.js or not. 

WebAssembly is a bit smaller (about 10% when measuring the compressed size, 
which is the only number that matters, asm.js is much less dense, but also 
compresses much better than WASM).

I got an emscripten "hello world" down to 16 KByte compressed without 
"hacks", and a minimal WebGL demo to about 33 KByte. These numbers are for 
plain C code, C++ is a bit trickier.

Everything on top of those about 10..50 KByte overhead caused by the C or 
C++ runtime lib and emscripten JS wrapper depends on how "bloated" your 
C/C++ code is. 

Using a lot of dynamic dispatch calls (virtual methods or jump tables) 
makes it hard for the compiler to remove unused code, using C++ iostream 
adds a lot of size overhead (about 100 KByte), using alot of complex 
template code will also add a lot of size, etc etc...

I wrote a blog post about the topic a while ago: 
http://floooh.github.io/2016/08/27/asmjs-diet.html

The TL;DR is: emscripten-generated code can be small if you're very careful 
what code you feed it, you basically need to embrace embedded-style 
programming, since embedded programming is these days about the only 
programming style which cares about avoiding code bloat.

Cheers,
-Floh.

Am Mittwoch, 18. Oktober 2017 05:58:31 UTC schrieb caiiiycuk:
>
> Hi. Beacuse of google-chrome bug, and some other reasons I can't use 
> asm.js in my scripts. Currently I just replace "use asm"; to ""; For my 
> case is very important to reduce js size as much as possible. If I revert 
> all asm.js stuff (type declarations and etc.) to plain js, how do you think 
> how much size I can reduce?
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.