Skip to content

Squint get - #56

Merged
borkdude merged 5 commits into
mainfrom
squint-get
Sep 18, 2026
Merged

borkdude merged 5 commits into
mainfrom
squint-get

Conversation

@borkdude

Copy link
Copy Markdown
Contributor

No description provided.

Calling a map is idiomatic Clojure and squint does not support it, so every
lookup of a type in arg-coercer, ret-converter, node-type, sizes,
scalar-get, scalar-set and array-carriers now goes through get. The other
hosts are unaffected.

The squint run goes from 67 to 119 assertions and from 10 errors to 6.
What is left is nested layouts, an array of structs and a struct holding an
array, plus the wording of a few error messages. Scalar calls, memory,
flat arrays, flat structs and callbacks pass.
Three things stood between squint and a green suite.

The codec cache was keyed on [kind lay], where lay is the resolved layout
map. A squint map key that holds a map matches any other such key, so the
second nested layout to be written got the codec of the first: a rect was
encoded as a point. The key is now the layout as it was written, which holds
no maps.

An error message prints a keyword as a quoted string under squint, since a
keyword is a string there. The message patterns in the suite accept both.

A symbol is a string too, so it carries no metadata and defcfn-form cannot
name a var. macro-form-test is skipped under squint, which the suite detects
by asking whether a keyword is a string.

squint: 15 tests, 176 assertions. nbb, ClojureScript and shadow-cljs are
unchanged at 190, babashka at 194 and the JVM at 368.
…here

squint compiles a collection to a plain JS value, and a map key that is one
is coerced to a string. Nesting flattens, so [:array [:array :int 2] 3] and
[:array [:array :int 2 3]] are one key there. The three caches are keyed by
a layout, so under squint the key is printed, which keeps the brackets.
ClojureScript hashes the collection as before.

The namespace asks whether a keyword is a string to know which host it is
on. sizeof of the two layouts above now answers 24 and 32 under squint.
… time

Printing the key on every call cost twice a struct write and three times a
sizeof under squint. A layout is data and does not change, so its key is
remembered in a WeakMap under its own identity: a layout held in a var pays
once, and the numbers are back where a raw key had them, 698 ns for a struct
write against 1545 with pr-str and 711 with the key that was wrong.

JSON.stringify rather than pr-str, because it keeps the brackets and runs
native.
Calling a map is what the code did before squint came along, and it is
faster on a host that allows it. Each table is now also bound as a function:
the map itself on nbb and ClojureScript, a get on squint. The call sites
read as they did, and the few percent that get cost on nbb is gone, 903 ns
against 881 for a scalar read where it was 1078 against 1017.
@borkdude
borkdude merged commit 60517d0 into main Sep 18, 2026
26 checks passed
@borkdude
borkdude deleted the squint-get branch September 18, 2026 15:35
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