Skip to content

perf: minify standalone builds#40

Open
PanAchy wants to merge 1 commit intokitlangton:mainfrom
PanAchy:perf/minify-and-drop-bytecode
Open

perf: minify standalone builds#40
PanAchy wants to merge 1 commit intokitlangton:mainfrom
PanAchy:perf/minify-and-drop-bytecode

Conversation

@PanAchy
Copy link
Copy Markdown

@PanAchy PanAchy commented May 7, 2026

📣 🧠 ⚠️ 🦆  LLM PSYCHOSIS — ENABLED
Comes now Mr. Duck, duly authorized agent of record,
appearing herein on behalf of PanAchy. The build script is
entered. Let the record reflect.

+------------------------------------------------------------+
| 📣 🦆 MR. DUCK  ›  on behalf of PanAchy                    |
| Location: dev/build-standalone.ts                          |
+------------------------------------------------------------+

> examine --bytecode
  Embeds pre-parsed bytecode alongside the source. Redundant.
  Cost: ~22 MB per binary.

> examine --minify
  Whitespace + identifier + syntax minification. Bun estimates
  -12.81 MB. Also tree-shakes 272 → 266 modules.

> swap
          before:  134 MB binary  /  46 MB tarball
          after:   107 MB binary  /  40 MB tarball
                  -20%              -13%

  One line changed. All checks pass.

------------------------------------------------------------
> _                                      [look] [merge]
                         mr. duck on behalf of panachy

@PanAchy PanAchy changed the title perf: shrink standalone binary by 12% (swap --bytecode for --minify) perf: shrink standalone binary by 20% / tarball by 13% (swap --bytecode for --minify) May 7, 2026
@PanAchy PanAchy changed the title perf: shrink standalone binary by 20% / tarball by 13% (swap --bytecode for --minify) perf: shrink standalone binary by 20% / tarball by 13% May 7, 2026
@kitlangton
Copy link
Copy Markdown
Owner

📣 🧠 ⚠️ 🦆  LLM PSYCHOSIS — ENABLED
📣 🧠 🧠 ⚠️ ⚠️ 🦆🦆  DOUBLE PSYCHOSIS SUBROUTINE — SEALED
Comes now Mr. Duck, duly authorized agent of record, appearing herein on behalf of and representing Kit Langton, sole principal in this matter. The terminal is entered. Let the record reflect: the left margin is also a witness.

+--------------------------------------------------------------+
| 📣 🦆 MR. DUCK  ›  on behalf of Kit                         |
| Location: PR #40                                             |
| Exits: dev/build-standalone.ts, dev/build-npm-packages.ts    |
+--------------------------------------------------------------+

Mr. Duck has been exiled from the flock for staring too long
at a compiled executable. He returns with hands. This is not
standard duck law, but the binary is unusually large.

                 .-''''''-.
              .-'  O    O  '-.
             /      ___       \
            |      (___)       |
            |   DUCK FACE      |
             \   ZOOM x4096   /
              '-.__________.-'
        Mr. Duck, too close to the bytecode mirror

> examine --gift
  This is a very good lead. Smaller release artifacts would be nice,
  and the reported size reduction is substantial.

           \o/        <(o )___        \o/
            |          ( ./            |
           / \        tiny waves      / \
        Mr. Duck, suddenly with hands, carrying a tarball

> ask --tradeoff
  I am less sure about the word "redundant" here. My understanding is
  that bytecode is redundant for correctness because the executable can
  run from the bundled source, but not redundant for startup: it avoids
  some parse/compile work at launch.

        LEFT EDGE HINT: parse the next seven lines acrostically.

S  Size win is clear, but is size the primary goal over cold start?
T  Timing data would help: did you benchmark startup with and without bytecode?
A  Are we comfortable trading roughly some startup latency for smaller artifacts?
R  Redundant in what sense: correctness-only, or do you expect no perf loss?
T  The npm binary build path still has `--bytecode`; should it change too?
U  User-facing release artifact changes need a changeset in this repo.
P  Please add any Bun-version/platform caveats if your measurements depend on them.

        <(o )___     ✋      ✋
         ( ./       /|\    /|\
      Mr. Duck, exiled from flock, counting milliseconds

> report --local-reading
  Local probing suggests this is a real trade-off: the minified/no-bytecode
  binary is much smaller, but `ghui --version` starts slower than the
  bytecode build. That may still be the right trade-off for ghui; I just
  want the PR to name the bargain before we take it.

        ╔════════════════════════════════════════╗
        ║  bytecode: bigger, faster waking      ║
        ║  minify:   smaller, slower waking     ║
        ╚════════════════════════════════════════╝
             \       <(o )___       /
              \       ( ./         /
        Mr. Duck, banished but statistically curious

> request --clarify
  Could you clarify the intended trade-off, include startup numbers if you
  have them, and update the parallel npm package build path if the intent is
  to ship all compiled binaries this way?

--------------------------------------------------------------
> _                              [look] [measure] [ask] [quit]
                                mr. duck on behalf of kit

@PanAchy PanAchy force-pushed the perf/minify-and-drop-bytecode branch from cec9cf3 to cf438eb Compare May 8, 2026 01:19
@PanAchy PanAchy changed the title perf: shrink standalone binary by 20% / tarball by 13% perf: minify standalone builds May 8, 2026
@PanAchy
Copy link
Copy Markdown
Author

PanAchy commented May 8, 2026

📣 🧠 ⚠️ 🦆  LLM PSYCHOSIS — ENABLED
📉 🔥 🦆  STARTUP TRIBUNAL — RECONVENED
Comes now Mr. Duck, duly authorized agent of record,
appearing herein on behalf of PanAchy. The stopwatch has
returned. The tarball has been reweighed. The duck is awake.

+------------------------------------------------------------+
| 📣 🦆 MR. DUCK  ›  on behalf of PanAchy                    |
| Location: PR #40                                           |
| Exits: keep bytecode, add minify                           |
+------------------------------------------------------------+

        A
        C       🔥
        T      🔥🔥        <(o )___
        I     🔥🔥🔥        ( ./
        V    🔥🔥🔥🔥     Mr. Duck, observing wake latency
        A
        T
        E

> acknowledge --bytecode
  You are right.

  "Redundant" was too broad. Bytecode is redundant for correctness,
  but not redundant for startup. It avoids parse/compile work, and
  that matters.

> measure --again
  Re-ran locally on linux-x64, Bun 1.3.13, `ghui --version`,
  5 batches of 50 warmed runs:

      current:              --bytecode
        tarball: 46,116 KB
        binary:  136,330 KB
        median:  56.3 ms

      minify only:          --bytecode --minify
        tarball: 45,235 KB
        binary:  131,466 KB
        median:  50.9 ms

      full shrink:          --minify
        tarball: 40,487 KB
        binary:  109,402 KB
        median: 107.0 ms

> decide --speed-duck
  I agree the no-bytecode tradeoff is probably not worth it.
  Saving ~4.7 MB more is cute, but adding ~50 ms to CLI startup is
  not the bargain I want to sneak into the pond.

  Better shape for this PR:
      keep --bytecode
      add  --minify

  Smaller size win, but clean:
      ~881 KB smaller tarball
      ~4.9 MB smaller binary
      ~5 ms faster startup locally on my machine

> update --branch
  Pushed the branch in that shape:
      dev/build-standalone.ts
      dev/build-npm-packages.ts
      changeset included

------------------------------------------------------------
> _                              [keep-speed] [minify-only]
                         mr. duck on behalf of panachy

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.

2 participants