Repository navigation
skdb: pass FLOAT fields to JS as raw f64 instead of text - #1720
Merged
Merged
Conversation
mbouaziz
enabled auto-merge
November 19, 2026 22:50
mbouaziz
disabled auto-merge
November 19, 2026 23:18
The OJS marshalling path formatted every float with Float.toString (Ryu d2s), passed the string pointer across the wasm boundary, and the TS client ran importString + parseFloat on it. Give the wasm extern a Float (f64) parameter instead: no formatting, string allocation, or parsing per value, and inf/nan/-0.0 cross exactly. The native stub in runtime64_specific.cpp takes a double; the OJS path is a no-op natively as before. Measured with a node benchmark against the wasm dev build (select of 8192 FLOAT rows materialized as JS objects, median of 50 runs, interleaved A/B): 4.3-5.6 ms before vs 1.4-2.2 ms after, i.e. ~3x faster end-to-end (~0.3-0.4 us saved per float row). Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Co-Authored-By: Claude Opus 5.5 (Anthropic, via Mistral Vibe; thinking: high) <noreply@anthropic.com>
Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai> Co-Authored-By: Claude Opus 5.5 (Anthropic, via Mistral Vibe; thinking: high) <noreply@anthropic.com>
mbouaziz
force-pushed
the
skdb-float-f64
branch
from
November 19, 2026 23:18
42b022a to
4f37798
Compare
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.
What
The OJS marshalling path (wasm skdb -> JS objects) sent every FLOAT as
text: the wasm side ran
Float.toString(Ryud2s), passed the stringpointer across the boundary, and the TS client did
importString+parseFloat(sql/ts/src/skdb_skdb.ts). This changesSKIP_push_object_field_floatto take a rawFloat— an f64 parameteron wasm — so the double crosses directly: no formatting, no string
allocation, no parsing per value. As a bonus,
Infinity/NaN/-0.0cross exactly (the text path relied on
parseFloatagreeing withSkip's spelling).
Changes:
sql/src/SqlValue.sk:jsPushObjectFieldFloat(Float), call sitepasses
fdirectly.sql/ts/src/skdb_skdb.ts: the import is now(v: float) => voidandassigns
this.object[field_name] = v(ToWasm interface, LinksImpl,Manager wiring).
skiplang/prelude/runtime/runtime64_specific.cpp: native stub takesdouble(the OJS path is a no-op natively, as before).sql0.3.0 -> 0.3.1,std0.8.1 -> 0.8.2.Measurement
Node benchmark against the wasm dev build (
createSkdb({asWorker: false}), 8192 FLOAT rows with full 17-digit mantissas,select f from tmaterialized as JS objects, median of 50 runs,interleaved A/B with both variants built from the same tree):
~3x faster end-to-end on float-heavy results (~0.3-0.4 us saved per
float row; the rest of the time is wasm query execution + object
allocation, unchanged). A
count(f)control shows no change, asexpected.
Validation
tsctypecheck, eslint, prettier, skfmt all clean on the touchedfiles.
select 0.1+0.2, 5e-324, -0.0;prints0.30000000000000004|5.0e-324|-0.0.sql/unit_tests.shwith the native binary: 83 OK, 0 FAILED(incl.
PARSE FLOAT,FLOAT ROUNDTRIP).0.1+0.2 === 0.30000000000000004,5e-324,1.7976931348623157e308bit-exact,-0.0preserved(
Object.is(row, -0)).Notes
trailers); validation performed in-session as described above.