Convert the expr codec from nightly coroutines to a manual iterator and push-struct - #126
Closed
MesTTo wants to merge 1 commit into
Closed
Convert the expr codec from nightly coroutines to a manual iterator and push-struct#126MesTTo wants to merge 1 commit into
MesTTo wants to merge 1 commit into
Conversation
…h-struct item_source/item_sink/apply_e used nightly #[coroutine] generators. Because apply_e is #[inline(never)] and the sink was passed as &mut Pin into it, the coroutine resume stayed opaque across that boundary (LLVM does not inline a coroutine resume across the Pin/poll edge), paying state-machine overhead on a trivial per-item body. Convert item_source to an ItemSource struct impl Iterator and item_sink to an ItemSink push-struct (push/finish; the arity stack was dead weight, since apply_e never reads the sink's completion); apply_e drops the Coroutine/Pin bound and pushes. The macro's $es:ident by-name contract keeps the space.rs call sites unchanged, and eval's quote loop becomes a plain for. Measured (min-of-3, interleaved against the pre-change binary): bench process_calculus 31,771,686 -> 28,729,938 us, 9.6% faster; Nil's bfc chainer at proof size 19 as a plain MM2 run 14,057 -> 11,279 ms, 19.8% faster; bench finite_domain 71,632 -> 67,313 us. Byte-identical: every kernel/resources program at several step depths, the bfc MM2 reproduction, and a 4096-hub triangle produce identical result spaces against the pre-change binary. Two expr differentials pin the conversion: diff_item_sink_old_vs_new keeps a frozen reference coroutine sink and asserts byte-equal output over a ground and adversarial corpus, and diff_apply_e_emit_vs_unify_oracle cross-checks the apply_e emit against the independent Expr::unify substitution path. mork-expr 17/17.
Collaborator
|
Hi! Appreciate your work here. The MORK kernel is closed to constant-time speed-ups until the asymptotic runtime has no known deficiencies. This prevents us from locking out much more impactful changes. Thanks for your understanding. |
Contributor
Author
|
Closing per the maintainer's guidance that the MORK kernel is closed to constant-time speed-ups until the asymptotic runtime has no known deficiencies. The codec coroutine->iterator conversion is a constant-factor change, so parking it. |
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.
item_source,item_sink, andapply_eused nightly#[coroutine]generators.apply_eis#[inline(never)]and received the sink as&mut Pin, so the coroutine resume stayed opaqueacross that boundary (LLVM does not inline a resume across the Pin/poll edge), paying
state-machine overhead on a trivial per-item body.
This converts
item_sourceto anItemSourcestruct implementingIterator,item_sinkto anItemSinkpush-struct (push/finish; the old arity stack only existed to signal completion,which
apply_enever reads), andapply_eto take the sink directly, dropping the Coroutine/Pinbound. The
apply_e_clears_stacks_and_cycles_checkmacro keeps its by-name contract, so thespace.rscall sites are unchanged, and eval's quote loop becomes a plainfor. Twodifferentials pin the conversion:
diff_item_sink_old_vs_newkeeps a frozen copy of the oldcoroutine sink and asserts byte-equal output and counts over a ground and adversarial corpus
(coreference, varrefs at the intro boundary, deep nesting, self-referential shapes), and
diff_apply_e_emit_vs_unify_oraclecross-checks theapply_eemit against the independentExpr::unifysubstitution path.Measured, min of 3 interleaved against the pre-change binary on one machine:
bench process_calculus: 31,771,686 -> 28,729,938 us, 9.6% fasterbench bfcprogram as a plainmork runMM2 file, proof size 19, 801steps, a 2.9M-atom space): 14,057 -> 11,279 ms, 19.8% faster
bench finite_domain: 71,632 -> 67,313 usByte-identical along the way: every
kernel/resourcesprogram at several step depths, the bfcreproduction, and a 4096-hub triangle produce identical result spaces against the pre-change
binary. mork-expr tests 17/17.
Independent of #124; the two touch disjoint files.