JS Engines performance#1717
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new performance-focused UnitTests benchmark that measures Babylon Native cold-start, script evaluation, GLB loading, and animation rendering timings (primarily CPU-side), along with build-system updates to include the new test and required JS assets.
Changes:
- Switches the FetchContent source for
JsRuntimeHostto a different Git repository/commit. - Adds a new C++ gtest perf benchmark (
Perf.GLBAnimation) plus accompanying JS/TS harness, webpack entry, and bundled dist output. - Updates UnitTests CMake to package the new benchmark script (and a loaders asset) into the UnitTests
Assetsfolder.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| CMakeLists.txt | Updates the FetchContent source/tag for JsRuntimeHost. |
| Apps/UnitTests/CMakeLists.txt | Registers the new perf test source and adds additional JS assets for UnitTests packaging. |
| Apps/UnitTests/Source/Tests.Perf.GLBAnimation.cpp | New C++ benchmark test that initializes runtime/plugins, loads scripts, drives a noop-render loop, and prints a timing summary. |
| Apps/UnitTests/JavaScript/webpack.config.js | Adds a new webpack entry point for the perf benchmark JS bundle. |
| Apps/UnitTests/JavaScript/src/tests.perf.glbAnimation.ts | New JS-side benchmark that loads a GLB and steps animation groups while reporting timings to C++. |
| Apps/UnitTests/JavaScript/dist/tests.perf.glbAnimation.js | Bundled output of the new perf benchmark script. |
| FetchContent_Declare(JsRuntimeHost | ||
| GIT_REPOSITORY https://github.com/BabylonJS/JsRuntimeHost.git | ||
| GIT_TAG 1e9b17e4544862270420f0e192c5dfe56fe768d2) | ||
| GIT_REPOSITORY https://github.com/CedricGuillemet/JsRuntimeHost.git | ||
| GIT_TAG fe26c61ecdebf84e8617c234b1729b86b1650858) |
| set(BABYLONJS_LOADERS_ASSETS | ||
| "../node_modules/babylonjs-loaders/babylonjs.loaders.js") | ||
|
|
| #include <atomic> | ||
| #include <chrono> | ||
| #include <cstdlib> | ||
| #include <filesystem> | ||
| #include <fstream> | ||
| #include <future> | ||
| #include <iomanip> | ||
| #include <iostream> | ||
| #include <mutex> | ||
| #include <sstream> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> |
| TEST(Perf, GLBAnimation) | ||
| { | ||
| const auto totalStart = PerfClock::now(); | ||
|
|
||
| std::mutex perfMutex; |
| function reportFrameStats(label: string, result: StepResult): void { | ||
| // Report the totals and individual stats as separate entries so the C++ summary lines | ||
| // them up under each other in the order they were observed. | ||
| _perfReport(label + " total (sum)", result.totalMs); | ||
| _perfReport(label + " frames", result.frameCount); | ||
| _perfReport(label + " min frame", result.minMs); | ||
| _perfReport(label + " max frame", result.maxMs); | ||
| _perfReport(label + " avg frame", result.avgMs); |
| const HORSE_GLB_URL = | ||
| "https://raw.githubusercontent.com/CedricGuillemet/dump/master/Horse.glb"; | ||
|
|
|
I wonder if compiling QuickJS with LTO/LTCG + PGO would close some of thoes gaps with v8. This is one of the things we did with ChakraCore on Windows 7/8/10 in React Native Windows to get TTFMP cut in half in the BlueJeans app, and I drove similar work in the JSC build for React Native PlayStation (closed source) to similarly cut TTMFP in PS5 apps. At the very least, seeing if there's any clusters of branch predicition, prefetch, or L1 cache misses that can be reasoned about would be good profiler data to have. Also, can you list the max RSS and CPU core usage used by the UnitTests for each engine? I'm assuming that even though QUickJS is currently slower than v8, that the performance per watt and for the memory usage blows v8 out of the water, but getting more hard data would be educational either way. |
UnitTests performance used to compare Chakra/V8/QuickJS CPU performance for initialization, loading and rendering performance.
All tests on Windows, D3D11, release.
Report visible here : https://cedricguillemet.github.io/BNPerf/perf-report.html
Binary size
Chakra
V8
QuickJS