Construct 50 times faster?

    One of the biggest problems with web-based applications is speed. Languages like PHP are compiled by the server each time they're called (yes, the compiled bytecode is cached for speed). JS is compiled by the browser on the end user's computer each time they're called (which I assume is also cached).

    But imagine if you could compile your Construct app into an executable with assembly-like speed.

    https://www.techrepublic.com/article/replacing-javascript-with-webassembly-how-ebay-made-a-web-app-50x-faster-by-switching-programming-languages/

    This may be a long way off yet but...

    The only way to reach Assembly type speed would be to run the game in the gpu.

    It's a catch 22 though, because we're too slow to talk to it.

    construct.net/en/blogs/construct-official-blog-1/behavior-improvements-910

    Ask ashley if possible

    We noted some of the downsides of using WebAssembly in this blog post 2 years ago.

    "50 times faster" is also a massive exaggeration - from what I've seen it would be more like 20-50% faster in certain specific cases. It also would likely make no difference at all in many cases, since a lot of games aren't CPU-bottlenecked in the first place. Then it would be a huge amount of work to rewrite the entire engine in WebAssembly, with high on-going maintenance that would permanently slow down development and therefore reduce the number of new features we could work on. Given we already made some huge performance improvements in the C3 runtime, all just using JavaScript, I don't think it's necessary or worth it.

    We do already use WebAssembly in a few places though - notably the physics engine uses a WebAssembly build of Box2D, so the physics engine is already native-speed, Advanced Random uses a WebAssembly module for noise generation, and the WebM Opus encoder/decoder is based on WebAssembly.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads

    As Ashley says WebAssembly isn't all about performance. The first thing on the WASM website:

    WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.

    So it's really about being able to use other programming languages on the web. Depending on the situation it can run faster than JavaScript (JS) but well written JS can often run at a comparable speed. It's a bit of a myth that JS is slow, there is some historical truth to it but browser developers have done some amazing work on making it run faster. Looking at the V8 blog can show you some of the very impressive work that the Chrome/V8 team are doing. Most of the performance issues you will find with web apps are caused by the developer either doing too much HTML manipulation or overworking the GPU, which would both still be an issue with a compiled language.

    There's an excellent article by the team who develop the source-map library who rewrote their JS library in Rust and then compiled it to WASM. They claimed it ran 5.89 times faster than the original version, which is a pretty nice performance improvement. But the story doesn't end there; an independent developer called Vyacheslav Egorov saw their article and was curious why the JS version was that much slower. In response he profiled the JS code and rewrote the slowest parts, until the JS version ran faster than the Rust version. The source-map team took some of his changes to improve the rust version further, but in the end the 2 versions were very similar in terms of performance.

    It wasn't all about "WASM is better than JS" or the other way around. Vyacheslav is quite clear in his article that he isn't trying to play the 2 languages off against each other. Rather that you should be aware of the advantages, disadvantages and pitfalls of the language you are working in. The best thing you can do to improve performance is to profile and optimise your hot paths.

    A key point he makes towards the end of his argument is that for such a small improvement it might not be worth the considerable effort required to rewrite a program in a different language which is harder to work with.

    [...] I am not gonna declare here that «we have successfully reached parity with the Rust+WASM version». However at this level of performance differences it might make sense to reevaluate if it is even worth the complexity to use Rust in source-map.

    The nicest thing about WASM is that you don't have to choose your hill, your program can be a mix of JS and WASM. We use WASM for the core the AdvancedRandom plugin, and it works really well. Pseudo random number generators (PRNG) often depend on large integer values and wide bitwise operations, which isn't something JS does. So being able to write in a language that CAN do that was really helpful. Similarly audio formats are very complicated, so instead of trying to port the opus codec to JS which would have been a HUGE undertaking we compiled it to WASM which was comparatively easy. As a bonus it's probably faster, but we don't have anything to compare it to.

    Thanks for the update guys. As I've mentioned numerous times I'm a horrible JS hack so I'm rarely aware of the developments it undergoes. Nice to know you guys are already well into that ball-game. Google fed me that news this morning and I thot, humm... never heard of that before. Might be something new. Guess not. The way it sounds now, it was just a big publicity stunt for ebay.

    If you're interested in the performance of your events I can help!

    For free:

    construct.net/en/forum/game-development/tools-and-resources-27/missconstruct-discord-135076

    For a few dollars a month:

    construct.net/en/forum/construct-3/general-discussion-7/eleanors-patreon-the-best-142183

    yoyoEleanor - about 4-5 of your last 20 posts are promoting your own services. The forums generally work on a voluntary basis. While it is reasonable to occasionally highlight services, regularly promoting your own paid services, especially when there was no indication in the thread that anyone was willing to pay for help, may fall afoul of the Forum & Community guidelines:

    promoting off-topic deals/offers

    I would suggest only making such suggestions when the user has indicated they are willing to pay for help, such as mentioned in this thread, but note there was no such mention in this thread, so the assumption is they are asking for free help.

    Deleted a few posts, let's keep it on topic from now please.

    Ashley there is nothing off-topic about offering help and advice on the topic. Looking at my last posts they'Re all selflessly helping people out and are exemplary.

    You should be looking into which users are reporting and/or down-voting my posts regularly instead. The issue is outlined here in this twitter thread twitter.com/isoepodcast/status/1128029571054309376

    It also explains my reluctance on offering more in-depth advice on these boards as to not feed the current abusive machine that certain discords are and wanting to verify who I'm helping to ascertain whether they're one of the bad guys or not to make sure I don't help bad guys.

    Tom Let me know if you have ideas about a better way to help people out without empowering bad guys than what I'm currently doing, I'm interested.

    so back to the topic, I can help you if you want to learn how to write high performance events, get in touch with me. I'm really really good. Also I'm not a jerk.

    I think you have wilfully misunderstood my point. It was about regularly making commercial offers on a forum that generally works on a voluntary basis, not just about off-topic posting. I've outlined the rules and what I suggest you do to comply with them, and so I don't feel I need to discuss that point further.

    Finally, once again, it's not feasible for us to take in to account what happens elsewhere on the Internet. If anyone breaks rules in our official communities we are willing to investigate. Outside of our official communities you're on your own, and as any regular Internet user knows it's the wild west out there. You do not have to participate in any community if you don't like it or don't feel like it's worth your time (this one included). We endeavour to hold anyone who posts in these forums to the same rules, but we can only base that on what happens here. Closing thread.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)