Skip to content

Commit

Permalink
docs: add a section for the -compress flag (vlang#22169)
Browse files Browse the repository at this point in the history
  • Loading branch information
esquerbatua authored Sep 6, 2024
1 parent 023fd92 commit 6160945
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions doc/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6725,15 +6725,16 @@ performance, memory usage, or size.
| Tuning Operation | Benefits | Drawbacks |
|--------------------------|---------------------------------|---------------------------------------------------|
| `@[inline]` | Performance | Increased executable size |
| `@[direct_array_access]` | Performance | Safety risks |
| `@[packed]` | Memory usage | Potential performance loss |
| `@[minify]` | Performance, Memory usage | May break binary serialization/reflection |
| `@[inline]` | Performance | Increased executable size |
| `@[direct_array_access]` | Performance | Safety risks |
| `@[packed]` | Memory usage | Potential performance loss |
| `@[minify]` | Performance, Memory usage | May break binary serialization/reflection |
| `_likely_/_unlikely_` | Performance | Risk of negative performance impact |
| `-skip-unused` | Performance, Compile time, Size | Potential instability |
| `-fast-math` | Performance | Risk of incorrect mathematical operations results |
| `-d no_segfault_handler` | Compile time, Size | Loss of segfault trace |
| `-cflags -march=native` | Performance | Risk of reduced CPU compatibility |
| `-compress` | Size | Harder to debug, extra dependency `upx` |
| `PGO` | Performance, Size | Usage complexity |
### Tuning operations details
Expand Down Expand Up @@ -6920,6 +6921,22 @@ with identical hardware.
- When distributing the software to users with potentially older CPUs.
#### `-compress`
This flag executes `upx` to compress the resultant executable,
reducing its size by around 50%-70%.
**When to Use**
- For really tiny environments, where the size of the executable on the file system,
or when deploying is important. The executable will be uncompressed at runtime,
so it will take a bit more time to start.
**When to Avoid**
- When you need to debug the application, or when your app's startup time
is extremely important (where 1-2ms can be meaningful for you).
#### PGO (Profile-Guided Optimization)
PGO allows the compiler to optimize code based on its behavior during sample runs. This can improve
Expand Down

0 comments on commit 6160945

Please sign in to comment.