Repository navigation
Squint get - #56
Merged
Merged
Squint get#56
Conversation
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.
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.
No description provided.