Skip to content

Avoid CPS effect type instantiation#2814

Open
plajjan wants to merge 1 commit into
mainfrom
cps-quicktype-optimizations
Open

Avoid CPS effect type instantiation#2814
plajjan wants to merge 1 commit into
mainfrom
cps-quicktype-optimizations

Conversation

@plajjan
Copy link
Copy Markdown
Contributor

@plajjan plajjan commented May 27, 2026

Summary

  • Read CPS call effects through schemaOf instead of forcing the full callee type with typeOf.
  • Dropped the typed-local initializer QuickType skip after review. That path can lose argument coercions because genExp/qType also rewrites call arguments with qMatch.

Performance

Measured on the 61 MB concurrent_typecheck_class_heavy fixture with out cleared before each run:

compiler-bench --pipeline dist/base/out/types test/compiler/concurrent_typecheck_class_heavy/src/concurrent_typecheck_class_heavy.act +RTS -T -A64M -RTS

The earlier combined numbers included the dropped QuickType commit and no longer apply. This is the current one-commit branch result compared with the previous baseline run from the compiler-bench head now merged to main.

Baseline:
parse 10.655304s
front 347.252679s
front_timing env 0.0s kinds 5.467403s types 341.778869s
back 153.737079s
back_stats alloc 371524555088 copied 90198456432 max_live 12653155120 max_mem 37528535040 gc_elapsed 35213930000 gcs 424
back_timing normalize 0.0s deactorize 3.600145s cps 1.0e-6s llift 37.588621s boxing 0.0s codegen 1.0e-6s render 107.705677s write 4.842622s

CPS-only branch:
parse 10.01912s
front 342.031121s
front_timing env 1.0e-6s kinds 5.433949s types 336.579875s
back 168.719363s
back_stats alloc 369063478000 copied 90455088080 max_live 13566249416 max_mem 36836474880 gc_elapsed 41838148000 gcs 422
back_timing normalize 0.0s deactorize 3.987647s cps 1.0e-6s llift 40.53988s boxing 0.0s codegen 1.0e-6s render 119.530711s write 4.661106s

This run does not show a wall-time improvement for the remaining CPS-only change. Back allocation is slightly lower, but back wall time is worse in this sample.

Check

stack --stack-yaml compiler/stack.yaml build libacton:exe:compiler-bench

CPS only needs the callee effect when deciding whether a call needs
continuation or mutation handling. The previous check used typeOf on
the callee, which can instantiate the full function type even though
the effect is already present in the schema for the common cases.

Read the effect through schemaOf instead. Ordinary variables and
attribute selections keep the same effect result without forcing the
extra type instantiation, while expressions whose schema must still be
derived keep using the existing schema path.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8461bf2f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread compiler/lib/src/Acton/CodeGen.hs Outdated
_ -> genExp env t e
else genExp env t e
else if B.isUnboxable t
then gen env e
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve argument coercions for unboxed initializers

For unboxable local declarations this now bypasses genExp, but genExp does more than the final result cast: it runs qType, whose Call case applies qMatch to coerce each argument to the callee's parameter types. When an initializer such as x: int = f(v) calls a function whose argument needs one of those non-unboxable casts (for example an optional or superclass parameter), the generated call now uses raw gen env e and omits the required argument coercion, while the old path still avoided any final cast because adjust is a no-op for unboxable result types. This can produce invalid or mis-typed C for typed local initializers even though the target itself is unboxable.

Useful? React with 👍 / 👎.

@plajjan plajjan force-pushed the cps-quicktype-optimizations branch from d8461bf to 09dbe07 Compare May 27, 2026 20:10
@plajjan plajjan changed the title Avoid redundant type work in back passes Avoid CPS effect type instantiation May 27, 2026
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