Title: Derived-always specialization of an over-budget instance method duplicates the dictionary read per site · Issue #326 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Derived-always specialization of an over-budget instance method duplicates the dictionary read per site · Issue #326 · purescript-lua/purescript-lua
X Title: Derived-always specialization of an over-budget instance method duplicates the dictionary read per site · Issue #326 · purescript-lua/purescript-lua
Description: Problem Directive derivation (#241) marks a saturated specialization always-inline, and the whole-binding paste copies its unresolved right-hand side into every use site — e.g. the float purs's CSE emits for a repeated dictionary applica...
Open Graph Description: Problem Directive derivation (#241) marks a saturated specialization always-inline, and the whole-binding paste copies its unresolved right-hand side into every use site — e.g. the float purs's CSE...
X Description: Problem Directive derivation (#241) marks a saturated specialization always-inline, and the whole-binding paste copies its unresolved right-hand side into every use site — e.g. the float purs's...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/326
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Derived-always specialization of an over-budget instance method duplicates the dictionary read per site","articleBody":"## Problem\n\nDirective derivation (#241) marks a saturated specialization always-inline, and the whole-binding paste copies its unresolved right-hand side into every use site — e.g. the float purs's CSE emits for a repeated dictionary application, `bind = Control.Bind.bind bindStateT` (verbatim shape from `Golden.CprState.Test`'s corefn). The intended cascade is: the accessor resolves, the concrete instance method pastes, and the constructor folds collapse the chain at each site. When the concrete method exceeds `inlineSizeBudget` and the instance dictionary carries no `.method always` field directive, `resolveDictionaryProp` declines the last step and every site is left holding `dict.method(...)` — one dictionary field read per site, where the pre-derivation shared binding (`local bind = bindStateT.bind`, a single read at module init) was strictly better on both code size and speed (Lua 5.1 locals beat hash lookups per call). The derivation currently cannot see this coming: at derivation time the method's settled size is not yet known.\n\n## Approach\n\nCandidates, in leaning order: (a) a sharing-repair pass after the specialize fixpoints that re-binds a dictionary field read surviving at two or more sites to a shared top-level binding — the dictionary analogue of `shareForeignAccessors` (#248), repairing the shape regardless of which pass duplicated it; (b) budget-aware derivation that declines always-inline when the specialization's settled form would not resolve at sites — requires anticipating the specialize fixpoint's dictionary resolution at derivation time, a fragile layer crossing; (c) letting a derivation-originated paste bypass the field-resolution budget — changes the calibrated growth semantics and needs measurement before committing. Lean (a).\n\n## Prerequisites / Relations\n\nBuilds on #241. Pairs with the #242 default directive pack: the pack is what will put `arity=N` on class accessors at scale, so pack tuning should assume this stall exists until fixed. A regression case needs no pack — a golden with a directive-annotated accessor and an over-budget instance method reproduces it.\n\n## Verification / Measurement\n\nA golden with a class accessor under `arity=1` and an instance method over the size budget shows the sites sharing one field read rather than one read per site, with eval output unchanged. Size/speed effect on the corpus measured through the bench harness (#172) once the pack lands directives in the package set.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-28T07:48:38Z","url":"https://github.com/purescript-lua/purescript-lua/issues/326"}
| 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:f8dc172d-f896-4204-de9b-7fdd7cea27b8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE06:2E124E:4BD4B6:624C83:6B00D94B |
| html-safe-nonce | 5f06f58cba7d04160cdc78d46b66017ceeb909284b4fc6b2343ac116762b7c72 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTA2OjJFMTI0RTo0QkQ0QjY6NjI0QzgzOjZCMDBEOTRCIiwidmlzaXRvcl9pZCI6IjU4Mjk2MTcyNDA3NDM0MDE4MDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a7aba55cdfe93b61f73819314139a80c37982b4ce36a0a1056b1d96c306b8e71 |
| hovercard-subject-tag | issue:4996239710 |
| 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/326/issue_layout |
| twitter:image | https://opengraph.githubassets.com/847af45fb5a940edd203c9448fe19982652b8668d8f6253563f494dfb3de1fc2/purescript-lua/purescript-lua/issues/326 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/847af45fb5a940edd203c9448fe19982652b8668d8f6253563f494dfb3de1fc2/purescript-lua/purescript-lua/issues/326 |
| og:image:alt | Problem Directive derivation (#241) marks a saturated specialization always-inline, and the whole-binding paste copies its unresolved right-hand side into every use site — e.g. the float purs's CSE... |
| 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 | a481f62a1e04c9b9bdcb5628230682c66d59006f5b13b080f79cba84a176905b |
| 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 | 84c8c5cc25e2fb7f2308428458538436baecc6d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width