Skip to content

Optimization work. - #163

Merged
galenhuntington merged 1 commit into
masterfrom
optimize
Jul 8, 2026
Merged

Optimization work.#163
galenhuntington merged 1 commit into
masterfrom
optimize

Conversation

@galenhuntington

Copy link
Copy Markdown
Owner

This PR addresses old annotations and settings to squeeze out performance, which are barely relevant today, and may indeed be obsolete:

  • Two fields in HState were inadvertently not strict; this is fixed.
  • A few other data fields are made strict which seem that they clearly should be.
  • -funbox-strict-fields is dropped per a conversation with Claude. Modern GHC has better heuristics than it used to, and this setting appears to make performance microscopically worse.
  • Nearly all INLINEs are dropped. Claude advised me to keep them, but I think that is out of bias towards the status quo ante, whereas I see unnecessary annotations as distracting clutter. Apparently they do nothing since inlining happens anyway since GHC knows they're small, and most are in-module so there's not even a need. I kept the one that is cross-module, though it is small enough to likely not need it.
  • Nearly all UNPACKs are dropped. Claude similarly advised me to keep them, but I see no benefit. The Msg fields in question are immediately copied into a Just where they're boxed anyway. The style in Segment is looked up in a map and so presumably is always boxed at that point (plus it's almost always pulled from a data structure where it's already boxed, so why flatten?). I only kept the Segment ByteString as unpacked since maybe in some cases there is no boxing.

In general, for this app, these are imperceptible sub-microsecond differences, so my inclination is to not annotate, that is, not second-guess GHC's defaults with extra stuff when it doesn't matter anyway. But if it's "right" to do it, it still makes sense, and there is a case for leaving a couple undisturbed. Hence the above choices.

Unrelatedly, I tweaked a test from the last PR to spare an import, and trimmed a few comment lines.

@galenhuntington
galenhuntington merged commit 0ac68c8 into master Jul 8, 2026
6 checks passed
@galenhuntington
galenhuntington deleted the optimize branch July 8, 2026 18:53
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