Title: Fold constant chains within a sweep instead of one fixpoint round per layer · Issue #328 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Fold constant chains within a sweep instead of one fixpoint round per layer · Issue #328 · purescript-lua/purescript-lua
X Title: Fold constant chains within a sweep instead of one fixpoint round per layer · Issue #328 · purescript-lua/purescript-lua
Description: Problem The optimizer's specialize+dce fixpoint converges on a constant chain one layer per round: a case-of-known-constructor fold exposes the next scrutinee only after the sweep that produced it finishes, so a bind-style chain of depth...
Open Graph Description: Problem The optimizer's specialize+dce fixpoint converges on a constant chain one layer per round: a case-of-known-constructor fold exposes the next scrutinee only after the sweep that produced it ...
X Description: Problem The optimizer's specialize+dce fixpoint converges on a constant chain one layer per round: a case-of-known-constructor fold exposes the next scrutinee only after the sweep that produced...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/328
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fold constant chains within a sweep instead of one fixpoint round per layer","articleBody":"## Problem\n\nThe optimizer's `specialize+dce` fixpoint converges on a constant chain one layer per round: a case-of-known-constructor fold exposes the next scrutinee only after the sweep that produced it finishes, so a `bind`-style chain of depth N needs on the order of N rounds to fold to its final value. This was invisible while nothing drove full-chain collapse, but the default directive pack (#242, PR #327) does exactly that: the ~300-deep golden stress chains (`Golden.LongApplyChain`, `Golden.LongBindFlipped`, `Golden.LongWriterBind`) diverged at the historical 100-round backstop, still diverged at 400, and converged only under 1000 (measured by bisecting the cap). PR #327 raised `maxFixpointIterations` from 100 to 1000 as a stopgap, which keeps the checked runner honest but makes a genuine loop bug burn 1000 whole-module sweeps before reporting, and leaves compile time O(depth × module size) for deep chains.\n\n## Approach\n\nMake the chain fold depth-independent within one round: when a rewrite fires, re-examine the rewritten node (and its new parent redex) instead of deferring to the next whole-module sweep — a local worklist inside the bottom-up traversal, bounded by the usual growth vetoes so termination arguments are unchanged. With rounds no longer proportional to chain depth, `maxFixpointIterations` can return to a small value that catches over-reporting passes quickly.\n\n## Prerequisites / Relations\n\nFollow-up to #242 / PR #327 (which introduced the 1000-round stopgap and the goldens that exercise it). Independent of the directive machinery itself — the same round-scaling applies to any rewrite cascade that exposes one redex per fold.\n\n## Verification / Measurement\n\nWith the local worklist, the three ~300-deep stress goldens converge within a small fixed round count (assert by lowering the cap in the checked runner used by the test suite); all goldens byte-identical to the current accepted state; wall-clock of the golden suite drops measurably (the Long* modules dominate it today).\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-28T10:15:03Z","url":"https://github.com/purescript-lua/purescript-lua/issues/328"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:91f3240e-0a08-4b05-2c9e-02c40eea2f50 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8210:3E4205:7090CB:98BA0F:6B00DB6C |
| html-safe-nonce | 02f3d41fd72daeb5851d655c90d021363e94876f6412d8bd4033f26136accff5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjEwOjNFNDIwNTo3MDkwQ0I6OThCQTBGOjZCMDBEQjZDIiwidmlzaXRvcl9pZCI6IjY2MDcwNTE2ODQ3NjM5ODI3MDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 32df824f2cd868d54b070eaeb07face28fd54053ae95cdb58e9e1c3ac472dd8b |
| hovercard-subject-tag | issue:4997427674 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/purescript-lua/purescript-lua/328/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ee1b87947b912e0b121baa1ff5d176be93df3e0933b22117ef2d2893aea1b5f2/purescript-lua/purescript-lua/issues/328 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ee1b87947b912e0b121baa1ff5d176be93df3e0933b22117ef2d2893aea1b5f2/purescript-lua/purescript-lua/issues/328 |
| og:image:alt | Problem The optimizer's specialize+dce fixpoint converges on a constant chain one layer per round: a case-of-known-constructor fold exposes the next scrutinee only after the sweep that produced it ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Unisay |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/purescript-lua/purescript-lua git https://github.com/purescript-lua/purescript-lua.git |
| octolytics-dimension-user_id | 131581790 |
| octolytics-dimension-user_login | purescript-lua |
| octolytics-dimension-repository_id | 587200487 |
| octolytics-dimension-repository_nwo | purescript-lua/purescript-lua |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 587200487 |
| octolytics-dimension-repository_network_root_nwo | purescript-lua/purescript-lua |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width