Title: Closing audit: prove the cumulative win of the optimisation series · Issue #187 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Closing audit: prove the cumulative win of the optimisation series · Issue #187 · purescript-lua/purescript-lua
X Title: Closing audit: prove the cumulative win of the optimisation series · Issue #187 · purescript-lua/purescript-lua
Description: Problem The optimisation and correctness series (#172-#186 plus the standing correctness bugs and #24) is motivated by a set of one-off measurements taken against a single commit. Each individual issue defends its own local win, but noth...
Open Graph Description: Problem The optimisation and correctness series (#172-#186 plus the standing correctness bugs and #24) is motivated by a set of one-off measurements taken against a single commit. Each individual i...
X Description: Problem The optimisation and correctness series (#172-#186 plus the standing correctness bugs and #24) is motivated by a set of one-off measurements taken against a single commit. Each individual i...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/187
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Closing audit: prove the cumulative win of the optimisation series","articleBody":"## Problem\n\nThe optimisation and correctness series (#172-#186 plus the standing\ncorrectness bugs and #24) is motivated by a set of one-off measurements taken\nagainst a single commit. Each individual issue defends its own local win, but\nnothing yet ties the series together into a single before/after statement about\nthe generated code as a whole. Without that, \"we made the backend faster\" stays\nan anecdote spread across a dozen issues rather than one reproducible number.\n\nThis issue is the closing bracket of the series: it records the baseline as it\nstands today so that, once the series lands, the same harness can be re-run and\nthe cumulative effect stated in one table. It is deliberately blocked by every\nissue in the series, so it naturally sorts last and cannot be closed until the\nwork it audits is done.\n\n### Baseline (today)\n\nTimings are from the generated-Lua performance analysis (PUC Lua 5.1.5,\n`os.clock`) and from the harness motivation in #172 (LuaJIT 2.1). Each row\ncompares the current generated shape against the idiomatic / uncurried\nequivalent.\n\n| Pattern | Current generated | Ideal | Slowdown | Runtime |\n|---|---|---|---|---|\n| `fib(30)`, arithmetic via IIFE lambdas | 0.457 s | 0.055 s | 8.3× | PUC 5.1.5 |\n| `>=` via `ordInt` dictionary (5e6) | 1.165 s | 0.027 s | 42.4× | PUC 5.1.5 |\n| Monadic `bind` ×3 chain (1e6) | 0.736 s | 0.012 s | 63.3× | PUC 5.1.5 |\n| Curried application `f(a)(b)` (5e6) | 0.339 s | 0.079 s | 4.3× | PUC 5.1.5 |\n| `M.field` access vs local (1e7) | 0.090 s | 0.037 s | 2.4× | PUC 5.1.5 |\n| `Maybe` alloc + match, hash-part vs array-part (2e6) | 0.158 s | 0.113 s | 1.4× | PUC 5.1.5 |\n| Curried hot loop `acc = add(acc)(i)` (2e7) | 0.91 s | 0.017 s | 54× | LuaJIT 2.1 |\n| `Data.Array.foldl` driven by a curried step | 0.99 s | 0.012 s | 85× | LuaJIT 2.1 |\n\nTwo LuaJIT facts from #172 anchor the trace-compilation story: the curried hot\nloop runs the same with the JIT on (0.91 s) and with `-joff` (0.90 s). The JIT\nbuys nothing because every partial application emits an `FNEW` (closure\ncreation), which is NYI, so the trace recording aborts and the loop start is\nblacklisted. The uncurried loop compiles to a single trace. The same blacklist\nhits the `Data.Array.foldl` FFI `for` loop because the trace has to inline the\ncurried callee.\n\n### FNEW census (to capture via the harness)\n\nThe deterministic LuaJIT counter from #172's approach is the CI-friendly\nregression metric: the number of `FNEW` bytecodes in `luajit -bl` of a linked\nartifact, split into main-chunk (runs once at init) vs function-body (runs per\ncall) occurrences. It is not in this baseline because the #172 harness does not\nexist yet and `luajit` is not in the dev shell. Capturing the `Data_Array.lua`\nFNEW split is part of running the harness for the before snapshot.\n\n## Approach\n\n1. Land #172 (the benchmark harness); it is a prerequisite of this audit.\n2. Once the series is closed, re-run the #172 harness over the same linked\n artifacts and micro/macro patterns.\n3. Fill the \"after\" column of the table above and the FNEW census, and state\n the cumulative multiplier per pattern.\n\nNo code change ships from this issue; its deliverable is the before/after\ntable and the FNEW deltas.\n\n## Verification / Measurement\n\nThe filled-in table above is the verification. The pass criterion is that the\nhot patterns move from the double-digit slowdowns recorded here toward small\nsingle-digit factors over idiomatic Lua, and that the function-body FNEW count\nin `Data_Array.lua` drops materially. The exact target numbers are set when the\nharness produces the \"after\" snapshot.\n\n## Prerequisites / Relations\n\nBlocked by the whole series: every correctness bug and performance\noptimisation whose effect this audit measures. Feature issues (#27, #72) are\nout of scope and are not blockers.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-06T11:58:50Z","url":"https://github.com/purescript-lua/purescript-lua/issues/187"}
| 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:72b60712-87fc-1e9c-85cf-58343fea19c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ABEE:19E4BB:659F80:83AB7B:6B00E059 |
| html-safe-nonce | b9c87c5db4f324ca7ef6bb8322cf4b31e7692c9fbc7f39eb1c27f178c67dd1dd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQkVFOjE5RTRCQjo2NTlGODA6ODNBQjdCOjZCMDBFMDU5IiwidmlzaXRvcl9pZCI6IjU4MTQ3MzQxOTU1MTUyNTI4MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f6a4bc7149db77eb206f2bdbebcc79982afec68b4f9f02016d9d9ec8dc88a44e |
| hovercard-subject-tag | issue:4818875426 |
| 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/187/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eb9b0b1e2529be75ec96f2c8a6c723bdc9199042d6f5b720e63501b058b2ef98/purescript-lua/purescript-lua/issues/187 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eb9b0b1e2529be75ec96f2c8a6c723bdc9199042d6f5b720e63501b058b2ef98/purescript-lua/purescript-lua/issues/187 |
| og:image:alt | Problem The optimisation and correctness series (#172-#186 plus the standing correctness bugs and #24) is motivated by a set of one-off measurements taken against a single commit. Each individual i... |
| 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