Skip to content

JS Engines performance#1717

Draft
CedricGuillemet wants to merge 5 commits into
BabylonJS:masterfrom
CedricGuillemet:TestPerfQJS
Draft

JS Engines performance#1717
CedricGuillemet wants to merge 5 commits into
BabylonJS:masterfrom
CedricGuillemet:TestPerfQJS

Conversation

@CedricGuillemet
Copy link
Copy Markdown
Collaborator

@CedricGuillemet CedricGuillemet commented May 26, 2026

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

05/26/2026  10:40 AM         3,719,680 UnitTests.exe

V8

05/26/2026  10:53 AM        10,717,392 icudtl.dat
05/26/2026  10:53 AM         1,437,696 icuuc.dll
05/26/2026  10:53 AM         2,297,856 third_party_icu_icui18n.dll
05/26/2026  10:53 AM           111,104 third_party_zlib.dll
05/26/2026  10:53 AM         3,896,320 UnitTests.exe
05/26/2026  10:53 AM        25,415,680 v8.dll
05/26/2026  10:53 AM           227,840 v8_libbase.dll
05/26/2026  10:53 AM           104,960 v8_libplatform.dll

QuickJS

05/26/2026  11:16 AM         4,684,800 UnitTests.exe

Copilot AI review requested due to automatic review settings May 26, 2026 09:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 JsRuntimeHost to 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 Assets folder.

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.

Comment thread CMakeLists.txt Outdated
Comment on lines +55 to +57
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)
Comment on lines +13 to +15
set(BABYLONJS_LOADERS_ASSETS
"../node_modules/babylonjs-loaders/babylonjs.loaders.js")

Comment on lines +30 to +42
#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>
Comment on lines +79 to +83
TEST(Perf, GLBAnimation)
{
const auto totalStart = PerfClock::now();

std::mutex perfMutex;
Comment on lines +126 to +133
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);
Comment on lines +27 to +29
const HORSE_GLB_URL =
"https://raw.githubusercontent.com/CedricGuillemet/dump/master/Horse.glb";

@CedricGuillemet CedricGuillemet marked this pull request as draft May 26, 2026 09:39
@matthargett
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants