Skip to content

feat: openscad to js compiler package added#1725

Draft
swaparup36 wants to merge 22 commits into
elalish:masterfrom
swaparup36:openscad-to-manifold
Draft

feat: openscad to js compiler package added#1725
swaparup36 wants to merge 22 commits into
elalish:masterfrom
swaparup36:openscad-to-manifold

Conversation

@swaparup36

Copy link
Copy Markdown
Contributor

No description provided.

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.62%. Comparing base (bd56861) to head (8ca19a8).
⚠️ Report is 34 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1725      +/-   ##
==========================================
- Coverage   95.34%   94.62%   -0.72%     
==========================================
  Files          37       44       +7     
  Lines        8329     9441    +1112     
==========================================
+ Hits         7941     8934     +993     
- Misses        388      507     +119     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pca006132

Copy link
Copy Markdown
Collaborator

generated files should be in .gitignore

compile_all_examples.ts
examples/
images/
out/

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

/src layout looks out of date. I think it might also be nice to move examples, images, and out under a test directory, since I believe that's what they are?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In addition, I think the whole shebang should either go under bindings/wasm/examples. Maaaybe bindings/wasm/lib, but I see this as a different layer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@elalish I changed the layout from /src to flat layout keeping all the things in root of the compiler which were inside the /src. Also moved the out, examples inside /test directory and added /test/out in .gitignore as per @pca006132 suggested. And the images are actually for the comparison.md file, should that also be moved to test directory?

@tonious Earlier I had a conversation with John, he suggested to keep this inside /bindings/wasm/openscad-compiler as a separate package. Should I move it to any other directory or keep it as it is?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nevermind me, then 😁

"commander": "^14.0.3",
"express": "^5.2.1",
"manifold-3d": "^3.3.2",
"puppeteer": "^24.38.0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

puppeteer is kind of a heavy dependency. Where is it used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, I was trying to write tests the compiled outputs programmatically in a node js environment, that's why added puppeteer and express. I have removed those as of now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

dev-dependencies?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will add those as dev dependency when I write the tests.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Puppeteer is really heavy for tests even. It should be possible to implement tests without in-browser tests. It's a compiler -- it should run fine in node.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will try to do so. Actually, previously I was trying to test if the generated code runs on the viewer.html without any error or not, so I used Puppeteer. I will try to write tests for checking the correctness in a different way.

@tonious

tonious commented May 20, 2026

Copy link
Copy Markdown
Collaborator

This is awesome! But it's also a huuuge chunk of code. I'm posting comments as I think of them, so they may be disjoint. I'm not trying to be difficult. I mean, I might be difficult, but I'm not trying to be. My apologies in advance.

My comments will typically come from a few specific concerns:

  • If this breaks, how easily can I (as a regular contributor) fix it?
  • Can a new contributor quickly understand it?
  • How difficult will it be to keep pace with OpenSCAD over time? This is a lesser concern as their grammar is pretty stable.

@tonious

tonious commented May 20, 2026

Copy link
Copy Markdown
Collaborator

IMHO, runtime.* should be moved into their own openscad-compiler/runtime/ subfolder. It's probably also worth digesting the runtime into bite sized chunks. I suspect much future development would take place there -- we want to make it especially easy for new contributors to get started.

@swaparup36

swaparup36 commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

@tonious Thanks for the feedback! Those concerns are completely fair for a PR of this size. I'll work on making the structure and flow easier to follow, and split things up where it makes sense. I'll also add more docs and tests to improve maintainability.

For now, I've moved the runtime.* files into openscad-compiler/runtime/. I'll break the runtime into smaller, focused files when I do the dead code cleanup pass for the compiled code.

@tonious

tonious commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Today's thoughts:

  • Is runtime.js compiled from runtime.ts? If so, only the TypeScript file should be in the repo.
  • I do appreciate starting from the OpenSCAD examples, but I think I'd pick a known-good subset rather than copying them all in. Or even write a few new examples. This can be a good baseline for testing -- ManifoldCAD checks the volume, surface area and genus of each example. There may be a little bit of variation as I think openSCAD and manifold will likely generate slightly different surfaces. See worker.test.ts.
  • Did you use a lexer or parser generator tool? In the C world, the canonical examples would be Lex or Yacc respectively. I think I'm showing my age again....
  • The documentation suggests npx serve .. I think there should probably also be a job in package.json -- that'd be the first place most JS devs would look, even before the readme.

I'm wrapping my head around the server/viewer thing a little bit. My feeling is that it's extraneous, but that is an opinion as yet unsubstantiated by any thought process.

@swaparup36

swaparup36 commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Today's thoughts:

  • Yes, runtime.js is compiled from runtime.ts, I've removed that from /runtime.
  • I've added the npx serve . script in package.json.
  • I did not use any lexer or parser generator tool. I have to see if there is any js equivalent of Lex/Yacc.
  • Yes, I agree there are probably too many OpenSCAD example files included right now. In the last weekly meeting, John also suggested a more generic testing approach: having a single test that iterates through the OpenSCAD files, compiles them, and then compares the generated Manifold geometry against precomputed expected values like volume and surface area. The idea was to store those expected values directly alongside the OpenSCAD examples.

…tion_for module, fixed polyhedron and rotate_extrude implementation
…ntation according to the special variables; added source file tracking and emitting at the compiled code as comments;
…ping and special variable scoping; added overwrite feature for premitives and other minor fixes
…ock, fixed trigonometric calculations, fixed semantic issues
@swaparup36

swaparup36 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Compiler Benchmark Result

Runs per file: 5
Benchmarked: 147 files

All timings are medians in milliseconds. "Ratio" = openscad median / our-total median (>1x means we're faster).

File OpenSCAD Our compile Our run Our total Ratio Notes
OpenScad/Advanced/GEB.scad 397.1 202.7 1007.7 1210.5 0.33x
OpenScad/Advanced/animation.scad 338.8 6.2 592.7 597.3 0.57x
OpenScad/Advanced/assert.scad 291.3 2.7 501.6 505.3 0.58x
OpenScad/Advanced/children.scad 358.8 62.1 745.2 802.1 0.45x
OpenScad/Advanced/children_indexed.scad 330.3 60.2 666.5 730.4 0.45x
OpenScad/Advanced/offset.scad 259.5 4.7 501.4 506.1 0.51x
OpenScad/Advanced/surface_image.scad 391.6 2.8 1142.0 1144.5 0.34x
OpenScad/Basics/CSG-modules.scad 440.4 7.0 718.7 725.5 0.61x
OpenScad/Basics/CSG.scad 307.3 1.6 531.2 532.8 0.58x
OpenScad/Basics/LetterBlock.scad 261.5 146.0 564.3 715.1 0.37x
OpenScad/Basics/hull.scad 230.9 2.9 507.7 510.8 0.45x
OpenScad/Basics/linear_extrude.scad 306.6 1.5 516.7 517.9 0.59x
OpenScad/Basics/logo.scad 382.6 3.1 571.9 575.3 0.66x
OpenScad/Basics/logo_and_text.scad 490.8 126.5 765.8 889.4 0.55x
OpenScad/Basics/rotate_extrude.scad 369.7 68.5 652.6 724.9 0.51x
OpenScad/Basics/text_on_cube.scad 276.6 169.0 700.9 885.8 0.31x
OpenScad/Functions/functions.scad 263.3 1.3 567.1 568.3 0.46x
OpenScad/Old/example001.scad 293.2 1.7 577.1 578.8 0.51x
OpenScad/Old/example002.scad 232.6 1.2 517.2 518.4 0.45x
OpenScad/Old/example003.scad 228.3 1.9 479.8 481.7 0.47x
OpenScad/Old/example004.scad 247.0 1.3 518.8 520.1 0.47x
OpenScad/Old/example005.scad 261.0 1.7 676.0 677.7 0.39x
OpenScad/Old/example006.scad 408.2 3.1 734.8 738.2 0.55x
OpenScad/Old/example010.scad 457.0 38.2 646.9 687.7 0.66x
OpenScad/Old/example014.scad 226.2 2.0 511.3 514.6 0.44x
OpenScad/Old/example017.scad 310.1 12.1 552.0 567.4 0.55x
OpenScad/Old/example018.scad 274.0 2.1 617.3 620.3 0.44x
OpenScad/Old/example019.scad 329.8 1.4 544.1 545.8 0.60x
OpenScad/Old/example020.scad 313.9 4.2 554.4 559.0 0.56x
OpenScad/Old/example021.scad 283.3 3.5 627.1 631.0 0.45x
OpenScad/Old/example022.scad 287.0 2.7 555.9 558.6 0.51x
OpenScad/Old/example023.scad 371.1 4.2 548.1 551.2 0.67x
OpenScad/Old/example024.scad 586.8 2.5 1382.1 1384.6 0.42x
OpenScad/Openscad-Tests/3d-features/2d-3d.scad 247.7 1.3 523.5 524.8 0.47x
OpenScad/Openscad-Tests/3d-features/assign-tests.scad 219.0 1.5 483.7 485.2 0.45x
OpenScad/Openscad-Tests/3d-features/background-modifier.scad 300.4 1.4 494.8 497.8 0.60x
OpenScad/Openscad-Tests/3d-features/background-modifier2.scad 284.1 1.9 521.3 523.9 0.54x
OpenScad/Openscad-Tests/3d-features/child-background.scad 278.7 1.0 480.5 481.6 0.58x
OpenScad/Openscad-Tests/3d-features/child-child-test.scad 231.4 3.9 562.3 566.3 0.41x
OpenScad/Openscad-Tests/3d-features/child-modifier.scad 246.3 2.3 490.5 492.9 0.50x
OpenScad/Openscad-Tests/3d-features/child-tests.scad 289.5 1.9 479.9 482.2 0.60x
OpenScad/Openscad-Tests/3d-features/color-names-tests.scad 371.7 10.3 499.8 510.2 0.73x
OpenScad/Openscad-Tests/3d-features/color-tests.scad 241.4 2.0 591.1 593.1 0.41x
OpenScad/Openscad-Tests/3d-features/color-tests2.scad 251.4 1.7 561.7 563.3 0.45x
OpenScad/Openscad-Tests/3d-features/color-tests3.scad 280.6 1.9 517.9 520.0 0.54x
OpenScad/Openscad-Tests/3d-features/colored-nodes.scad 274.5 1.2 498.0 500.9 0.55x
OpenScad/Openscad-Tests/3d-features/cube-tests.scad 236.6 1.1 514.2 515.3 0.46x
OpenScad/Openscad-Tests/3d-features/cylinder-diameter-tests.scad 240.2 2.2 489.5 491.8 0.49x
OpenScad/Openscad-Tests/3d-features/cylinder-tests.scad 245.5 3.9 553.4 558.9 0.44x
OpenScad/Openscad-Tests/3d-features/difference-tests.scad 305.9 5.0 473.7 477.5 0.64x
OpenScad/Openscad-Tests/3d-features/disable-modifier.scad 266.4 1.4 611.9 613.3 0.43x
OpenScad/Openscad-Tests/3d-features/edge-cases.scad 329.0 3.1 554.1 558.6 0.59x
OpenScad/Openscad-Tests/3d-features/for-nested-tests.scad 310.7 2.6 545.8 548.3 0.57x
OpenScad/Openscad-Tests/3d-features/for-tests.scad 269.0 12.0 ERR ERR n/a run: Command failed: C:\nvm4w\nodejs\node.exe --import tsx D:\manifold\bindings\wasm\openscad-compil
OpenScad/Openscad-Tests/3d-features/hex-colors-tests.scad 323.3 3.9 508.0 513.2 0.63x
OpenScad/Openscad-Tests/3d-features/highlight-and-background-modifier.scad 308.4 2.1 549.5 551.7 0.56x
OpenScad/Openscad-Tests/3d-features/highlight-modifier.scad 250.4 1.4 536.3 538.7 0.46x
OpenScad/Openscad-Tests/3d-features/highlight-modifier2.scad 298.6 3.9 667.8 670.2 0.45x
OpenScad/Openscad-Tests/3d-features/hull3-tests.scad 224.8 1.5 592.1 593.8 0.38x
OpenScad/Openscad-Tests/3d-features/ifelse-tests.scad 242.4 4.0 466.9 471.1 0.51x
OpenScad/Openscad-Tests/3d-features/intersection-tests.scad 254.9 6.0 499.8 505.5 0.50x
OpenScad/Openscad-Tests/3d-features/intersection_for-tests.scad 230.1 1.8 605.6 608.0 0.38x
OpenScad/Openscad-Tests/3d-features/linear_extrude-parameter-tests.scad 282.9 2.4 544.2 545.9 0.52x
OpenScad/Openscad-Tests/3d-features/linear_extrude-scale-zero-tests.scad 286.8 2.5 514.3 517.4 0.55x
OpenScad/Openscad-Tests/3d-features/linear_extrude-tests.scad 268.5 2.8 466.0 468.8 0.57x
OpenScad/Openscad-Tests/3d-features/linear_extrude_invisible-tests.scad 238.1 1.2 498.6 499.9 0.48x
OpenScad/Openscad-Tests/3d-features/minkowski3-erosion.scad 359.5 2.5 869.8 873.0 0.41x
OpenScad/Openscad-Tests/3d-features/mirror-tests.scad 222.8 1.4 536.5 537.8 0.41x
OpenScad/Openscad-Tests/3d-features/module-recursion.scad 300.0 1.3 516.5 517.5 0.58x
OpenScad/Openscad-Tests/3d-features/modulevariables.scad 284.9 1.6 511.4 512.7 0.56x
OpenScad/Openscad-Tests/3d-features/nullspace-minkowski-intersection.scad 218.8 1.3 483.1 485.3 0.45x
OpenScad/Openscad-Tests/3d-features/nullspace-minkowski.scad 213.9 2.1 486.9 490.9 0.44x
OpenScad/Openscad-Tests/3d-features/polyhedron-concave-test.scad 285.7 1.8 485.2 486.7 0.59x
OpenScad/Openscad-Tests/3d-features/polyhedron-cube.scad 218.2 1.5 585.2 586.7 0.37x
OpenScad/Openscad-Tests/3d-features/polyhedron-nonplanar-tests.scad 233.6 7.2 480.3 487.5 0.48x
OpenScad/Openscad-Tests/3d-features/polyhedron-soup.scad 224.2 3.4 461.9 465.0 0.48x
OpenScad/Openscad-Tests/3d-features/primitive-inf-tests.scad 231.3 2.1 541.6 543.6 0.43x
OpenScad/Openscad-Tests/3d-features/projection-extrude-tests.scad 256.9 1.0 488.4 489.4 0.52x
OpenScad/Openscad-Tests/3d-features/render-preserve-colors.scad 221.9 4.0 496.6 502.7 0.44x
OpenScad/Openscad-Tests/3d-features/render-tests.scad 218.3 1.7 547.7 549.4 0.40x
OpenScad/Openscad-Tests/3d-features/resize-convexity-tests.scad 247.2 1.6 478.7 480.6 0.51x
OpenScad/Openscad-Tests/3d-features/resize-tests.scad 268.3 4.7 528.6 535.6 0.50x
OpenScad/Openscad-Tests/3d-features/root-modifier.scad 229.1 2.2 507.7 509.9 0.45x
OpenScad/Openscad-Tests/3d-features/rotate-parameters.scad 289.4 2.4 502.4 504.1 0.57x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-angle.scad 223.2 1.9 488.2 490.1 0.46x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-tests.scad 302.6 1.8 563.0 565.6 0.53x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-touch-edge.scad 212.6 2.2 450.5 452.7 0.47x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-touch-vertex.scad 208.4 0.9 489.4 490.2 0.43x
OpenScad/Openscad-Tests/3d-features/scale-mirror2D-3D-tests.scad 228.2 1.1 475.9 478.3 0.48x
OpenScad/Openscad-Tests/3d-features/scale3D-tests.scad 307.9 2.3 479.9 482.1 0.64x
OpenScad/Openscad-Tests/3d-features/sphere-tests.scad 322.4 3.8 510.7 514.2 0.63x
OpenScad/Openscad-Tests/3d-features/surface-png-image-tests.scad 1375.9 31.1 1310.7 1338.0 1.03x
OpenScad/Openscad-Tests/3d-features/surface-png-image2-tests.scad 1342.4 29.3 1313.5 1347.6 1.00x
OpenScad/Openscad-Tests/3d-features/surface-png-image3-tests.scad 1358.2 23.5 1322.0 1345.2 1.01x
OpenScad/Openscad-Tests/3d-features/tessellation-text-test.scad 260.6 130.6 541.2 672.2 0.39x
OpenScad/Openscad-Tests/3d-features/transform-tests.scad 243.3 2.1 530.4 534.5 0.46x
OpenScad/Openscad-Tests/3d-features/union-coincident-test.scad 225.5 1.2 518.6 519.6 0.43x
OpenScad/Openscad-Tests/3d-features/union-tests.scad 238.4 1.6 504.0 505.6 0.47x
OpenScad/Parametric/candleStand.scad 420.2 5.9 646.6 653.8 0.64x
OpenScad/Parametric/sign.scad 287.5 59.0 607.6 667.6 0.43x
advanced.scad 236.0 2.4 521.6 524.2 0.45x
boolean_ops.scad 316.1 2.8 556.0 558.6 0.57x
bosl2/BOSL2logo.scad 4491.4 11.0 ERR ERR n/a run: Command failed: C:\nvm4w\nodejs\node.exe --import tsx D:\manifold\bindings\wasm\openscad-compil
bosl2/attachments.scad 896.6 6.6 907.3 913.8 0.98x
bosl2/boolean_geometry.scad 2978.0 79.8 1973.8 2025.9 1.47x
bosl2/fractal_tree.scad 53697.3 7.0 777.7 784.6 68.44x
bosl2/orientations.scad 1270.7 64.4 2398.8 2449.3 0.52x
bosl2/spherical_patch.scad 808.0 6.8 ERR ERR n/a run: Command failed: C:\nvm4w\nodejs\node.exe --import tsx D:\manifold\bindings\wasm\openscad-compil
bosl2/spring_handle.scad 2900.2 8.8 1196.0 1204.1 2.41x
bosl2_bool_dif.scad 560.6 6.0 784.7 791.3 0.71x
bosl2_multiple_attachments.scad 756.8 6.6 840.6 846.2 0.89x
bosl2_tube_perimative.scad 541.7 6.3 778.0 787.6 0.69x
cube.scad 209.8 1.1 550.7 551.8 0.38x
echo/functions/rands.scad 716.6 17.4 524.9 546.0 1.31x
echo/misc/allmodules.scad 252.7 66.0 572.9 615.8 0.41x
echo/misc/assert-tests.scad 236.9 1.4 526.6 527.9 0.45x
echo/misc/bad-stl-pcbvicebar.scad 286.8 1.0 478.5 479.3 0.60x
echo/misc/bad-stl-tardis.scad 271.2 1.7 529.1 530.3 0.51x
echo/misc/bad-stl-wing.scad 440.4 1.2 497.8 499.3 0.88x
echo/misc/builtin-invalid-range-test.scad 315.5 3.8 585.1 589.4 0.54x
echo/misc/builtins-calling-vec3vec2.scad 249.8 1.7 516.5 518.4 0.48x
echo/misc/children-tests.scad 279.1 3.6 496.9 500.9 0.56x
echo/misc/color-cubes.scad 228.5 1.4 553.7 555.1 0.41x
echo/misc/color-export.scad 239.4 1.5 539.1 540.5 0.44x
echo/misc/cube10.scad 217.4 0.7 474.9 475.6 0.46x
echo/misc/ifelse-ast-dump.scad 284.9 2.1 668.7 671.9 0.42x
echo/misc/internal-cavity-polyhedron.scad 240.3 2.8 606.1 610.2 0.39x
echo/misc/internal-cavity.scad 239.6 1.2 533.4 534.4 0.45x
echo/misc/let-module-tests.scad 235.2 1.8 531.5 533.3 0.44x
echo/misc/localfiles-test.scad 252.2 2.5 475.1 478.3 0.53x
echo/misc/localfiles_dir/localfiles-compatibility-test.scad 296.9 3.0 515.9 519.4 0.57x
echo/misc/nonmanifold-polyhedron.scad 230.1 1.3 559.4 560.7 0.41x
echo/misc/normal-nan.scad 227.8 1.4 507.3 508.2 0.45x
echo/misc/root-modifier-for.scad 255.1 1.1 735.5 736.8 0.35x
echo/misc/root-modifiers.scad 222.8 1.2 528.3 530.0 0.42x
echo/misc/rotate-empty-bbox.scad 221.6 0.9 518.8 521.0 0.43x
echo/misc/rotate_extrude-hole.scad 237.6 1.2 550.9 552.4 0.43x
echo/misc/search-tests.scad 230.8 12.2 523.9 536.1 0.43x
echo/misc/sfære.scad 220.4 1.3 538.7 541.6 0.41x
echo/misc/special-consts.scad 229.4 2.4 524.5 527.3 0.44x
echo/misc/utf8-☠-3D.scad 286.7 2.9 744.0 747.0 0.38x
echo/misc/vector-values.scad 233.2 2.3 522.0 524.4 0.44x
minkowski_test.scad 234.7 0.9 519.8 520.6 0.45x
table.scad 230.6 1.3 502.9 505.4 0.46x
temp_cylinder.scad 232.4 1.3 499.3 500.2 0.46x
temp_sphere.scad 219.8 0.8 526.3 527.1 0.42x
temp_text.scad 249.1 62.5 597.3 645.0 0.39x
test_extrude.scad 216.4 0.8 497.2 498.3 0.43x
tree.scad 309.6 1.5 733.2 734.7 0.42x
view_port.scad 291.4 1.7 540.4 541.7 0.54x

Speedup Comparison Chart

speedup_comparison_chart

Time Distribution Chart

time_distribution_chart

@pca006132

Copy link
Copy Markdown
Collaborator

I think you may be running openscad in multithreaded mode while our js is only single threaded. You can try to limit the number of threads to openscad. On linux you can do it with taskset.

@swaparup36

swaparup36 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I think you may be running openscad in multithreaded mode while our js is only single threaded. You can try to limit the number of threads to openscad. On linux you can do it with taskset.

I am on windows and I think for OpenSCAD on Windows it is compiled without TBB (Threading Building Blocks) support (I am not quite sure about that but I asked this to several LLMs and they all told this). I tried running openscad, restricting it to single core (using CPU affinity bitmask) and the way I am running now, the time it took to compile is almost same. I have done it for several files and pasted output for four files -

PS D:\manifold\bindings\wasm\openscad-compiler> .\threading_check.ps1   
Running normally
Normal Internal Timer: Total rendering time: 0:00:00.149
Running locked to CPU Core 1
Restricted Internal Timer: Total rendering time: 0:00:00.172
PS D:\manifold\bindings\wasm\openscad-compiler> .\threading_check.ps1
Running normally
Normal Internal Timer: Total rendering time: 0:00:05.255
Running locked to CPU Core 1
Restricted Internal Timer: Total rendering time: 0:00:05.806
PS D:\manifold\bindings\wasm\openscad-compiler> .\threading_check.ps1
Running normally
Normal Internal Timer: Total rendering time: 0:00:00.022
Running locked to CPU Core 1
Restricted Internal Timer: Total rendering time: 0:00:00.028
PS D:\manifold\bindings\wasm\openscad-compiler> .\threading_check.ps1
Running normally
Normal Internal Timer: Total rendering time: 0:00:00.010
Running locked to CPU Core 1
Restricted Internal Timer: Total rendering time: 0:00:00.016

here is the script I am running -

$file = 'test/examples/tree.scad'
$exe = 'C:\Program Files\OpenSCAD (nightly)\openscad.exe'

Write-Host "Running normally"
$p = Start-Process $exe -ArgumentList "-o normal.off --backend=manifold $file" -NoNewWindow -RedirectStandardError normal_err.txt -PassThru
$p.WaitForExit()
$normalRenderLine = Get-Content normal_err.txt | Where-Object { $_ -match "Total rendering time:" }
Write-Host "Normal Internal Timer: $normalRenderLine"

Write-Host "Running locked to CPU Core 1"
$p = Start-Process $exe -ArgumentList "-o affinity.off --backend=manifold $file" -NoNewWindow -RedirectStandardError affinity_err.txt -PassThru
$p.ProcessorAffinity = 2
$p.WaitForExit()
$affinityRenderLine = Get-Content affinity_err.txt | Where-Object { $_ -match "Total rendering time:" }
Write-Host "Restricted Internal Timer: $affinityRenderLine"

Remove-Item normal.off, affinity.off, normal_err.txt, affinity_err.txt -ErrorAction SilentlyContinue

Am I doing it right?

@pca006132

Copy link
Copy Markdown
Collaborator

I have no idea about powershell, so cannot really say anything about your script. However, I am pretty sure openscad on windows is compiled with tbb. The simplest way to check this would be to run openscad on a non-trivial model (high resolution sphere union) and check CPU utilization yourself.

And well, I tried asking gemini and it agrees with me too, so I cannot be wrong :P

image

@swaparup36

swaparup36 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

My mistake. Indeed openscad on windows is compiled with tbb. I just verified that. I am now running openscad in wsl and with taskset to limit the openscad to run on single threaded mode. I've rewritten the benchmark script. Now the data I am getting are -

File OpenSCAD Our compile Our run Our total Ratio Notes
OpenScad/Advanced/GEB.scad 984.8 24.2 2903.3 2926.6 0.34x
OpenScad/Advanced/animation.scad 901.5 19.0 2617.4 2636.4 0.34x
OpenScad/Advanced/assert.scad 773.8 15.2 2834.5 2848.5 0.27x
OpenScad/Advanced/children.scad 673.2 17.6 2738.2 2755.5 0.24x
OpenScad/Advanced/children_indexed.scad 853.0 20.9 2489.6 2510.1 0.34x
OpenScad/Advanced/offset.scad 738.7 17.0 2520.0 2536.2 0.29x
OpenScad/Advanced/surface_image.scad 975.4 17.5 2417.6 2436.1 0.40x
OpenScad/Basics/CSG-modules.scad 889.1 16.9 2871.9 2887.5 0.31x
OpenScad/Basics/CSG.scad 777.3 14.7 2463.3 2478.0 0.31x
OpenScad/Basics/LetterBlock.scad 787.1 19.9 2543.6 2563.6 0.31x
OpenScad/Basics/hull.scad 747.5 14.0 2424.7 2438.5 0.31x
OpenScad/Basics/linear_extrude.scad 761.1 14.8 1633.6 1648.4 0.46x
OpenScad/Basics/logo.scad 705.0 13.2 2595.7 2606.6 0.27x
OpenScad/Basics/logo_and_text.scad 993.6 46.2 2640.0 2691.7 0.37x
OpenScad/Basics/rotate_extrude.scad 915.4 22.6 2520.0 2542.6 0.36x
OpenScad/Basics/text_on_cube.scad 779.0 20.0 2573.1 2593.8 0.30x
OpenScad/Functions/functions.scad 725.1 12.0 2506.4 2524.7 0.29x
OpenScad/Old/example001.scad 509.2 9.9 2489.6 2500.4 0.20x
OpenScad/Old/example002.scad 730.2 12.9 2471.9 2484.7 0.29x
OpenScad/Old/example003.scad 528.1 9.2 2398.3 2406.0 0.22x
OpenScad/Old/example004.scad 712.9 13.8 2408.4 2423.3 0.29x
OpenScad/Old/example005.scad 750.1 13.4 2578.8 2596.4 0.29x
OpenScad/Old/example006.scad 902.9 16.9 2648.4 2664.0 0.34x
OpenScad/Old/example010.scad 894.2 27.0 2477.5 2494.4 0.36x
OpenScad/Old/example014.scad 741.0 13.8 2518.4 2534.3 0.29x
OpenScad/Old/example017.scad 568.6 14.8 2029.9 2050.1 0.28x
OpenScad/Old/example018.scad 576.5 12.3 1645.0 1656.9 0.35x
OpenScad/Old/example019.scad 549.5 12.7 1674.0 1687.4 0.33x
OpenScad/Old/example020.scad 510.5 12.2 1531.5 1543.7 0.33x
OpenScad/Old/example021.scad 751.8 17.1 2437.9 2454.7 0.31x
OpenScad/Old/example022.scad 520.9 9.5 1517.0 1525.9 0.34x
OpenScad/Old/example023.scad 832.7 25.1 1844.1 1867.9 0.45x
OpenScad/Old/example024.scad 928.1 8.9 2911.2 2919.4 0.32x
OpenScad/Openscad-Tests/3d-features/2d-3d.scad 929.3 16.9 2043.1 2060.0 0.45x
OpenScad/Openscad-Tests/3d-features/assign-tests.scad 596.3 9.2 1646.7 1655.9 0.36x
OpenScad/Openscad-Tests/3d-features/background-modifier.scad 805.2 14.2 1662.7 1676.9 0.48x
OpenScad/Openscad-Tests/3d-features/background-modifier2.scad 533.2 15.9 2017.1 2033.5 0.26x
OpenScad/Openscad-Tests/3d-features/child-background.scad 552.9 10.2 1919.0 1932.3 0.29x
OpenScad/Openscad-Tests/3d-features/child-child-test.scad 533.1 12.8 2606.1 2615.2 0.20x
OpenScad/Openscad-Tests/3d-features/child-modifier.scad 745.5 16.8 2636.8 2653.6 0.28x
OpenScad/Openscad-Tests/3d-features/child-tests.scad 574.4 11.2 1703.0 1714.2 0.34x
OpenScad/Openscad-Tests/3d-features/color-names-tests.scad 926.9 24.0 2869.3 2903.9 0.32x
OpenScad/Openscad-Tests/3d-features/color-tests.scad 526.1 11.6 1888.4 1899.1 0.28x
OpenScad/Openscad-Tests/3d-features/color-tests2.scad 837.7 17.2 2770.6 2791.8 0.30x
OpenScad/Openscad-Tests/3d-features/color-tests3.scad 624.5 11.6 1907.5 1919.2 0.33x
OpenScad/Openscad-Tests/3d-features/colored-nodes.scad 501.3 12.0 2575.9 2587.9 0.19x
OpenScad/Openscad-Tests/3d-features/cube-tests.scad 723.7 18.5 2711.0 2731.9 0.26x
OpenScad/Openscad-Tests/3d-features/cylinder-diameter-tests.scad 829.6 18.7 2650.5 2667.8 0.31x
OpenScad/Openscad-Tests/3d-features/cylinder-tests.scad 587.7 13.0 1605.1 1618.9 0.36x
OpenScad/Openscad-Tests/3d-features/difference-tests.scad 863.0 17.3 2641.5 2659.0 0.32x
OpenScad/Openscad-Tests/3d-features/disable-modifier.scad 719.1 17.9 2518.2 2536.1 0.28x
OpenScad/Openscad-Tests/3d-features/edge-cases.scad 849.7 17.6 2695.1 2718.9 0.31x
OpenScad/Openscad-Tests/3d-features/for-nested-tests.scad 770.7 15.4 2619.3 2637.4 0.29x
OpenScad/Openscad-Tests/3d-features/for-tests.scad 866.3 23.4 ERR ERR n/a run: Command failed: /home/swaparup/.nvm/versions/node/v24.1.0/bin/node --import tsx /mnt/d/manifold
OpenScad/Openscad-Tests/3d-features/hex-colors-tests.scad 545.8 13.4 1700.4 1717.7 0.32x
OpenScad/Openscad-Tests/3d-features/highlight-and-background-modifier.scad 516.5 10.0 2688.3 2700.0 0.19x
OpenScad/Openscad-Tests/3d-features/highlight-modifier.scad 672.3 14.3 2752.5 2767.8 0.24x
OpenScad/Openscad-Tests/3d-features/highlight-modifier2.scad 904.1 18.0 2833.7 2851.6 0.32x
OpenScad/Openscad-Tests/3d-features/hull3-tests.scad 803.1 18.0 2826.8 2843.8 0.28x
OpenScad/Openscad-Tests/3d-features/ifelse-tests.scad 827.3 17.8 1975.1 1992.3 0.42x
OpenScad/Openscad-Tests/3d-features/intersection-tests.scad 614.8 12.9 2386.2 2397.5 0.26x
OpenScad/Openscad-Tests/3d-features/intersection_for-tests.scad 551.1 13.2 1889.2 1900.6 0.29x
OpenScad/Openscad-Tests/3d-features/linear_extrude-parameter-tests.scad 672.9 13.9 1983.5 1994.0 0.34x
OpenScad/Openscad-Tests/3d-features/linear_extrude-scale-zero-tests.scad 586.8 13.8 1914.1 1927.9 0.30x
OpenScad/Openscad-Tests/3d-features/linear_extrude-tests.scad 589.3 17.8 2010.3 2028.1 0.29x
OpenScad/Openscad-Tests/3d-features/linear_extrude_invisible-tests.scad 574.3 12.5 1909.5 1922.1 0.30x
OpenScad/Openscad-Tests/3d-features/minkowski3-difference-test.scad 712.9 13.2 2508.3 2521.9 0.28x
OpenScad/Openscad-Tests/3d-features/minkowski3-erosion.scad 637.6 13.6 2201.6 2214.9 0.29x
OpenScad/Openscad-Tests/3d-features/minkowski3-tests.scad 607.2 13.6 2034.7 2048.4 0.30x
OpenScad/Openscad-Tests/3d-features/mirror-tests.scad 584.2 12.5 1907.6 1922.7 0.30x
OpenScad/Openscad-Tests/3d-features/module-recursion.scad 552.3 14.0 2856.7 2870.0 0.19x
OpenScad/Openscad-Tests/3d-features/modulevariables.scad 782.3 13.2 1942.8 1958.2 0.40x
OpenScad/Openscad-Tests/3d-features/nullspace-minkowski-intersection.scad 694.2 16.7 2263.5 2279.3 0.30x
OpenScad/Openscad-Tests/3d-features/nullspace-minkowski.scad 585.7 13.7 2299.7 2314.7 0.25x
OpenScad/Openscad-Tests/3d-features/polyhedron-concave-test.scad 538.1 13.0 2136.4 2149.4 0.25x
OpenScad/Openscad-Tests/3d-features/polyhedron-cube.scad 856.4 19.9 2892.8 2914.7 0.29x
OpenScad/Openscad-Tests/3d-features/polyhedron-nonplanar-tests.scad 820.0 35.8 2737.8 2776.4 0.30x
OpenScad/Openscad-Tests/3d-features/polyhedron-soup.scad 781.8 18.4 2623.8 2641.2 0.30x
OpenScad/Openscad-Tests/3d-features/primitive-inf-tests.scad 853.4 18.5 2650.2 2668.7 0.32x
OpenScad/Openscad-Tests/3d-features/projection-extrude-tests.scad 769.2 17.7 2604.9 2626.6 0.29x
OpenScad/Openscad-Tests/3d-features/render-preserve-colors.scad 664.4 20.3 2689.5 2709.8 0.25x
OpenScad/Openscad-Tests/3d-features/render-tests.scad 808.9 18.4 2885.3 2903.7 0.28x
OpenScad/Openscad-Tests/3d-features/resize-convexity-tests.scad 814.6 18.4 2653.3 2669.3 0.31x
OpenScad/Openscad-Tests/3d-features/resize-tests.scad 822.1 22.9 2780.2 2802.6 0.29x
OpenScad/Openscad-Tests/3d-features/root-modifier.scad 735.5 19.7 2622.9 2644.2 0.28x
OpenScad/Openscad-Tests/3d-features/rotate-parameters.scad 833.3 18.0 2780.9 2799.8 0.30x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-angle.scad 806.0 18.4 2753.8 2772.3 0.29x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-tests.scad 889.1 17.2 2725.8 2743.0 0.32x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-touch-edge.scad 771.6 17.2 2788.1 2806.5 0.27x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-touch-vertex.scad 814.4 9.2 2345.2 2355.7 0.35x
OpenScad/Openscad-Tests/3d-features/scale-mirror2D-3D-tests.scad 640.3 11.7 1896.7 1908.3 0.34x
OpenScad/Openscad-Tests/3d-features/scale3D-tests.scad 634.2 14.6 2641.8 2656.4 0.24x
OpenScad/Openscad-Tests/3d-features/sphere-tests.scad 648.7 13.0 2260.0 2277.0 0.28x
OpenScad/Openscad-Tests/3d-features/tessellation-text-test.scad 948.0 23.3 3070.9 3097.5 0.31x
OpenScad/Openscad-Tests/3d-features/transform-tests.scad 750.8 10.9 2763.8 2773.9 0.27x
OpenScad/Openscad-Tests/3d-features/union-coincident-test.scad 913.5 21.7 2997.9 3019.5 0.30x
OpenScad/Openscad-Tests/3d-features/union-tests.scad 887.1 22.5 2806.1 2828.6 0.31x
OpenScad/Parametric/candleStand.scad 1010.8 19.1 2915.1 2935.7 0.34x
OpenScad/Parametric/sign.scad 959.1 18.2 2732.0 2750.4 0.35x
advanced.scad 861.3 11.0 2881.8 2893.5 0.30x
boolean_ops.scad 898.1 12.6 2496.0 2507.3 0.36x
bosl2/orientations.scad 1033.2 31.2 ERR ERR n/a run: Command failed: /home/swaparup/.nvm/versions/node/v24.1.0/bin/node --import tsx /mnt/d/manifold
cube.scad 815.2 12.7 2803.9 2815.6 0.29x
echo/functions/rands.scad 1939.4 40.6 2933.6 2979.6 0.65x
echo/misc/allmodules.scad 1166.5 21.5 1931.1 1954.5 0.60x
echo/misc/assert-tests.scad 901.6 15.4 2949.0 2963.6 0.30x
echo/misc/bad-stl-pcbvicebar.scad 995.5 17.5 2896.4 2912.1 0.34x
echo/misc/bad-stl-tardis.scad 878.9 15.2 2932.9 2946.8 0.30x
echo/misc/bad-stl-wing.scad 900.4 15.2 2997.5 3012.7 0.30x
echo/misc/builtin-invalid-range-test.scad 2085.8 16.3 3001.6 3019.2 0.69x
echo/misc/builtins-calling-vec3vec2.scad 1160.7 18.3 2849.7 2869.1 0.40x
echo/misc/children-tests.scad 830.1 18.0 2836.9 2855.8 0.29x
echo/misc/color-cubes.scad 825.6 16.8 2878.6 2900.6 0.28x
echo/misc/color-export.scad 852.4 25.2 2811.3 2829.4 0.30x
echo/misc/cube10.scad 856.3 17.2 2795.4 2812.3 0.30x
echo/misc/ifelse-ast-dump.scad 847.4 15.9 2878.2 2895.7 0.29x
echo/misc/internal-cavity-polyhedron.scad 845.5 16.9 2877.9 2896.6 0.29x
echo/misc/internal-cavity.scad 901.3 15.3 2959.1 2975.1 0.30x
echo/misc/let-module-tests.scad 863.1 10.6 2180.6 2191.2 0.39x
echo/misc/localfiles-test.scad 974.5 44.4 2743.3 2788.0 0.35x
echo/misc/localfiles_dir/localfiles-compatibility-test.scad 992.7 45.8 2730.9 2778.2 0.36x
echo/misc/nonmanifold-polyhedron.scad 764.7 15.8 2717.0 2731.3 0.28x
echo/misc/normal-nan.scad 792.9 16.0 2582.8 2597.6 0.31x
echo/misc/root-modifier-for.scad 774.8 14.1 2593.7 2607.9 0.30x
echo/misc/root-modifiers.scad 795.9 15.8 2641.7 2656.8 0.30x
echo/misc/rotate-empty-bbox.scad 767.8 15.8 2635.1 2651.0 0.29x
echo/misc/rotate_extrude-hole.scad 772.7 14.9 2713.7 2728.4 0.28x
echo/misc/search-tests.scad 949.8 30.4 2935.8 2966.3 0.32x
echo/misc/sfære.scad 921.8 37.5 2085.8 2121.7 0.43x
echo/misc/special-consts.scad 519.7 11.1 2183.5 2194.6 0.24x
echo/misc/utf8-☠-3D.scad 549.5 9.3 1733.5 1742.4 0.32x
echo/misc/vector-values.scad 768.9 15.9 1864.0 1879.3 0.41x
minkowski_test.scad 532.1 7.6 2012.3 2018.7 0.26x
table.scad 581.1 9.6 2041.6 2051.6 0.28x
temp_cylinder.scad 778.0 12.9 1787.7 1802.4 0.43x
temp_sphere.scad 800.0 9.9 2710.7 2722.1 0.29x
temp_text.scad 935.8 16.5 3070.9 3088.1 0.30x
test_extrude.scad 684.5 8.7 1945.4 1953.3 0.35x
tree.scad 840.3 11.0 3051.1 3062.1 0.27x
view_port.scad 845.8 10.0 2896.9 2906.0 0.29x

Speedup Comparison Chart (in log scale)

speedup_comparison_chart

Time Distribution Chart

time_distribution_chart

@pca006132

Copy link
Copy Markdown
Collaborator

Timing distribution graph: Nice plot, but not very useful, since I can't read the proper total time here and compare it with openscad's time. This kind of cumulative plot works when the timings are components of a total time, e.g., compile and run of our js output, but openscad's timing is not one component of the total time. Try to change it that way.

Speedup comparison graph: Also not very useful, I have no idea what the axis actually means. Also, I don't think it is an appropriate use of log scale, things are not different in scale.

The bigger question here is, why are we so much slower even when openscad is running in a single thread? Geometry evaluation? Other stuff?

@swaparup36

swaparup36 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

@pca006132 Actually the previous benchmark result was incorrect due to some WSL issues. Here is the corrected data -

File OpenSCAD Our compile Our run Our total Ratio
OpenScad/Advanced/GEB.scad 948.6 6.3 584.5 592.7 1.60x
OpenScad/Advanced/animation.scad 742.4 12.4 638.5 659.7 1.13x
OpenScad/Advanced/assert.scad 721.5 1.7 498.6 500.1 1.44x
OpenScad/Advanced/children.scad 820.1 3.8 565.4 569.3 1.44x
OpenScad/Advanced/children_indexed.scad 831.0 3.3 518.5 521.2 1.59x
OpenScad/Advanced/offset.scad 676.3 1.3 508.6 509.8 1.33x
OpenScad/Advanced/surface_image.scad 865.4 1.5 500.4 501.8 1.72x
OpenScad/Basics/CSG-modules.scad 669.1 3.0 801.0 804.0 0.83x
OpenScad/Basics/CSG.scad 531.3 1.4 498.7 500.2 1.06x
OpenScad/Basics/LetterBlock.scad 757.4 2.4 457.1 460.5 1.64x
OpenScad/Basics/hull.scad 711.5 1.0 480.4 481.6 1.48x
OpenScad/Basics/linear_extrude.scad 733.9 1.0 572.6 574.2 1.28x
OpenScad/Basics/logo.scad 796.9 1.4 606.9 608.3 1.31x
OpenScad/Basics/logo_and_text.scad 901.6 3.6 445.2 448.4 2.01x
OpenScad/Basics/rotate_extrude.scad 526.1 4.0 362.5 364.5 1.44x
OpenScad/Basics/text_on_cube.scad 495.4 2.1 494.6 496.5 1.00x
OpenScad/Functions/functions.scad 694.9 1.4 517.4 520.0 1.34x
OpenScad/Old/example001.scad 689.5 1.7 504.9 505.9 1.36x
OpenScad/Old/example002.scad 689.8 1.7 511.3 513.0 1.34x
OpenScad/Old/example003.scad 667.1 1.0 477.1 478.7 1.39x
OpenScad/Old/example004.scad 699.0 0.9 499.5 500.3 1.40x
OpenScad/Old/example005.scad 722.7 1.5 563.0 564.8 1.28x
OpenScad/Old/example006.scad 855.1 4.1 718.1 722.2 1.18x
OpenScad/Old/example010.scad 495.9 2.0 437.2 438.1 1.13x
OpenScad/Old/example014.scad 675.2 1.2 454.6 455.3 1.48x
OpenScad/Old/example017.scad 687.5 5.3 630.2 634.8 1.08x
OpenScad/Old/example018.scad 760.2 1.3 610.9 612.0 1.24x
OpenScad/Old/example019.scad 785.2 0.9 591.5 592.1 1.33x
OpenScad/Old/example020.scad 495.5 4.2 529.0 532.1 0.93x
OpenScad/Old/example021.scad 571.3 2.2 658.2 660.5 0.86x
OpenScad/Old/example022.scad 685.1 4.9 650.9 656.2 1.04x
OpenScad/Old/example023.scad 747.0 2.2 503.7 505.9 1.48x
OpenScad/Old/example024.scad 1198.9 1.6 1060.1 1061.7 1.13x
OpenScad/Openscad-Tests/3d-features/2d-3d.scad 420.1 0.3 297.2 297.5 1.41x
OpenScad/Openscad-Tests/3d-features/assign-tests.scad 466.3 1.0 328.6 330.3 1.41x
OpenScad/Openscad-Tests/3d-features/background-modifier.scad 433.5 1.0 467.0 468.5 0.93x
OpenScad/Openscad-Tests/3d-features/background-modifier2.scad 711.5 3.5 526.0 531.0 1.34x
OpenScad/Openscad-Tests/3d-features/child-background.scad 698.7 0.7 488.0 488.6 1.43x
OpenScad/Openscad-Tests/3d-features/child-child-test.scad 569.3 1.3 489.2 490.7 1.16x
OpenScad/Openscad-Tests/3d-features/child-modifier.scad 693.4 1.0 482.9 485.0 1.43x
OpenScad/Openscad-Tests/3d-features/child-tests.scad 685.2 2.1 455.8 458.6 1.49x
OpenScad/Openscad-Tests/3d-features/color-names-tests.scad 777.0 9.8 541.9 549.3 1.41x
OpenScad/Openscad-Tests/3d-features/color-tests.scad 659.8 1.1 474.5 476.0 1.39x
OpenScad/Openscad-Tests/3d-features/color-tests2.scad 698.0 0.8 518.1 518.7 1.35x
OpenScad/Openscad-Tests/3d-features/color-tests3.scad 705.2 0.5 335.0 335.8 2.10x
OpenScad/Openscad-Tests/3d-features/colored-nodes.scad 451.2 1.1 358.3 358.9 1.26x
OpenScad/Openscad-Tests/3d-features/cube-tests.scad 534.0 0.8 449.6 450.6 1.19x
OpenScad/Openscad-Tests/3d-features/cylinder-diameter-tests.scad 695.5 1.3 460.5 462.4 1.50x
OpenScad/Openscad-Tests/3d-features/cylinder-tests.scad 643.9 1.8 475.2 477.0 1.35x
OpenScad/Openscad-Tests/3d-features/difference-tests.scad 737.4 2.2 504.2 507.0 1.45x
OpenScad/Openscad-Tests/3d-features/disable-modifier.scad 710.5 0.6 442.6 443.1 1.60x
OpenScad/Openscad-Tests/3d-features/edge-cases.scad 791.1 1.4 585.7 587.9 1.35x
OpenScad/Openscad-Tests/3d-features/for-nested-tests.scad 739.3 0.7 565.5 566.2 1.31x
OpenScad/Openscad-Tests/3d-features/hex-colors-tests.scad 637.4 2.3 386.4 388.8 1.64x
OpenScad/Openscad-Tests/3d-features/highlight-and-background-modifier.scad 512.3 1.9 346.6 348.7 1.47x
OpenScad/Openscad-Tests/3d-features/highlight-modifier.scad 552.5 0.8 503.6 504.5 1.10x
OpenScad/Openscad-Tests/3d-features/highlight-modifier2.scad 506.8 1.7 502.8 505.1 1.00x
OpenScad/Openscad-Tests/3d-features/hull3-tests.scad 467.5 2.6 468.8 470.5 0.99x
OpenScad/Openscad-Tests/3d-features/ifelse-tests.scad 693.7 3.0 542.5 545.5 1.27x
OpenScad/Openscad-Tests/3d-features/intersection-tests.scad 753.7 3.8 540.1 543.6 1.39x
OpenScad/Openscad-Tests/3d-features/intersection_for-tests.scad 770.6 0.6 310.3 310.8 2.48x
OpenScad/Openscad-Tests/3d-features/linear_extrude-parameter-tests.scad 497.1 1.7 523.2 525.1 0.95x
OpenScad/Openscad-Tests/3d-features/linear_extrude-scale-zero-tests.scad 709.8 2.7 557.2 559.8 1.27x
OpenScad/Openscad-Tests/3d-features/linear_extrude-tests.scad 753.4 3.5 542.7 553.6 1.36x
OpenScad/Openscad-Tests/3d-features/linear_extrude_invisible-tests.scad 730.6 0.9 494.6 495.9 1.47x
OpenScad/Openscad-Tests/3d-features/minkowski3-difference-test.scad 962.2 0.9 1201.9 1203.1 0.80x
OpenScad/Openscad-Tests/3d-features/minkowski3-erosion.scad 500.7 1.0 758.2 759.9 0.66x
OpenScad/Openscad-Tests/3d-features/minkowski3-tests.scad 481.9 1.2 515.3 516.5 0.93x
OpenScad/Openscad-Tests/3d-features/mirror-tests.scad 514.0 1.3 501.2 502.7 1.02x
OpenScad/Openscad-Tests/3d-features/module-recursion.scad 759.0 0.9 588.8 589.6 1.29x
OpenScad/Openscad-Tests/3d-features/modulevariables.scad 698.4 0.7 513.1 513.7 1.36x
OpenScad/Openscad-Tests/3d-features/nullspace-minkowski-intersection.scad 710.7 0.7 480.3 480.9 1.48x
OpenScad/Openscad-Tests/3d-features/nullspace-minkowski.scad 711.9 0.7 481.7 482.2 1.48x
OpenScad/Openscad-Tests/3d-features/polyhedron-concave-test.scad 686.9 1.3 468.9 470.4 1.46x
OpenScad/Openscad-Tests/3d-features/polyhedron-cube.scad 625.3 0.8 483.2 485.1 1.29x
OpenScad/Openscad-Tests/3d-features/polyhedron-nonplanar-tests.scad 726.0 10.0 510.6 516.3 1.41x
OpenScad/Openscad-Tests/3d-features/polyhedron-soup.scad 711.8 1.4 494.7 495.8 1.44x
OpenScad/Openscad-Tests/3d-features/primitive-inf-tests.scad 726.7 1.0 501.6 502.5 1.45x
OpenScad/Openscad-Tests/3d-features/projection-extrude-tests.scad 686.0 0.7 479.1 480.2 1.43x
OpenScad/Openscad-Tests/3d-features/render-preserve-colors.scad 701.7 0.7 389.2 389.9 1.80x
OpenScad/Openscad-Tests/3d-features/render-tests.scad 531.5 2.5 535.7 541.5 0.98x
OpenScad/Openscad-Tests/3d-features/resize-convexity-tests.scad 715.2 0.9 500.6 501.2 1.43x
OpenScad/Openscad-Tests/3d-features/resize-tests.scad 744.7 7.2 547.2 552.6 1.35x
OpenScad/Openscad-Tests/3d-features/root-modifier.scad 645.9 0.5 468.7 469.1 1.38x
OpenScad/Openscad-Tests/3d-features/rotate-parameters.scad 652.4 2.8 465.3 468.1 1.39x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-angle.scad 672.1 2.6 500.2 501.7 1.34x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-tests.scad 772.1 2.0 630.3 632.0 1.22x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-touch-edge.scad 658.2 0.5 479.8 480.2 1.37x
OpenScad/Openscad-Tests/3d-features/rotate_extrude-touch-vertex.scad 652.8 0.5 487.3 487.8 1.34x
OpenScad/Openscad-Tests/3d-features/scale-mirror2D-3D-tests.scad 654.3 0.8 505.6 507.0 1.29x
OpenScad/Openscad-Tests/3d-features/scale3D-tests.scad 673.0 0.8 460.1 460.8 1.46x
OpenScad/Openscad-Tests/3d-features/sphere-tests.scad 795.6 2.2 548.4 550.7 1.44x
OpenScad/Openscad-Tests/3d-features/tessellation-text-test.scad 776.4 1.5 509.0 510.1 1.52x
OpenScad/Openscad-Tests/3d-features/transform-tests.scad 712.1 1.6 489.7 491.4 1.45x
OpenScad/Openscad-Tests/3d-features/union-coincident-test.scad 730.3 0.6 525.6 526.2 1.39x
OpenScad/Openscad-Tests/3d-features/union-tests.scad 733.1 1.2 539.8 541.3 1.35x
OpenScad/Parametric/candleStand.scad 987.7 3.8 713.9 717.2 1.38x
OpenScad/Parametric/sign.scad 562.9 1.7 517.1 518.7 1.09x
advanced.scad 737.1 0.9 481.0 482.8 1.53x
boolean_ops.scad 763.1 0.7 580.4 581.5 1.31x
cube.scad 626.5 0.5 480.4 481.3 1.30x
echo/functions/rands.scad 775.2 25.6 522.7 539.2 1.44x
echo/misc/allmodules.scad 753.2 3.1 500.6 503.8 1.50x
echo/misc/assert-tests.scad 734.3 0.8 515.2 516.0 1.42x
echo/misc/bad-stl-pcbvicebar.scad 731.9 0.7 470.8 471.4 1.55x
echo/misc/bad-stl-tardis.scad 724.9 0.6 497.7 498.3 1.45x
echo/misc/bad-stl-wing.scad 667.3 0.9 479.3 480.3 1.39x
echo/misc/builtin-invalid-range-test.scad 749.2 1.6 567.3 568.4 1.32x
echo/misc/builtins-calling-vec3vec2.scad 516.9 1.6 511.8 517.5 1.00x
echo/misc/children-tests.scad 677.8 2.3 485.0 487.3 1.39x
echo/misc/color-cubes.scad 680.6 0.6 493.4 495.3 1.37x
echo/misc/color-export.scad 526.8 0.7 405.3 406.0 1.30x
echo/misc/cube10.scad 442.7 0.3 427.4 427.7 1.04x
echo/misc/ifelse-ast-dump.scad 752.8 1.0 491.5 492.2 1.53x
echo/misc/internal-cavity-polyhedron.scad 714.5 2.2 473.3 474.5 1.51x
echo/misc/internal-cavity.scad 701.9 0.6 495.1 495.7 1.42x
echo/misc/let-module-tests.scad 707.0 2.5 490.6 499.7 1.41x
echo/misc/localfiles-test.scad 700.9 1.8 483.8 485.7 1.44x
echo/misc/localfiles_dir/localfiles-compatibility-test.scad 698.4 1.7 480.6 482.3 1.45x
echo/misc/nonmanifold-polyhedron.scad 646.9 0.7 522.3 523.1 1.24x
echo/misc/normal-nan.scad 720.5 0.7 494.9 495.5 1.45x
echo/misc/root-modifier-for.scad 652.9 0.5 489.7 490.2 1.33x
echo/misc/root-modifiers.scad 658.4 0.3 493.5 493.9 1.33x
echo/misc/rotate-empty-bbox.scad 717.3 0.6 488.9 489.5 1.47x
echo/misc/rotate_extrude-hole.scad 743.6 0.7 511.0 511.8 1.45x
echo/misc/search-tests.scad 708.8 6.5 436.6 443.2 1.60x
echo/misc/sfære.scad 450.9 0.4 356.0 356.3 1.27x
echo/misc/special-consts.scad 430.7 1.4 467.5 468.9 0.92x
echo/misc/utf8-☠-3D.scad 686.5 0.5 496.8 497.1 1.38x
echo/misc/vector-values.scad 642.7 1.7 486.6 488.2 1.32x
minkowski_test.scad 674.7 0.5 481.9 482.6 1.40x
table.scad 752.0 1.0 501.7 503.3 1.49x
temp_cylinder.scad 689.2 0.5 467.9 468.4 1.47x
temp_sphere.scad 679.1 0.5 480.8 481.3 1.41x
temp_text.scad 706.1 1.1 504.2 504.8 1.40x
test_extrude.scad 666.7 0.4 435.9 436.2 1.53x
tree.scad 790.3 1.4 738.7 740.0 1.07x
view_port.scad 756.4 1.5 543.1 544.4 1.39x

Time Comparison Chart

benchmark_comparison

So most of the time the OpenSCAD to TS compilation + the time to run TS file lesser than the time to compile OpenSCAD. I will prepare more decorated stats by categorizing these files according to what they test for.

@elalish

elalish commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Nice plot! That looks excellent and as expected. Good work.

@swaparup36

swaparup36 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author
benchmark_by_category

This is a category wise time comparison plot. Files that uses external library takes more time to compile and run as expected but still takes lesser time than openscad on average.

@pca006132

Copy link
Copy Markdown
Collaborator

Nice. Here are some follow up that we can look into later (not urgent, fix the failing tests first)

  1. It is interesting that for geometry tests, openscad is slower than wasm. What did you actually measure? It will be nice if you can share the benchmark script, e.g., limit number of cores, whether the timing includes file export, etc.
  2. For BOSL2 tests, maybe we can separate between the logic part and the geometry part by generating the csg tree, which is the logic part. Openscad has that. From that, we can see how much faster we are for the complex logic stuff BOSL2 is doing.
  3. We should investigate the few cases where we are significantly slower than openscad, at least understand why.

…ment handling for explicit undef, improved linear_extrude and rotate semantics, fixed range iteration edge cases
@swaparup36

Copy link
Copy Markdown
Contributor Author

I have pushed the fixes. Now all the test cases are passing. Here is the benchmark script - https://github.com/swaparup36/manifold/blob/openscad-to-manifold/bindings/wasm/openscad-compiler/test/benchmark.ts

For openscad I am measuring the time that openscad takes to compile and export the openscad code to .off file, and openscad is running it on single core.

I will do the separation of the logic part and geometry part by csg tree and check how much it takes for the logic part. And see why for some files the compiled one is slower.

@elalish

elalish commented Jul 19, 2026

Copy link
Copy Markdown
Owner

I have pushed the fixes. Now all the test cases are passing.

Doesn't look like all the tests are passing yet on the CI.

@swaparup36

Copy link
Copy Markdown
Contributor Author

Doesn't look like all the tests are passing yet on the CI.

Yes, that is because of some dependency of the compiler on external resources like fonts, images and other openscad libraries. First I thought that the tests are not passing because the output files are not pushed along with the examples, so I made the tests generate the output files before running the tests. But it is still not working because many of the openscad example taken here is dependent on some external fonts, images, libraries, so when these files are compiled the compiler takes care of these dependencies and generates runtime exports. These dependencies are in my local machine and compiler can find it by env variables, but the CI environment does not have those locally. Moreover the semantic test runs the example using openscad cli that is not present on the CI environment as well.

The fix I am thinking for this -
I can change the CI workflow and make it add those dependencies before running the tests and for the openscad cli thing - I think I should generate .echo outputs of example files by running them locally and then use those .echo outputs for test, rather than generating those outputs on the run.

@pca006132

Copy link
Copy Markdown
Collaborator

Yes, I think we should not have openscad binary in our CI. Looking at the CI failure though, I think you can address the simpler ones first, e.g., format your code, make sure the tests can find the runtime.js file, etc.

@swaparup36

Copy link
Copy Markdown
Contributor Author

Yes, I think we should not have openscad binary in our CI. Looking at the CI failure though, I think you can address the simpler ones first, e.g., format your code, make sure the tests can find the runtime.js file, etc.

Sure! I guess the runtime.js is not available because it is not built before running tests. I will add that before the tests run.

@swaparup36

swaparup36 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

I have written a script to separately measure the time taken by the logic and geometry part for the bosl2 files. Here are the results -

File OpenSCAD logic OpenSCAD geom Our logic Our geom Logic ratio Geom ratio Total ratio
BOSL2logo.scad 2713.3 526.8 1888.5 24.5 1.44x 21.47x 1.69x
attachments.scad 843.6 565.5 420.0 1.0 2.01x 555.12x 3.35x
boolean_geometry.scad 1889.2 289.6 1342.0 15.8 1.41x 18.33x 1.60x
fractal_tree.scad 40728.2 0.0 24475.1 27.7 1.66x 0.00x 1.37x
orientations.scad 723.2 1272.0 1765.5 24.0 0.41x 52.95x 1.11x
spherical_patch.scad 824.5 518.9 528.2 1.6 1.56x 321.60x 2.54x
spring_handle.scad 1629.9 392.4 880.8 5.8 1.85x 67.98x 2.28x

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.

4 participants