Repository navigation
Recover 1.42's BOSL2 slowdown: short-circuit assert, faster number formatting - #266
Merged
Merged
Conversation
A passing assert() now evaluates its condition and nothing else, the way `||` skips its right operand -- a deliberate divergence from OpenSCAD, which evaluates every argument first. BOSL2 validates nearly every call with assert(cond, str(...)), and building those never-shown messages was ~4% of its evaluation. A failing or condition-less assert evaluates every other argument after the condition, in source order, so its output is unchanged; unexpected-argument warnings still print on every call. The argument layout (condition/message indices, whether anything warns) is worked out once per compiled call site (AssertLayout), and the VM compiles the condition, a JumpIfFalse to the failure path, and an AssertPass op only when there are warnings or chained children to run. BOSL2 replay sample: 836.1G -> 803.6G instructions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For a normal double the shortest round-trip rendering rounds to 6 digits exactly as the value does, except when it is itself a 7-digit tie; only then (and for subnormals) does the exact printf path run. Byte-identical to the previous output over a fuzz of 139M doubles (random bits, short decimals and their neighbours, ties at every exponent, integers, powers of two and ten, subnormals, specials). fmt.scad micro-benchmark: 1.87G -> 0.91G instructions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…positional Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Evaluator 1.42.0 made BOSL2 evaluation ~5% slower (BOSL2 docs build 8.34T → 8.67T instructions, 1.37 vs 1.44). Traced to 1.42's eager assert() messages and exact six-digit number formatting. This takes it back below 1.41.0.
||. A deliberate divergence from OpenSCAD, which evaluates the message eagerly, so a message with echo()/an undefined name/a warning is silent when the assert passes. Failure output is unchanged; unexpected-argument warnings still print every call (decided once per call site). Interpreter and VM.C++ 1463 pass; bindings 63 pass. New tests cover the short-circuit both ways (passing: silent; failing: side effects + same ERROR), warnings on passing asserts, ties/subnormals.
🤖 Generated with Claude Code