Repository navigation
Conversation
containsOpaqueReference and containsRuntimeReference made a set, a list and an iterator to walk a value that, for most arguments, is a string or a number.
…iled once Making a run's several hundred built-ins was 78 µs of the 80 µs return 1 took, and 63% of script/corpus.ts. A run that ends on its own, having changed no intrinsic (each is still as made, by the dirty bit snapshots already keep) and left arrays iterable directly, now leaves its runtime for the next run of the same Runtime (Interpreter.reusable, recycle). That run gets host globals, bindings, global scope, console state, intrinsic names and a VM of its own; only the built-ins carry over. Up to four are kept. A run that changed a built-in, failed, timed out, was aborted or was suspended leaves none, and the round-trip test mode takes none. The last 64 programs compiled are kept by their text, so one run again is not parsed and compiled again. test/reuse.test.ts runs 29 programs that try to leave something behind (properties on built-ins and their functions, freezing, deleting, the array iterator, console state, a run left waiting), each followed by a probe run. script/corpus.ts, median µs: setup 64 to 6; return 1 from 65 to 6; the corpus 1,750 to about 465 (about 730 for programs not seen before).
This branch has not been deployed
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.
Stacked on #98. Takes the TypeScript implementation from about 1.1x to about 4x on
script/corpus.tsagainstdev(1,918 → about 465 µs; about 730 µs for programs not seen before), and the fixed cost of a run from 80 µs to about 6.What it does
return 1took. A run that ends on its own having changed no intrinsic now leaves its runtime for the next run of the sameRuntime. That run gets its own host globals, bindings, global scope, console state, intrinsic names and VM; only the built-ins carry over. Up to four are kept perRuntime.The thing to review: isolation
Reuse is only right if "changed no intrinsic" is detected completely. It rests on the dirty bit snapshots already keep on every intrinsic (
Obj.intrinsic, flipped bychanged), plus the array-iteration protector. A run leaves no runtime if it changed a built-in, failed, timed out, was aborted or was suspended; the round-trip test mode takes none.test/reuse.test.tsruns 29 programs that try to leave something behind (properties on built-ins, on built-in functions and accessor getters, freezing, deleting,setPrototypeOf, the array iterator, console state, a run left waiting), each followed by a probe run on the same runtime. That is evidence, not a proof: a built-in that kept state outside its properties, where the dirty bit does not see it, would cross runs. I found none.Costs
Runtimestill pays the full setup.Runtime, roughly 0.5 MB each.Not reached
The programs' own execution is about 430 µs of the corpus and was 28% of it on
dev, so about 4.5x is the ceiling without a faster dispatch loop.bun testandbun run test:roundtrippass. Numbers are wall-clock medians on a busy machine.