You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b7948ab
Browse filesBrowse the repository at this point in the historyBrowse files
perf(pricing): shrink embedded snapshots 58% and binary 2.9% (#1244)
* docs(skills): add Rust binary size guidance
Add a repo-local rust-binary-size skill for release-profile, dependency feature, native package size, and executable bloat work.
The skill captures stable min-sized-rust guidance, keeps aggressive nightly and packer techniques opt-in, and links back to the upstream reference so future agents can inspect the source material when size work recurs.
Register the skill in AGENTS.md so agents discover it before changing Rust size-sensitive code or packaging.
* perf(pricing): flatten embedded models.dev snapshot
Regenerate the committed models.dev pricing snapshot as a flat map keyed by runtime model id instead of preserving upstream provider nesting.
The runtime loader now accepts both the live provider-tree shape from models.dev and the flat embedded shape, so network fallback compatibility is unchanged while the checked-in snapshot shrinks from 97,159 bytes to 36,871 bytes.
The release binary rebuilt successfully after the change at 2,845,920 bytes. Pricing tests cover the flat embedded shape and the existing offline fallback behaviour.
* fix(pricing): validate models.dev snapshot shape
Replace the untagged models.dev snapshot parser with explicit top-level shape validation so malformed provider payloads cannot be accepted as an empty flat model map.
The regression test uses a fixture-backed malformed provider payload and confirms parsing fails without loading entries. This addresses CodeRabbit feedback on PR #1244.
Validation: direnv exec . cargo test --manifest-path rust/Cargo.toml -p ccusage pricing::tests:: -- --nocapture; direnv exec . just fmt
* perf(pricing): compact embedded LiteLLM snapshot
Emit the build-time LiteLLM snapshot with short field keys and teach the runtime loader to read both the compact embedded shape and the normal LiteLLM response shape.
The generated LiteLLM snapshot shrinks from 66,046 bytes to 31,949 bytes while keeping 401 model keys. Runtime-relevant fields compared equal after expanding the compact keys.
Together with the models.dev flattening, the local release binary is now 2,812,864 bytes versus 2,895,424 bytes on the base commit.
Validation: direnv exec . cargo test --manifest-path rust/Cargo.toml -p ccusage pricing::tests:: -- --nocapture; direnv exec . cargo build --manifest-path rust/Cargo.toml --release --bin ccusage; direnv exec . just fmt
* fix(pricing): harden compact snapshot parsing
Align the LiteLLM compact-shape detector with the build-time emitter by requiring both short price keys before compact decoding. If compact decoding fails, the parser now falls back to the full LiteLLM shape so unrelated metadata keys do not drop otherwise valid pricing rows.
Also make the models.dev snapshot generator ignore empty catalog ids and fall back to the source model key. This prevents a malformed empty id from becoming the embedded pricing key while keeping the committed snapshot format unchanged.
* fix(package): rewrite Darwin libiconv install name
The macOS native package was copying a Nix-built binary that still referenced libiconv inside /nix/store. That works inside a Nix closure but fails when the binary is installed from the npm preview package on a clean GitHub macOS runner.
Patch the staged Darwin binary with install_name_tool so the package uses /usr/lib/libiconv.2.dylib at runtime. This keeps the Nix build unchanged while making the published native package runnable outside Nix.
* test(pricing): cover compact fallback branches
Extend the LiteLLM fallback regression so it enters the compact-shape branch and then falls through to full-shape parsing when compact decoding fails.
Also cover the undefined and non-empty catalog id branches for the models.dev compact key helper, matching the generator inputs called out during review.
* ci(perf): skip unavailable base package benchmarks
Perf comment jobs use pkg.pr.new URLs for both the base and PR package. The base URL can be unavailable for a commit that was never published by the preview package workflow, which previously made the script wait for the full job timeout and fail before writing a comment.
Make package installation return undefined when the URL is not ready, emit a commit-specific skipped performance comment when no base-dir fallback exists, and lower the workflow wait to five minutes so the job has time to finish cleanly.
* fix(pricing): warn on duplicate models.dev keys
The compact models.dev generator keeps the first entry for a pricing key, but duplicate provider aliases were previously skipped without any signal. Cubic identified that this could hide future pricing drift when regenerating the snapshot.
Emit a warning before skipping a duplicate pricing key and cover the warning text with a focused Vitest case so future duplicate handling remains visible.
* ci(github): tolerate unauthenticated comment writes
The rust perf comment job can produce a skipped benchmark summary when the base pkg.pr.new package is unavailable, but creating the new PR comment failed with a 401 from the workflow token. That made the job fail even though the benchmark script completed and wrote the job summary.
Treat 401 the same as the existing 403 no-comment-permission path, keep other GitHub failures fatal, and add a small in-source Vitest project for this script so the auth classification is covered.
reason: `Base package URL was not ready before ${formatDuration(ctx.values.packageRunnerTimeoutMs)}. Fixture performance comparison requires a base package when --base-dir is not provided.`,
0 commit comments