Repository navigation
perf: copy plain host results and JSON directly, and skip conversion arrays for primitive string and Math arguments - #107
Merged
Conversation
…arrays for primitive string and Math arguments
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.
Low-risk fast paths in the host boundary, string/Math built-ins, cycle checks and property enumeration. No opcode, compiler or prelude change, so the build id and snapshots are unaffected.
Changes, each measured with a targeted program (fresh process per run, median of 5 runs, best of 3 alternating base/new runs; the machine was loaded, load average ~10–16):
Array.prototype/Object.prototype/ null prototype) copy without theinstanceofchain, per-value closures andObject.entries, straight into fresh slotsruntime/extensions.tscopyPlainwithPrimitivesand its array copies (simple,includes/startsWith/endsWith);containsOpaqueReference/containsRuntimeReferencereturn early for primitivesstdlib/string.ts,runtime/references.tsindexOf/slice/includescallspadStart+splitMathfunctions take number arguments directlystdlib/math.tsMath.abs/Math.maxruntime/references.tshasCircularReferencefilter20k objects ×5PUT_ELEMappend/overwrite fast path also for object values, after the cycle checkvm.tsout[i] = { i }200kObject.keys/Object.entriesin one pass over the slots when no key is an index;parseArrayIndextests the first character before the regexruntime/objects.tskeys+entrieson 5 keysJSON.parseresults (fromJson) written straight into fresh slots, primitives without a recursive calldata.tsvm.tsexecDefineFieldruntime/objects.ts,vm.tsNumber.isIntegerpush({ i })script/bench.ts(best of 6 alternating runs, ms;--mixedis one process, all cases):Behaviour kept the same (new
test/fast-paths.test.ts, which also passes ondev):fromHostdoes; the first cut took primitives one level down without the check.fromJsonkeeps holes in bound arrays (keptmapinstead of afor…ofthat filled them withundefined).__proto__as an own data key (host results,JSON.parse, object literals), duplicate and accessor keys in literals, spread, non-enumerable and symbol keys, cycle errors through arrays, and string/Math arguments withtoString/valueOfare covered.Objwith no guard andintrinsic0), where they match whatdefinedoes. Class fields still go throughdefineOwnProperty.bun run checkpasses.