Skip to content

skdb: pass FLOAT fields to JS as raw f64 instead of text - #1720

Merged
mbouaziz merged 2 commits into
mainfrom
skdb-float-f64
Nov 19, 2026
Merged

mbouaziz merged 2 commits into
mainfrom
skdb-float-f64

Conversation

@mbouaziz

Copy link
Copy Markdown
Contributor

What

The OJS marshalling path (wasm skdb -> JS objects) sent every FLOAT as
text: the wasm side ran Float.toString (Ryu d2s), passed the string
pointer across the boundary, and the TS client did importString +
parseFloat (sql/ts/src/skdb_skdb.ts). This changes
SKIP_push_object_field_float to take a raw Float — an f64 parameter
on wasm — so the double crosses directly: no formatting, no string
allocation, no parsing per value. As a bonus, Infinity/NaN/-0.0
cross exactly (the text path relied on parseFloat agreeing with
Skip's spelling).

Changes:

  • sql/src/SqlValue.sk: jsPushObjectFieldFloat(Float), call site
    passes f directly.
  • sql/ts/src/skdb_skdb.ts: the import is now (v: float) => void and
    assigns this.object[field_name] = v (ToWasm interface, LinksImpl,
    Manager wiring).
  • skiplang/prelude/runtime/runtime64_specific.cpp: native stub takes
    double (the OJS path is a no-op natively, as before).
  • Patch bumps: sql 0.3.0 -> 0.3.1, std 0.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 t materialized as JS objects, median of 50 runs,
interleaved A/B with both variants built from the same tree):

variant run 1 run 2
text + parseFloat (base) 4.3 ms 5.6 ms
raw f64 1.4 ms 2.2 ms

~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, as
expected.

Validation

  • tsc typecheck, eslint, prettier, skfmt all clean on the touched
    files.
  • Native skdb dev build compiles/links with the new stub signature and
    select 0.1+0.2, 5e-324, -0.0; prints 0.30000000000000004|5.0e-324|-0.0.
  • sql/unit_tests.sh with the native binary: 83 OK, 0 FAILED
    (incl. PARSE FLOAT, FLOAT ROUNDTRIP).
  • Wasm bench correctness: 0.1+0.2 === 0.30000000000000004,
    5e-324, 1.7976931348623157e308 bit-exact, -0.0 preserved
    (Object.is(row, -0)).
  • CI (incl. the skdb-wasm playwright suite) on the branch head.

Notes

  • AI assistance: commits generated with Mistral Vibe (Co-Authored-By
    trailers); validation performed in-session as described above.

@mbouaziz
mbouaziz enabled auto-merge November 19, 2026 22:50
@mbouaziz
mbouaziz disabled auto-merge November 19, 2026 23:18
mbouaziz and others added 2 commits 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
mbouaziz merged commit a2844fd into main Nov 19, 2026
1 check was pending
@mbouaziz
mbouaziz deleted the skdb-float-f64 branch November 19, 2026 23:19
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.

1 participant