Gabriel: very interesting, thanks! Great to see that this works out of the box, and that -O2/-O3 run at full speed.
Probably the Os/Oz differences are due to inlining. Binaryen is very cautious to not increase code size when the flags say to focus on code size, see https://github.com/WebAssembly/binaryen/issues/2144 So I am guessing -O2/-O3 inlining something important there at link time, at the cost of increased code size. I'll be doing some more optimizations on Asyncify, which will hopefully help with the 50% code size increase. But without a whitelist the benefits may be limited, so we may need do that eventually. - Alon On Sun, Jul 21, 2019 at 11:40 PM Gabriel CV <[email protected]> wrote: > Hi! > > I did some tests with the new Upstream/Asyncify feature (ie. "Bysyncify") > on the Doom 3 port. > > I am using Chrome 75/Ubuntu 18.04/nVidia binary drivers, and used the > "timedemo demo1" command to measure the FPS (not available on the D3 demo > though, too bad. I had to do this with the full version of the game). > > The good news: UPSTREAM/ASYNCIFY is working well! And easier to use than > Emterpreter. However there is a catch on the final wasm size. Here are the > raw results: > > TARGET FPS SIZE (MB) > O2/FASTCOMP/EMTERPRETER 50 4,55 MB (for reference. NB: I > am using whitelisting feature on EMTERPRETER) > O2/UPSTREAM/ASYNCIFY 50 6,81 MB > O2/UPSTREAM (no Asyncify) 50 3,90 MB > O3/UPSTREAM/ASYNCIFY 51 6,96 MB > Os/UPSTREAM/ASYNCIFY 41 5,56 MB > Oz/UPSTREAM/ASYNCIFY 40 5,56 MB > > What to read from these numbers: > - Performance > -- FASTCOMP/EMTERPRETER and UPSTREAM/ASYNCIFY have a similar performance > profile: with O2 optimization, there 50 FPS on average for both targets. > -- ASYNCIFY have no impact on performance: with O2 optimization, there is > 50 FPS on average with and without for both targets (NB: on the D3 port, I > really tried to 'yield' as few as possible) > -- There is however an important gap between Os/Oz and O2/O3: using Os > lead to a 20% performance hit comparted to O2 (50 FPS with O2/O3 => 40 FPS > with Os/Oz) > -- O3 compared to O2 does not bring significant performance improvement > -- Same thing for Oz compared to Os: both are almost the same > > - Binary size > -- UPSTREAM/ASYNCIFY do have a big impact on final binary size: this > roughly a +50% increase (from 4,55 MB with O2/FASTCOMP/EMTERPRETER => 6,81 > MB with O2/UPSTREAM/ASYNCIFY) > -- It is really the ASYNCIFY that cause this binary size increase, as > without ASYNCIFY, UPSTREAM produce a binary that is 15% smaller than > FASTCOMP (from 4,55 MB with FASTCOMP/EMTERPRETER => 3,90 MB with UPSTREAM) > -- Using Os compared to O2 brings a binary size improvement (from 6,81 MB > with O2 => 5,56 MB with Os), but this does not match with FASTCOMP (4,55 > MB) > -- Oz compared to Os does not bring significant binary size improvement > > So, all in all, my observation is that ASYNCIFY works well, but the binary > size increase is not negligible (+50%). > Using Os/Oz instead of O2/O3 allow to reduce that overhead to some extent, > but it is at the expense of a 20% performance hit (at least on the D3 > port), and not on par with the FASTCOMP binary size. > > As it appears it is really the Asyncify transformation that brings the > binary size increase, the whitelisting feature could really bring the best > of both world: > - By default (that is, without whitelisting): > - Ease of use of ASYNCIFY compared to EMTERPRETER (this works *by > default*, without having to do some extra work) > - No performance impact of using ASYNCIFY (at least, when using > yield/sleep carefully) > - Cons: +50% binary size > - With whitelisting: > - The binary size issue could be mitigated a lot, as UPSTREAM give > smaller binary size than FASTCOMP (-15% on D3) > - Cons: obviously, some work to do with whitelisting, but this is the > same as with EMTERPRETER > > Here it is! > > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/167d5725-0a84-4332-90c0-e6be6296dc78%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/167d5725-0a84-4332-90c0-e6be6296dc78%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpRZYAVdmHo-EQstN5KifpHZA%2BTR%3D%3D%2B0d%2BCRgdF9ht6vHA%40mail.gmail.com.
