Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Response to JavaScript/Emscripten Skinning Benchmarks by Chad Austin
# A response to
# http://chadaustin.me/2011/11/digging-into-javascript-performance-part-2/
# C++
$ g++ -Wall -O2 -o skinning_test_no_simd skinning_test_no_simd.cpp
$ ./skinning_test_no_simd
Skinned vertices per second: 19730000, blah=0.000000
# Unoptimized Emscripten
$ python tools/emmaken.py skinning_test_no_simd.cpp -o skinning.bc
$ python emscripten.py skinning_test_no_simd.bc > skinning.js
$ ~/Dev/mozilla-central/js/src/js -m -n skinning.js
Skinned vertices per second: 116279, blah=0.000000
# Optimized Emscripten
$ python tools/emmaken.py skinning_test_no_simd.cpp -o skinning.bc
$ python emscripten.py -s CORRECT_SIGNS=0 -s CORRECT_OVERFLOWS=0 -s CORRECT_ROUNDINGS=0 -s OPTIMIZE=1 -s RELOOP=1 -s QUANTUM_SIZE=1 -s USE_TYPED_ARRAYS=1 -s ASSERTIONS=0 -s INIT_STACK=0 --optimize skinning.bc > skinning.js
$ java -Xmx1024m -jar ~/Dev/closure-compiler-read-only/build/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js skinning.js --js_output_file skinning.opt.js --formatting PRETTY_PRINT
$ ~/Dev/mozilla-central/js/src/js -m -n skinning.opt.js
Skinned vertices per second: 2365269, blah=0.000000
# Ratios:
# C++ 1.00
# Optimized Emscripten 8.34
# Unoptimized Emscripten 169.68 (used in the link at the top of this doc)
#
# This is slower than other Emscripten benchmarks due to this test being
# heavy on memory operations, which tends to be an issue even with typed
# arrays. (A similar thing happens in the 'raytrace' benchmark in the
# Emscripten benchmark suite, which is the slowest benchmark there.)
#
# Note that there are plenty of obvious optimizations not done in the
# generated code. We are working on fixing that, but meanwhile some
# projects using Emscripten are hand-optimizing their inner loops,
# for example Broadway (of course hand-optimizing inner loops will
# probably help even with the best automatic optimizer).
#
# We realize that generating fully optimized code with Emscripten is
# not trivial (as can be seen by the options used above), and we will
# improve that. Meanwhile, see the makefiles in projects using
# Emscripten (ammo.js, j2k.js, Broadway, etc.) for concrete examples
# and also the docs in
# https://github.com/kripken/emscripten/wiki/Optimizing-Code
# (slightly outdated, the makefiles are current).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.