Skip to content

WASM performance is ~45% slower compared to 2.9 #177

@tzimnoch

Description

@tzimnoch

Sample performance tests can be checked out from https://github.com/tzimnoch/dds/tree/performance_demo

The 2.9 WASM files were build from https://github.com/dds-bridge/dds.git using the following command.

$ em++ --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 5.0.3 (285c424dfa9e83b03cf8490c65ceadb7c45f28eb)
Copyright (C) 2026 the Emscripten authors (see AUTHORS.txt)
[...]

em++ -O2 \
  -s WASM=1 \
  -s EXPORTED_FUNCTIONS='["_malloc","_free","_SetMaxThreads","_SolveBoard","_SolveBoardPBN","_CalcDDtable","_CalcDDtablePBN"]' \
  -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap","setValue","getValue"]' \
  -s INITIAL_MEMORY=67108864 \
  -s MODULARIZE=1 \
  -s EXPORT_NAME="DDS" \
  -s USE_PTHREADS=0 \
  -D DDS_THREADS=1 \
  -I src/ \
  src/*.cpp \
  -o dds.js

Using Firefox on Fedora, solving the same set of 100 random boards took:
New solver: 492925.0ms (4929.25ms avg). Legacy: 263241.0ms (2632.41ms avg).

Brave on Fedora had a similar difference in relative performance, though significantly better than Firefox.
New solver: 124909.7ms (1249.10ms avg). Legacy: 70628.5ms (706.28ms avg).

As of yet I've not been able to account for the difference in performance nor have I been successful in tweaking the compile/linker options in this project to achieve similar performance as seen in prior versions.

I have not verified whether a similar difference in performance exists in the native libraries, but I suspect the greatest performance gain will come from changing the way the WASM artifact is built or used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions