alpha123 Posted May 24, 2013 Report Share Posted May 24, 2013 I guess that's been covered a lot(couldn't find in forum search, though), and I'm very late there, but why not V8 js engine ( https://code.google.com/p/v8/ )?That would be much harder than simply upgrading SpiderMonkey.It would be a ton of work for no performance gain - SpiderMonkey is at least comparable with V8's performance these days, sometimes it is even faster.The code contains quite a lot of SpiderMonkey-specific synax (short lambdas, destructuring assignments, array comprehensions, etc).V8 does have far better docs though. Quote Link to comment Share on other sites More sharing options...
Yves Posted May 24, 2013 Author Report Share Posted May 24, 2013 I don't like it when people tell me to redo everything from scratch after writing tons of code .... no I'm just kidding, of course it's always good to talk about alternatives. There's a bigger community around than mozilla js afaik, lots of apps & docs & tutorial around (http://athile.net/li...ary/V8/Tutorial), nicer docsYes the docs are a problem but I've already used APIs that were a lot worse in that regard.and also has buitltin profiler/debugging capabilities. (even gdb support https://code.google....GDBJITInterface or with some work webkit/chrome dev tools like nodejs did here https://github.com/d.../node-inspector ).Spidermonkey also has some integrated profiling and debugging support. We even have a graphical interface.If I understand that GDB support correctly it just shows symbol names in the backgrace but it doesn't allow you to actually step through the JS code, right?Alpha123 has some good points. It would be a lot more work at the moment and both engines are developing well, so I wouldn't take performance into account at all. Maybe Spidermonkey's documentation will also improve in the future. Quote Link to comment Share on other sites More sharing options...
tuan kuranes Posted May 24, 2013 Report Share Posted May 24, 2013 Ok. got the point. now documented in forum why mozilla-js rather than v8.@alpha123agree. Just want to make sure alternatives are known/considered. Docs, support & community is a big part of reliable 3rd party library, better change soon than late and having more work to do when having to upgrade...Didn't know that js code could be SpiderMonkey-specific. Perhaps "Polyfills" (like es5/es6 polyfills) could perhaps help there?Not sure about same perf, as to my understanding that mozilla-js optimisation where mostly "tracing" (spotting and optimising hot-path) and v8 were more "compilation" (type inference) oriented@Yves: I know I'm late. Just wanted to be sure that alternative are considered (especially when hitting a wall)Yeah, GDB thing is just stack trace naming, still useful though, notably in Cpu profilers that get lost by js stack...My secret point is that mozilla-js is really a pain to get running, especially under win64... still didn't succeed here (would like to be able to release 64bits exe, much faster, notably on the fixed sqrt calls...) Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted May 24, 2013 Report Share Posted May 24, 2013 My secret point is that mozilla-js is really a pain to get running, especially under win64... still didn't succeed here (would like to be able to release 64bits exe, much faster, notably on the fixed sqrt calls...)That would be nice to have, in fact building most of the libraries on Windows is a pain We've discussed a few times setting up VC++ projects for them and having the source code in an SVN repo somewhere (part of the ongoing Git migration), so it would be simple[r] to build them with new compilers.Does this help? https://developer.mozilla.org/en-US/docs/SpiderMonkey/Build_Documentation#Specifying_compilers_and_compiler_flagsTo build a 64-bit Windows version, you can use the following:$SRC/configure --host=x86_64-pc-mingw32 --target=x86_64-pc-mingw32Note: You must have started your MozillaBuild shell with the proper -x64.bat script in order for the 64-bit compilers to be in your PATH.(assuming it applies to 1.8.5) Quote Link to comment Share on other sites More sharing options...
alpha123 Posted May 24, 2013 Report Share Posted May 24, 2013 agree. Just want to make sure alternatives are known/considered. Docs, support & community is a big part of reliable 3rd party library, better change soon than late and having more work to do when having to upgrade...You have good points. I really, really wish the SpiderMonkey docs/support/community was better. The library itself is excellent though. (Well, at least performace/feature wise.)Didn't know that js code could be SpiderMonkey-specific. Perhaps "Polyfills" (like es5/es6 polyfills) could perhaps help there?You can't really polyfill this:[n * n for each (n in [1, 2, 3, 4, 5])].map(function n + 1) // [2, 5, 10, 17, 26]contrived example, but demonstrates some (but not nearly all) of the SpiderMonkey-specific syntax.Not sure about same perf, as to my understanding that mozilla-js optimisation where mostly "tracing" (spotting and optimising hot-path) and v8 were more "compilation" (type inference) orientedSpiderMonkey doesn't use a tracing JIT anymore, they use a method JIT (like V8) combined with a powerful type inference and optimization engine. I wish they had put more effort into TraceMonkey personally; IMO tracing JITs are superior to method JITs. Just look at LuaJIT (an insanely fast tracing JIT compiler). Quote Link to comment Share on other sites More sharing options...
Yves Posted May 25, 2013 Author Report Share Posted May 25, 2013 I've compared v1.8.5 and v17 using sunspider.How I did the tests (also the same for the sunspider-1.0 suite):svn checkout http://svn.webkit.org/repository/webkit/trunk/PerformanceTests/SunSpidercd SunSpider./sunspider --args='"-m -n"' --shell=/home/yves/Projekte/0ad_original_trunk/libraries/source/spidermonkey/js-1.8.5/js/src/build-release/shell/js --run=30 --suite=v8-v6./sunspider --args="-m -n" --shell=/home/yves/Projekte/0ad_spidermonkey1_trunk/libraries/source/spidermonkey/mozjs17/js/src/build-release/shell/js --run=30 --suite=v8-v6./sunspider-compare-results --shell=/home/yves/Projekte/0ad_spidermonkey1_trunk/libraries/source/spidermonkey/mozjs17/js/src/build-release/shell/js --suite=v8-v6 v8-v6-results/sunspider-results-2013-05-25-16.58.04.js v8-v6-results/sunspider-results-2013-05-25-16.59.41.js | geditThe results of the sunspider-1.0 benchmark:TEST COMPARISON FROM TO DETAILS===============================================================================** TOTAL **: 1.21x as fast 340.8ms +/- 0.3% 280.5ms +/- 0.3% significant=============================================================================== 3d: 1.098x as fast 54.3ms +/- 1.4% 49.5ms +/- 1.5% significant cube: 1.065x as fast 20.2ms +/- 3.9% 18.9ms +/- 4.0% significant morph: 1.42x as fast 15.2ms +/- 0.4% 10.7ms +/- 1.3% significant raytrace: *1.048x as slow* 19.0ms +/- 0.8% 19.9ms +/- 0.3% significant access: 2.35x as fast 54.1ms +/- 0.1% 23.0ms +/- 0.2% significant binary-trees: 2.18x as fast 6.2ms +/- 0.5% 2.8ms +/- 0.4% significant fannkuch: 2.26x as fast 22.6ms +/- 0.1% 10.0ms +/- 0.1% significant nbody: 2.74x as fast 15.5ms +/- 0.1% 5.7ms +/- 0.2% significant nsieve: 2.18x as fast 9.8ms +/- 0.3% 4.5ms +/- 0.3% significant bitops: 1.57x as fast 33.7ms +/- 0.2% 21.5ms +/- 0.4% significant 3bit-bits-in-byte: 2.33x as fast 3.0ms +/- 0.4% 1.3ms +/- 0.7% significant bits-in-byte: 1.62x as fast 11.5ms +/- 0.1% 7.1ms +/- 0.7% significant bitwise-and: 1.42x as fast 9.2ms +/- 0.6% 6.5ms +/- 1.0% significant nsieve-bits: 1.51x as fast 10.0ms +/- 0.0% 6.6ms +/- 0.2% significant controlflow: 1.164x as fast 3.4ms +/- 0.1% 2.9ms +/- 0.2% significant recursive: 1.164x as fast 3.4ms +/- 0.1% 2.9ms +/- 0.2% significant crypto: *1.191x as slow* 23.4ms +/- 0.3% 27.8ms +/- 0.3% significant aes: *1.178x as slow* 12.2ms +/- 0.2% 14.4ms +/- 0.2% significant md5: *1.42x as slow* 6.4ms +/- 0.8% 9.0ms +/- 0.7% significant sha1: 1.080x as fast 4.8ms +/- 0.3% 4.4ms +/- 0.3% significant date: *1.189x as slow* 30.4ms +/- 1.0% 36.2ms +/- 0.4% significant format-tofte: *1.142x as slow* 18.2ms +/- 0.8% 20.8ms +/- 0.4% significant format-xparb: *1.26x as slow* 12.2ms +/- 1.8% 15.4ms +/- 0.7% significant math: 1.72x as fast 45.2ms +/- 0.2% 26.3ms +/- 0.2% significant cordic: 2.54x as fast 15.0ms +/- 0.4% 5.9ms +/- 0.4% significant partial-sums: 1.32x as fast 20.1ms +/- 0.3% 15.2ms +/- 0.2% significant spectral-norm: 1.93x as fast 10.1ms +/- 1.0% 5.2ms +/- 0.3% significant regexp: *1.009x as slow* 18.3ms +/- 0.3% 18.5ms +/- 0.2% significant dna: *1.009x as slow* 18.3ms +/- 0.3% 18.5ms +/- 0.2% significant string: 1.042x as fast 77.9ms +/- 0.1% 74.8ms +/- 0.3% significant base64: 1.52x as fast 9.0ms +/- 0.3% 5.9ms +/- 0.3% significant fasta: 1.51x as fast 15.6ms +/- 0.3% 10.3ms +/- 0.3% significant tagcloud: *1.048x as slow* 21.6ms +/- 0.3% 22.6ms +/- 0.7% significant unpack-code: *1.20x as slow* 22.5ms +/- 0.2% 27.0ms +/- 0.3% significant validate-input: 1.039x as fast 9.3ms +/- 0.3% 9.0ms +/- 0.4% significantAnd the v8-v6 benchmark:TEST COMPARISON FROM TO DETAILS===============================================================================** TOTAL **: 1.84x as fast 2220.2ms +/- 0.3% 1208.5ms +/- 0.3% significant=============================================================================== v8: 1.84x as fast 2220.2ms +/- 0.3% 1208.5ms +/- 0.3% significant crypto: 2.81x as fast 395.3ms +/- 0.3% 140.7ms +/- 0.4% significant deltablue: 2.70x as fast 457.5ms +/- 1.1% 169.4ms +/- 0.9% significant earley-boyer: 1.71x as fast 254.6ms +/- 0.7% 148.6ms +/- 0.6% significant raytrace: - 137.0ms +/- 0.5% 136.0ms +/- 1.5% regexp: 1.089x as fast 349.1ms +/- 0.7% 320.5ms +/- 0.3% significant richards: 2.02x as fast 432.3ms +/- 0.1% 214.5ms +/- 0.4% significant splay: 2.47x as fast 194.4ms +/- 0.5% 78.7ms +/- 0.4% significantMy conclusions are:V17 is generally faster and these are my own builds, so it can't simply be a problem of wrong build settingsThe two test suites give very different results (1.21x compared to 1.84x) and in some of the tests v1.8.5 is faster. Taking into account that these are the same benchmarks the Mozilla guys use (and the engine is therefore specially optimized to produce good benchmark results), it seems to be possible that our code simply runs slower with version 17 because it does things that spidermonkey handles worse in the newer version.I still don't know if there is an issue about how we are embedding Spidermonkey or if it's normal that v17 runs slower in our case.EDIT: New idea, new challenge. Maybe I can isolate some parts of code that run slower and write a Sunspider test for it.This way I could test it easily with newer versions of Spidermonkey and probably fill a bug for Spidermonkey if it's slower there too. Quote Link to comment Share on other sites More sharing options...
Yves Posted May 25, 2013 Author Report Share Posted May 25, 2013 I looked a bit closer at the random map alpine_lakes to see where the speed difference comes from.I figured out that there are about 2 seconds difference (in the configuration used for the tests posted on the previous page) in this loop.After replacing the Math.random() in randInt with 0.777 Spidermonkey 17 became faster than 1.8.5 (the total time is now different from the previous test because the random number has a big impact and changes the generated map):17TIMER| Load RMS: 13.5352 sTIMER| Load RMS: 13.7982 sTIMER| Load RMS: 13.5488 sTIMER| Load RMS: 13.6651 sTIMER| Load RMS: 13.4973 sTIMER| Load RMS: 13.4511 s1.8.5TIMER| LoadRMS: 14.1331 sTIMER| LoadRMS: 13.7393 sTIMER| LoadRMS: 13.7287 sTIMER| LoadRMS: 13.768 sTIMER| LoadRMS: 13.7408 sTIMER| LoadRMS: 13.8551 sThe difference is small but I think it seems to be relevant (especially because 17 was slower before).I suspect that JS_GetReservedSlot and JS_GetContextPrivate could be the problem. These are used from C++ to get a pointer to the network synchronized random number generator we use for replacing the default one (which is truely random and would break replays, and would generate different random maps with the same seed). The same functions for reserved slots are also used for many other functions to store pointers to objects. I'm going to test if I can prove a performance difference by writing a specific test for the JS_GetReservedSlot function. Quote Link to comment Share on other sites More sharing options...
wraitii Posted May 26, 2013 Report Share Posted May 26, 2013 Interesting bottleneck you found here. And great work so far, it's been a very interesting read! Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted May 26, 2013 Report Share Posted May 26, 2013 Just wondering,if it's a single player game, so randoms don't have to be synced, can't you use a native random function that's faster? And if you set a debug option, it could still switch to the deterministic random generator to warrant replays. It looks like a nice tradeoff. In single player, you have faster randoms, but the AI will always take a serious amout of cpu time, and in multiplayer, you have no AI slowdown, so a bit of margin for longer random creation. Quote Link to comment Share on other sites More sharing options...
Yves Posted May 26, 2013 Author Report Share Posted May 26, 2013 The random numbers aren't really a problem I think. I've just picked that as an example to figure out in which situations Spidermonkey 17 is slower.I'm picking the random map generation instead of the places where this really is a problem because it's easier to debug there. Hopefully it gives me some information that is useful in other cases too.I've checked JS_GetContextPrivate using Valgrind in the meantime and it shows 0.00% of the execution time in 62 000 calls. If that's correct, it isn't the bottleneck. Quote Link to comment Share on other sites More sharing options...
Yves Posted May 26, 2013 Author Report Share Posted May 26, 2013 I made another SunSpider benchmark with MethodJIT disabled.It shows that Spidermonkey 17 is significantly slower (half as fast) as Spidermonkey 1.8.5 in this case.I suspect that in the randInt method it falls back to interpreter mode because one argument of Math.floor is a random number that comes from C++ code and it's unknown for Spidermonkey what value this code will return and what type this value will have.That's just a guess though, I don't know enough Spidermonkey internals yet to be sure.The same problem could apply to other parts of code interacting with results returned from engine (C++) functions.With TypeInference enabled for Spidermonkey 17.TEST COMPARISON FROM TO DETAILS===============================================================================** TOTAL **: *1.97x as slow* 1475.5ms +/- 0.2% 2913.8ms +/- 1.0% significant=============================================================================== 3d: *1.98x as slow* 209.1ms +/- 0.5% 413.3ms +/- 0.9% significant cube: *1.56x as slow* 78.0ms +/- 1.0% 121.5ms +/- 0.6% significant morph: *2.40x as slow* 60.6ms +/- 0.6% 145.6ms +/- 2.0% significant raytrace: *2.07x as slow* 70.5ms +/- 0.7% 146.3ms +/- 0.8% significant access: *1.77x as slow* 345.4ms +/- 0.3% 610.6ms +/- 1.4% significant binary-trees: *2.35x as slow* 29.9ms +/- 0.3% 70.4ms +/- 0.5% significant fannkuch: *1.61x as slow* 185.7ms +/- 0.4% 299.1ms +/- 1.9% significant nbody: *2.04x as slow* 76.0ms +/- 0.8% 155.1ms +/- 1.1% significant nsieve: *1.60x as slow* 53.8ms +/- 1.4% 86.0ms +/- 1.2% significant bitops: *2.14x as slow* 285.2ms +/- 0.6% 609.8ms +/- 1.0% significant 3bit-bits-in-byte: *1.39x as slow* 48.2ms +/- 0.8% 67.1ms +/- 2.7% significant bits-in-byte: *1.118x as slow* 81.7ms +/- 0.9% 91.3ms +/- 1.5% significant bitwise-and: *4.69x as slow* 70.0ms +/- 0.7% 328.4ms +/- 0.6% significant nsieve-bits: *1.44x as slow* 85.3ms +/- 1.6% 122.9ms +/- 1.8% significant controlflow: *2.45x as slow* 34.2ms +/- 0.5% 83.9ms +/- 0.4% significant recursive: *2.45x as slow* 34.2ms +/- 0.5% 83.9ms +/- 0.4% significant crypto: *2.03x as slow* 124.5ms +/- 0.3% 252.9ms +/- 0.8% significant aes: *2.19x as slow* 51.3ms +/- 0.4% 112.3ms +/- 0.7% significant md5: *2.01x as slow* 35.2ms +/- 0.6% 70.6ms +/- 1.0% significant sha1: *1.84x as slow* 38.1ms +/- 0.4% 70.0ms +/- 1.1% significant date: *2.06x as slow* 69.6ms +/- 0.5% 143.2ms +/- 0.9% significant format-tofte: *2.04x as slow* 42.6ms +/- 0.4% 86.8ms +/- 0.5% significant format-xparb: *2.09x as slow* 27.0ms +/- 1.1% 56.4ms +/- 1.6% significant math: *1.91x as slow* 217.9ms +/- 0.5% 416.7ms +/- 1.1% significant cordic: *1.66x as slow* 106.5ms +/- 0.9% 177.1ms +/- 1.2% significant partial-sums: *2.31x as slow* 64.9ms +/- 0.3% 149.7ms +/- 1.6% significant spectral-norm: *1.93x as slow* 46.5ms +/- 0.7% 89.9ms +/- 1.1% significant regexp: *1.010x as slow* 18.3ms +/- 0.3% 18.5ms +/- 0.2% significant dna: *1.010x as slow* 18.3ms +/- 0.3% 18.5ms +/- 0.2% significant string: *2.13x as slow* 171.3ms +/- 0.4% 364.9ms +/- 1.5% significant base64: *2.56x as slow* 31.6ms +/- 0.5% 80.7ms +/- 1.3% significant fasta: *2.29x as slow* 54.7ms +/- 1.0% 125.2ms +/- 2.2% significant tagcloud: *1.72x as slow* 33.7ms +/- 0.3% 58.0ms +/- 0.9% significant unpack-code: *1.49x as slow* 27.6ms +/- 0.5% 41.0ms +/- 1.1% significant validate-input: *2.53x as slow* 23.7ms +/- 0.5% 60.0ms +/- 1.3% significantWith TypeInference disabled for Spidermonkey 17:TEST COMPARISON FROM TO DETAILS===============================================================================** TOTAL **: *1.46x as slow* 1475.5ms +/- 0.2% 2147.5ms +/- 0.2% significant=============================================================================== 3d: *1.37x as slow* 209.1ms +/- 0.5% 287.5ms +/- 0.3% significant cube: *1.191x as slow* 78.0ms +/- 1.0% 92.9ms +/- 0.8% significant morph: *1.67x as slow* 60.6ms +/- 0.6% 101.4ms +/- 0.5% significant raytrace: *1.32x as slow* 70.5ms +/- 0.7% 93.2ms +/- 0.2% significant access: *1.33x as slow* 345.4ms +/- 0.3% 460.3ms +/- 0.6% significant binary-trees: *2.24x as slow* 29.9ms +/- 0.3% 67.0ms +/- 0.7% significant fannkuch: *1.182x as slow* 185.7ms +/- 0.4% 219.5ms +/- 0.9% significant nbody: *1.35x as slow* 76.0ms +/- 0.8% 102.6ms +/- 0.3% significant nsieve: *1.32x as slow* 53.8ms +/- 1.4% 71.2ms +/- 1.3% significant bitops: *1.68x as slow* 285.2ms +/- 0.6% 478.7ms +/- 0.4% significant 3bit-bits-in-byte: *1.179x as slow* 48.2ms +/- 0.8% 56.8ms +/- 0.7% significant bits-in-byte: *1.038x as slow* 81.7ms +/- 0.9% 84.7ms +/- 0.8% significant bitwise-and: *3.49x as slow* 70.0ms +/- 0.7% 244.2ms +/- 0.6% significant nsieve-bits: *1.089x as slow* 85.3ms +/- 1.6% 93.0ms +/- 0.6% significant controlflow: *1.60x as slow* 34.2ms +/- 0.5% 54.8ms +/- 1.1% significant recursive: *1.60x as slow* 34.2ms +/- 0.5% 54.8ms +/- 1.1% significant crypto: *1.36x as slow* 124.5ms +/- 0.3% 169.0ms +/- 0.4% significant aes: *1.37x as slow* 51.3ms +/- 0.4% 70.5ms +/- 0.9% significant md5: *1.38x as slow* 35.2ms +/- 0.6% 48.6ms +/- 0.6% significant sha1: *1.31x as slow* 38.1ms +/- 0.4% 49.9ms +/- 0.5% significant date: *1.38x as slow* 69.6ms +/- 0.5% 96.3ms +/- 0.8% significant format-tofte: *1.39x as slow* 42.6ms +/- 0.4% 59.2ms +/- 1.1% significant format-xparb: *1.37x as slow* 27.0ms +/- 1.1% 37.1ms +/- 0.7% significant math: *1.46x as slow* 217.9ms +/- 0.5% 318.3ms +/- 0.4% significant cordic: *1.33x as slow* 106.5ms +/- 0.9% 141.6ms +/- 0.5% significant partial-sums: *1.73x as slow* 64.9ms +/- 0.3% 112.3ms +/- 0.8% significant spectral-norm: *1.39x as slow* 46.5ms +/- 0.7% 64.5ms +/- 0.7% significant regexp: *1.009x as slow* 18.3ms +/- 0.3% 18.4ms +/- 0.2% significant dna: *1.009x as slow* 18.3ms +/- 0.3% 18.4ms +/- 0.2% significant string: *1.54x as slow* 171.3ms +/- 0.4% 264.2ms +/- 0.3% significant base64: *1.86x as slow* 31.6ms +/- 0.5% 58.6ms +/- 0.5% significant fasta: *1.63x as slow* 54.7ms +/- 1.0% 89.3ms +/- 0.6% significant tagcloud: *1.30x as slow* 33.7ms +/- 0.3% 43.8ms +/- 0.7% significant unpack-code: *1.187x as slow* 27.6ms +/- 0.5% 32.8ms +/- 2.1% significant validate-input: *1.67x as slow* 23.7ms +/- 0.5% 39.7ms +/- 0.5% significant Quote Link to comment Share on other sites More sharing options...
scroogie Posted May 30, 2013 Report Share Posted May 30, 2013 Just out of curiosity, can't you compile some functions manually? In the examples, I found this: https://developer.mozilla.org/en-US/docs/SpiderMonkey/JSAPI_User_Guide#Compiled_scripts Quote Link to comment Share on other sites More sharing options...
Yves Posted May 30, 2013 Author Report Share Posted May 30, 2013 Just out of curiosity, can't you compile some functions manually? In the examples, I found this: https://developer.mo...ompiled_scriptsCompiling means bytecode compilation in this context which is not the same as JIT-compiling. When I'm talking about interpreter-mode I mean executing bytecode compiled code instead of JIT-compiled code.JIT-compiled code is further optimized. It can be JIT-compiled with JaegerMonkey or with IonMonkey which is available since V18 (so IonMonkey is not involved in the benchmarks posted in this thread because I'm using version 17).JaegerMonkey has a relatively small overhead for compiling but the code is less well optimized than code JIT-compiled using IonMonkey. This confused me too in the beginning and I hope I could clear that up a bit...I've asked if JIT-compilation can be done manually here.The answer was that this is not possible but if you refer to the graph I posted here, you see that this is not really necessary because the compilation overhead is relatively small. I'm trying to figure out which parts of code are run in interpreter mode and why, but I need a few more hours for that. Quote Link to comment Share on other sites More sharing options...
Yves Posted May 30, 2013 Author Report Share Posted May 30, 2013 Here are some JIT statistics generated using getPCCountScriptSummary.I'm not yet sure what to do with it because I can only guess what these values mean (or dive deep into the Spidermonkey sourcecode).{file:maps/random/rmgen/tileclass.jsline:33name:RangeOp.gettotals:{mjit:632478063mjit_calls:12801440mjit_code:182814883720mjit_pics:832092560infer_poly:320608662infer_nobarrier:54230321observe_int32:279179765observe_double:3024625observe_object:38404272id_unknown:12801424elem_other:12801424prop_other:28627473arith_double:49034454arith_unknown:142706585}}{file:maps/random/rmgen/tileclass.jsline:86name:TileClass.addtotals:{mjit:124019mjit_calls:41mjit_code:43368701mjit_pics:654702infer_poly:75051infer_nobarrier:43713observe_int32:40837observe_double:15observe_object:34199id_unknown:26646elem_other:26646prop_other:18530arith_double:4757arith_unknown:9514}}{file:maps/random/rmgen/tileclass.jsline:105name:TileClass.countInRadiustotals:{mjit:228563040mjit_calls:12144848mjit_code:70984882285mjit_pics:1028498109infer_poly:128065770infer_nobarrier:33462594observe_boolean:99063observe_int32:88520486observe_double:6082690observe_object:33363531id_unknown:3024625elem_other:3024625prop_other:18293141arith_double:12044536arith_unknown:39664542}}{file:maps/random/rmgen/tileclass.jsline:141name:TileClass.countMembersInRadiustotals:{interp:20mjit:594366mjit_calls:4mjit_code:209712137mjit_pics:6934200infer_poly:396244infer_nobarrier:99061observe_int32:296979observe_double:204observe_object:99061prop_other:99061}}{file:maps/random/rmgen/terrain.jsline:10name:Terrain.placetotals:{mjit:57084mjit_calls:16mjit_code:22134321mjit_pics:946577infer_poly:42813infer_nobarrier:23785observe_undefined:4757observe_int32:19012observe_double:16observe_object:19028id_unknown:9514elem_other:9514prop_other:9514}}{file:maps/random/rmgen/terrain.jsline:31name:SimpleTerraintotals:{mjit:540mjit_calls:186mjit_code:124860mjit_pics:26060infer_poly:240infer_nobarrier:60observe_undefined:120observe_string:120prop_other:120arith_unknown:60}}{file:maps/random/rmgen/terrain.jsline:44name:SimpleTerrain.placeNewtotals:{mjit:71355mjit_calls:4780mjit_code:26429892mjit_pics:1274806infer_poly:47570infer_nobarrier:38056observe_undefined:9514observe_int32:9506observe_double:8observe_string:4757observe_object:23785id_unknown:9514elem_other:9514prop_other:19028arith_unknown:4757}}{file:maps/random/rmgen/terrain.jsline:63name:RandomTerraintotals:{mjit:360mjit_calls:39mjit_code:84480mjit_pics:8410infer_poly:150infer_nobarrier:60observe_int32:30observe_object:120prop_other:60arith_other:30arith_unknown:30}}{file:maps/random/rmgen/terrain.jsline:75name:RandomTerrain.placeNewtotals:{mjit:52327mjit_calls:12mjit_code:21016426mjit_pics:623101infer_poly:38056infer_nobarrier:28542observe_int32:14263observe_double:8observe_object:23785id_unknown:4757elem_other:4757prop_other:19028}}{file:maps/random/rmgen/tileclass.jsline:24name:RangeOp.addtotals:{mjit:472065mjit_calls:22899mjit_code:141313373mjit_pics:1487720infer_poly:234602infer_nobarrier:94413observe_int32:163077observe_double:2861observe_object:68664id_unknown:45776elem_other:45776prop_other:48637arith_double:71525arith_unknown:45776}}{file:maps/random/rmgen/point.jsline:8name:PointXZtotals:{mjit:659910mjit_calls:131990mjit_code:141132752mjit_pics:17245392infer_poly:263964infer_nobarrier:87988observe_undefined:87988observe_int32:175822observe_double:154prop_other:87988arith_unknown:87988}}{file:maps/random/rmgen/random.jsline:12name:getRndtotals:{mjit:83300mjit_calls:13mjit_code:17297000mjit_pics:3472600infer_poly:29400infer_nobarrier:29400observe_int32:19600observe_double:4900observe_object:4900id_unknown:4900elem_other:4900arith_double:19600arith_unknown:4900}}{file:maps/random/rmgen/random.jsline:27name:randFloattotals:{mjit:2075mjit_calls:502mjit_code:654123mjit_pics:11039infer_mono:166infer_poly:1079infer_nobarrier:581observe_int32:664observe_object:332id_int:166elem_other:166prop_other:249arith_double:249arith_unknown:249}}{file:maps/random/rmgen/random.jsline:76name:randInt2totals:{mjit:540mjit_calls:4mjit_code:139380mjit_pics:7888infer_poly:240infer_nobarrier:60observe_int32:180observe_object:60arith_double:60arith_unknown:120}}{file:maps/random/rmgen/random.jsline:81name:randInt1totals:{mjit:38536mjit_calls:4825mjit_code:11445192mjit_pics:1280790infer_poly:19268infer_nobarrier:14451observe_int32:4817observe_object:14451prop_other:4817arith_unknown:4817}}{file:maps/random/rmgen/painter.jsline:48name:LayeredPaintertotals:{interp:217mjit:504mjit_calls:63mjit_code:163181mjit_pics:4996infer_poly:283infer_nobarrier:142observe_int32:94observe_object:189id_unknown:24elem_other:24prop_other:106arith_double:24arith_other:11arith_unknown:35}}{file:maps/random/rmgen/painter.jsline:64name:LayeredPainter.painttotals:{mjit:3497292mjit_calls:16927mjit_code:1191853027mjit_pics:21310902infer_poly:2097009infer_nobarrier:827715observe_int32:1357019observe_double:661observe_object:739329id_unknown:360592elem_other:360592prop_other:269744arith_double:318488arith_unknown:303693}}{file:maps/random/rmgen/painter.jsline:160name:MultiPaintertotals:{interp:75}}{file:maps/random/rmgen/painter.jsline:165name:MultiPainter.painttotals:{interp:272mjit:168mjit_calls:12mjit_code:61752mjit_pics:2157infer_poly:108infer_nobarrier:68observe_int32:44observe_object:64id_unknown:12elem_other:12prop_other:56arith_double:12arith_unknown:16}}{file:maps/random/rmgen/painter.jsline:186name:SmoothElevationPaintertotals:{interp:270}}{file:maps/random/rmgen/painter.jsline:198name:SmoothElevationPainter.checkInAreatotals:{interp:730mjit:3821121mjit_calls:458mjit_code:1408901783mjit_pics:47904276infer_poly:2557606infer_nobarrier:1395036observe_int32:1394174observe_double:862observe_object:1162570id_unknown:464932elem_other:464932prop_other:465052arith_double:201590arith_unknown:232466}}{file:maps/random/rmgen/painter.jsline:209name:SmoothElevationPainter.painttotals:{interp:636mjit:7913563mjit_calls:29528mjit_code:2517176030mjit_pics:49818653infer_poly:4390153infer_nobarrier:1308756observe_int32:2924550observe_double:125999observe_object:1339604id_unknown:508945elem_other:508945prop_other:532862arith_double:859623arith_unknown:639107}}{file:maps/random/rmgen/painter.jsline:400name:TileClassPaintertotals:{interp:75}}{file:maps/random/rmgen/painter.jsline:405name:TileClassPainter.painttotals:{interp:373mjit:80671mjit_calls:15mjit_code:31342880mjit_pics:331870infer_poly:56939infer_nobarrier:28466observe_int32:23726observe_double:5observe_object:33208id_unknown:4742elem_other:4742prop_other:23724arith_double:4742arith_unknown:4749}}{file:maps/random/rmgen/pathplacer.jsline:19name:PathPlacertotals:{interp:675}}{file:maps/random/rmgen/pathplacer.jsline:33name:PathPlacer.placetotals:{interp:335mjit:4872377mjit_calls:124189mjit_code:1690918961mjit_pics:5191708infer_poly:2956366infer_nobarrier:976680observe_undefined:7observe_int32:1279541observe_double:531451observe_object:1145367id_int:44094id_unknown:83354elem_other:127448prop_other:802999arith_double:209388arith_unknown:1059239}}{file:maps/random/rmgen/pathplacer.jsline:148name:PathPlacer.place/tri<totals:{interp:96mjit:222000mjit_calls:4mjit_code:80364000infer_poly:148000infer_nobarrier:74000observe_int32:73912observe_double:88observe_object:74000prop_other:74000arith_unknown:37000}}{file:maps/random/rmgen/pathplacer.jsline:155name:PathPlacer.place/fillLinetotals:{interp:706mjit:4224619mjit_calls:332048mjit_code:1460123114mjit_pics:53396917infer_poly:2669182infer_nobarrier:1329844observe_int32:1215763observe_double:222384observe_object:1231035id_unknown:188990elem_other:188990prop_other:516458arith_double:112493arith_unknown:278527}}{file:maps/random/rmgen/map.jsline:218name:Map.createAreatotals:{mjit:86197mjit_calls:90mjit_code:38149627mjit_pics:10354infer_poly:66903infer_nobarrier:33413observe_undefined:29observe_int32:33326observe_double:5observe_object:33543id_unknown:19028elem_other:19028prop_other:19075arith_double:4765arith_unknown:4818}}{file:maps/random/rmgen/library.jsline:530name:avoidClassestotals:{interp:360mjit:342mjit_calls:82mjit_code:114165mjit_pics:1224infer_mono:9infer_poly:189infer_nobarrier:81observe_int32:99observe_object:63id_int:9id_unknown:27elem_other:36prop_other:36arith_double:72arith_unknown:18}}{file:maps/random/rmgen/map.jsline:83name:Map.getTextureIDtotals:{mjit:38080mjit_calls:4781mjit_code:13695126mjit_pics:1693819infer_poly:23803infer_nobarrier:14277observe_int32:4766observe_string:9517observe_object:9520id_unknown:4760elem_other:4760prop_other:9523}}{file:maps/random/rmgen/map.jsline:105name:Map.validTtotals:{mjit:128466mjit_calls:16483mjit_code:37330902mjit_pics:1110078infer_poly:65880infer_nobarrier:32940observe_undefined:6588observe_boolean:3294observe_int32:32925observe_double:15observe_object:23058prop_other:16470arith_double:6588arith_unknown:23058}}{file:maps/random/rmgen/map.jsline:124name:Map.inMapBoundstotals:{mjit:5833670mjit_calls:4mjit_code:1472817870infer_poly:2499812infer_nobarrier:833080observe_int32:2498221observe_double:1591prop_other:833080arith_double:833652arith_unknown:833080}}{file:maps/random/rmgen/map.jsline:130name:Map.validHtotals:{interp:368mjit:4337159mjit_calls:5mjit_code:1097266514mjit_pics:18434800infer_poly:1897448infer_nobarrier:813174observe_boolean:271100observe_int32:1625691observe_double:657prop_other:542074arith_double:542200arith_unknown:542074}}{file:maps/random/rmgen/map.jsline:143name:Map.validClasstotals:{mjit:240mjit_calls:3mjit_code:69330infer_poly:120infer_nobarrier:60observe_int32:90observe_object:30prop_other:60arith_double:30arith_unknown:30}}{file:maps/random/rmgen/library.jsline:294name:createTerraintotals:{mjit:1770mjit_calls:109mjit_code:561780mjit_pics:31204infer_poly:990infer_nobarrier:450observe_int32:240observe_string:180observe_object:570id_unknown:60elem_other:60prop_other:150arith_double:60arith_unknown:90}}{file:maps/random/rmgen/library.jsline:313name:createSimpleTerraintotals:{mjit:840mjit_calls:68mjit_code:258420mjit_pics:15428infer_poly:480infer_nobarrier:240observe_int32:60observe_string:240observe_object:180prop_other:120arith_double:60}}{file:maps/random/rmgen/library.jsline:360name:getTileClasstotals:{mjit:330mjit_calls:10mjit_code:115770mjit_pics:9918infer_poly:210infer_nobarrier:150observe_int32:60observe_object:150id_unknown:30elem_other:30prop_other:60arith_unknown:30}}{file:maps/random/rmgen/library.jsline:371name:createAreatotals:{interp:126mjit:7mjit_calls:3mjit_code:2547mjit_pics:68infer_poly:5infer_nobarrier:2observe_object:5prop_other:1}}{file:maps/random/rmgen/library.jsline:381name:getMapSizetotals:{interp:6mjit:222mjit_calls:3mjit_code:76072mjit_pics:5032infer_poly:148infer_nobarrier:148observe_int32:74observe_object:74prop_other:74}}{file:maps/random/rmgen/library.jsline:518name:paintClasstotals:{interp:120}}{file:maps/random/rmgen/library.jsline:39name:scaleByMapSizetotals:{interp:208mjit:480mjit_calls:6mjit_code:135520mjit_pics:8512infer_poly:224infer_nobarrier:128observe_int32:192observe_object:32arith_unknown:192}}{file:maps/random/rmgen/constraint.jsline:86name:AvoidTileClassConstrainttotals:{interp:168mjit:7mjit_calls:6mjit_code:1611mjit_pics:68infer_poly:3infer_nobarrier:1observe_int32:2observe_object:1prop_other:2}}{file:maps/random/rmgen/constraint.jsline:92name:AvoidTileClassConstraint.allowstotals:{interp:26mjit:792488mjit_calls:8mjit_code:280441691mjit_pics:6934200infer_poly:495305infer_nobarrier:297183observe_int32:296979observe_double:204observe_object:198122prop_other:297183arith_double:99061}}{file:maps/random/alpine_lakes.jsline:0totals:{mjit:1201mjit_calls:223mjit_code:282326mjit_pics:56601infer_poly:466infer_nobarrier:466observe_int32:195observe_object:271arith_double:90arith_unknown:30}}{file:maps/random/rmgen/area.jsline:10name:Areatotals:{interp:112}}{file:maps/random/rmgen/area.jsline:16name:Area.getIDtotals:{interp:42mjit:4mjit_calls:2mjit_code:1162infer_poly:2infer_nobarrier:2observe_int32:2prop_other:2}}" Quote Link to comment Share on other sites More sharing options...
Yves Posted May 31, 2013 Author Report Share Posted May 31, 2013 Please read to the end, there's an important decision to take and I need some feedback!I've found this article which is about a new baseline JIT compiler being introduced in version 22 of Spidermonkey.The baseline compiler has landedSome interesting quotes from the article:"If type information for a function changes, then any existing JITcode (both Jaeger’s and Ion’s) is thrown away, ... ""Baseline jitcode never becomes invalid, and never requires recompilation. It tracks and reacts to dynamic changes, adding new stubs to its IC chains as necessary. "I think this could be our biggest performance problem.This output could mean that this function is recompiled with JaegerMonkey nearly 13 million times (while generating the random map Alpine Lakes with a size of 256 if I remember correctly)mjit_calls:12'801'440I've checked how often the function is called (44'811'319 times), so it would compile it and then run the compiled version 3.5 times in average and then already recompile it. That can't be good but I'm not sure if this interpretation is correct or if the number means something slightly (or completely) different.Anyway I think the best decision is now to switch to v22 instead of esr17.Some pros and cons:+ If I upgrade to V17 now we have to upgrade to a newer version later, but we have to do it at some point. If I already make the changes for the newer API, some of the work is already done.+ The performance problem of V17 seems to be an internal problem of Spidermonkey. If that's true,the only way to solve it is to upgrade to a newer version. Spending a lot of time on troubleshooting an old version is a waste of time. Especially if it's likely that the main problem is solved in a newer version.+ Even if this doesn't bring a huge improvement it should be faster because newer versions are always faster... erm...+ Hopefully the Mozilla guys will be more interested in helping with performance issues if we use the current version instead of an old one.+ Adding something that was mainly meant to be a performance improvement and actually making the game slower feels bad and demotivating.- Linux distributions won't like us because they have to bundle v22 with the game. V17 is officially released by Mozilla as a standalone version and most distributions will package that anyway. On the other hand 0 A.D. is an alpha version and we shouldn't yet worry too much about release packaging.- It's bleeding edge and probably buggier than v17.- The whole upgrade takes longer. V17 brings some improvements even if the performance is worse- We don't really support the efforts put into releasing a standalone Spidermonkey vesion (esr17)Any comment on that? Do you guys think that's the right decision? Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted May 31, 2013 Report Share Posted May 31, 2013 Any comment on that? Do you guys think that's the right decision?If we're going to upgrade SM in the first place, we need a justification. If there's no performance benefit, no GC benefit, why should we take the trouble of upgrading and losing compatibility with the 1.8.5 packages out there? So I'm fine with looking for a version that offers one or more significant benefits, I think it's worth investigating. Can you also summarize the non-performance improvements we would get from V17+? Quote Link to comment Share on other sites More sharing options...
wraitii Posted May 31, 2013 Report Share Posted May 31, 2013 I'd agree with historic Bruno. If it seems like we can't really get more out of v17, then we should not upgrade at all. But if we can get more from v22, then it's interesting, even of right now potentially buggy. At the very least, your work wouldn't be most and could serve a a framework for a future upgrade once it's stable Quote Link to comment Share on other sites More sharing options...
Yves Posted May 31, 2013 Author Report Share Posted May 31, 2013 Can you also summarize the non-performance improvements we would get from V17+?I think the main benefit is that it should make it easier for us to implement multi-threading support for the AI. I've tried it with 1.8.5 but there were a lot random crashes in Spidermonkey I couldn't find a reason for. V17 forces you to be more careful with compartments and triggers assertions earlier if something's wrong instead of crashing later. I've also red something about improved threading support, but I don't know exactly what was improved.Basic lifecycle. I don't know how long distributions will keep the 1.8.5 packages. But that's a weak argument if we force them to use a non-standard version instead.If we find a problem that can't be solved with 1.8.5 (localization maybe or whatever) then we also have to upgradeThe strict-mode validation of js code is better. It gave hundreds of errors and warnings when I first ran it. Many of these warnings pointed to potentially buggy or ambiguous code that could be avoided in the future.Granted, the main reason was/is performance.At the very least, your work wouldn't be most and could serve a a framework for a future upgrade once it's stableIt looks like they plan to release the next bundled Spidermonkey version with esr24 this autumn/winter. Quote Link to comment Share on other sites More sharing options...
Yves Posted May 31, 2013 Author Report Share Posted May 31, 2013 This output could mean that this function is recompiled with JaegerMonkey nearly 13 million times (while generating the random map Alpine Lakes with a size of 256 if I remember correctly)mjit_calls:12'801'440I've checked how often the function is called (44'811'319 times), so it would compile it and then run the compiled version 3.5 times in average and then already recompile it. That can't be good but I'm not sure if this interpretation is correct or if the number means something slightly (or completely) different.I've met bhackett (the guy who wrote large parts of JIT Inspector) on the #jsapi channel. My interpretation was wrong. bhackett Yves: it means the jitcode either called another jit compiled function, or made a VM call into C++ to perform an operation rather than being able to do it in jitcode bhackett Yves: programs with a lot of mjit_calls will not perform very well Another guy called h4writer pointed me to this release schedule: https://wiki.mozilla...elease/CalendarHe suggested aiming for esr24 which will be the next stable release and should be released on the 17th of September.I think that makes sense Quote Link to comment Share on other sites More sharing options...
wraitii Posted June 1, 2013 Report Share Posted June 1, 2013 I think that's a fair aim. If there is any indication that esr24 will not be too different from v22, I say go for it. Multithreading and stricter compiling are two very good points imo. Quote Link to comment Share on other sites More sharing options...
tuan kuranes Posted June 1, 2013 Report Share Posted June 1, 2013 (edited) The strict-mode validation of js code is better. It gave hundreds of errors and warnings when I first ran it. Many of these warnings pointed to potentially buggy or ambiguous code that could be avoided in the future.That adds other good point for upgrading:- latest sm version will support sourcemaps (allows eaiser use of js "flavors" or any other language that can be transpiled to js)- asm.js support in future sm release (which means real faster typed vars)Both point, plus the current "c++ like" orientation of current js code could leads to either easier js code production, using transpilers like lljs (would recommend that, because it can transpile to asm.js, and handle memory C like in a very efficient way and is very strict), or just directly asm.js (but that have to wait for sm upgrade to asm.js supported version).On a side note, current js code could benefits for addition/usage of js code quality tools. (jsvalidate, jshint, qunit, plato, benchmarkjs, etc.). Some nice things can be done/automated using gruntjs (like setting a "grunt watch" task which run in background and lint against any js tools any changes while you edit js files)(from a few js code reading, there's lot of room for js optimisation) Edited June 1, 2013 by tuan kuranes Quote Link to comment Share on other sites More sharing options...
fabio Posted June 4, 2013 Report Share Posted June 4, 2013 Mozilla plans to release mozjs24 snapshot this month:https://bugzilla.moz...i?id=735599#c57When 24 moves from Nightly to Aurora (around June 24), I'll work on putting outa version. This obviously cannot be considered a release candidate, but the APIshould be stable between Aurora and release, and I'll track any major changes.Release candidates can start appearing after 24 is out of beta, around lateSeptember. Quote Link to comment Share on other sites More sharing options...
Yves Posted June 4, 2013 Author Report Share Posted June 4, 2013 Thanks, that's good to know.At the moment I'm just building it inside the Firefox source tree because I haven't yet figured out which directories and files it exactly needs. Quote Link to comment Share on other sites More sharing options...
fabio Posted June 4, 2013 Report Share Posted June 4, 2013 The scripts used for extracting mozjs17 from FF is here:https://github.com/sstangl/js-packagingpackage.sh lists the needed directory, maybe it still applies for 24 also (the patches may break). Quote Link to comment Share on other sites More sharing options...
stwf Posted June 6, 2013 Report Share Posted June 6, 2013 ok, I checked my fixes for this upgrade into main trunk. It just makes things so much easier. I did incorporate the suggestions you made on the first batch. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.