mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
perf(native): build smaller binaries with -Os and enforce a size budget (#28)
This commit is contained in:
1 parent
ac57626481
commit
3c4118ff1a
4 files changed
+28
No files matched your search
@@ -54,6 +54,19 @@ jobs:
|
||||
- name: Build native binary
|
||||
run: mvn clean package -Pnative -DskipTests -B
|
||||
|
||||
# Fails when the binary outgrows the budget, so size regressions show up in review instead
|
||||
# of in a release. Set about 5% over the 40.8 MB this job built when the budget was
|
||||
# introduced (GraalVM Community, -Os); raise it deliberately in the PR that needs the room.
|
||||
- name: Binary size budget
|
||||
env:
|
||||
NATIVE_SIZE_BUDGET_MB: 43
|
||||
run: |
|
||||
bytes=$(stat -c %s target/floci)
|
||||
mb=$(awk -v b="$bytes" 'BEGIN { printf "%.1f", b / 1048576 }')
|
||||
echo "Native binary (linux/arm64): ${mb} MB, budget ${NATIVE_SIZE_BUDGET_MB} MB" | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
awk -v b="$bytes" -v max="$NATIVE_SIZE_BUDGET_MB" 'BEGIN { exit (b / 1048576 > max) }' \
|
||||
|| { echo "::error::Native binary is ${mb} MB, over the ${NATIVE_SIZE_BUDGET_MB} MB budget."; exit 1; }
|
||||
|
||||
- name: Smoke test — version
|
||||
run: ./target/floci version
|
||||
|
||||
|
||||
@@ -170,6 +170,16 @@ jobs:
|
||||
find . -type f \( -name "floci-*" \) | sort | xargs sha256sum > sha256sums.txt
|
||||
cat sha256sums.txt
|
||||
|
||||
- name: Report binary sizes
|
||||
run: |
|
||||
{
|
||||
echo "| Asset | Size (MB) |"
|
||||
echo "|---|---|"
|
||||
find dist -type f -name "floci*" ! -name "*.txt" | sort | while read -r f; do
|
||||
echo "| $(basename "$f") | $(awk -v b="$(stat -c %s "$f")" 'BEGIN { printf "%.1f", b / 1048576 }') |"
|
||||
done
|
||||
} | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
|
||||
@@ -137,6 +137,7 @@ Rules when touching this:
|
||||
- **New Jackson DTOs** (anything `ObjectMapper` serializes/deserializes by field name) must be added to `src/main/resources/META-INF/native-image/io.floci/floci-cli/reflect-config.json`. Prefer passing `Map`/`JsonNode` to `printer.structured(...)` — those need no registration.
|
||||
- **`@Command` classes** do not need manual reflect-config entries — `picocli-codegen` (the annotation processor in `pom.xml`) generates them automatically at compile time.
|
||||
- **Do not remove** `--enable-url-protocols=http,https` from `native-image.properties`; `java.net.http.HttpClient` requires it.
|
||||
- The native profile builds with `-Os` (about 17% smaller with GraalVM Community, about 35% with Oracle GraalVM, for about 10 ms more startup). `ci.yml` fails the native job when the linux/arm64 binary exceeds `NATIVE_SIZE_BUDGET_MB`; raise the budget deliberately in the PR that needs the room, and say why.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -157,6 +157,10 @@
|
||||
<buildArg>--no-fallback</buildArg>
|
||||
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
|
||||
<buildArg>-H:IncludeResources=.*\.properties</buildArg>
|
||||
<!-- Optimize for size, measured 2026-10-08: GraalVM Community linux/arm64 49.2 to 40.8 MB
|
||||
(about 17%); Oracle GraalVM about 35% (darwin-arm64 51.8 to 33.6 MB) for
|
||||
~10 ms more startup (~33 to ~43 ms). -->
|
||||
<buildArg>-Os</buildArg>
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
Reference in new issue
Block a user