-
Notifications
You must be signed in to change notification settings - Fork 239
Benchmarks: default to local swift-foundation branch #1981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
itingliu
wants to merge
2
commits into
swiftlang:release/6.4.x
Choose a base branch
from
itingliu:benchmark-local-benchmark
base: release/6.4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # swift-foundation Benchmarks | ||
|
|
||
| Benchmarks for `swift-foundation` live in this directory as a separate Swift Package. They use the [`package-benchmark`](https://github.com/ordo-one/package-benchmark) plugin. | ||
|
|
||
| All commands below must be run from this `Benchmarks/` subdirectory. | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| `package-benchmark` uses [`jemalloc`](https://jemalloc.net) for memory allocation statistics. You can either install it or skip it. | ||
|
|
||
| `Benchmarks/Package.swift` declares `package-benchmark` with `traits: []`, which disables the `Jemalloc` trait. Benchmarks build and run without jemalloc installed by default. | ||
|
|
||
| To opt in to jemalloc and capture malloc metrics, install it first and then pass `--traits Jemalloc`: | ||
|
|
||
| - **macOS:** `brew install jemalloc` | ||
| - **Linux:** `apt-get install libjemalloc-dev` (Ubuntu/Debian) or equivalent | ||
|
|
||
| See the official [Getting Started](https://swiftpackageindex.com/ordo-one/package-benchmark/1.31.0/documentation/benchmark/gettingstarted#Disabling-jemalloc-Swift-61+) article for details. | ||
|
|
||
| --- | ||
|
|
||
| ## Running Benchmarks | ||
|
|
||
| **Run all benchmarks:** | ||
|
|
||
| ``` | ||
| swift package benchmark | ||
| ``` | ||
|
|
||
| **Run a specific target:** | ||
|
|
||
| ``` | ||
| swift package benchmark --target JSONBenchmarks | ||
| swift package benchmark --filter "URL" | ||
| ``` | ||
|
|
||
| **List all available benchmarks:** | ||
|
|
||
| ``` | ||
| swift package benchmark list | ||
| ``` | ||
|
|
||
| **Full help:** | ||
|
|
||
| ``` | ||
| swift package benchmark help | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Choosing Which Foundation to Benchmark Against | ||
|
|
||
| The benchmark package supports four configurations, controlled by environment variables. The active configuration is printed at build time. | ||
|
|
||
| ### Local changes — benchmark your own swift-foundation checkout (default) | ||
|
|
||
| By default, with no environment variable set, benchmarks build against the local `swift-foundation` checkout (the parent of this `Benchmarks/` directory). Other package dependencies (e.g. `swift-foundation-icu`) are fetched from their remote URLs. This is the recommended mode for contributors iterating on a performance improvement. | ||
|
|
||
| ``` | ||
| swift package benchmark | ||
| ``` | ||
|
|
||
| To point at a different local checkout, set `SWIFTCI_USE_LOCAL_DEPS` to the directory *containing* the `swift-foundation` checkout: | ||
|
|
||
| ``` | ||
| SWIFTCI_USE_LOCAL_DEPS=/path/to/parent swift package benchmark | ||
| ``` | ||
|
|
||
| On Linux, `SWIFTCI_USE_LOCAL_DEPS` resolves to `swift-corelibs-foundation` instead. | ||
|
|
||
| > **Note:** `SWIFTCI_USE_LOCAL_DEPS` is also set by the Swift repo CI when running full toolchain unit tests, so that *all* dependencies (including transitive ones like `swift-foundation-icu`) resolve to locally checked-out copies rather than fetching from git. | ||
|
|
||
| ### GitHub main branch — compare against the latest published commit | ||
|
|
||
| ``` | ||
| USE_PACKAGE=1 swift package benchmark | ||
| ``` | ||
|
|
||
| Fetches and benchmarks against the `main` branch of `swift-foundation` (or `swift-corelibs-foundation` on Linux) from GitHub. Useful for comparing a local build against a known top-of-tree commit. | ||
|
|
||
| ### System Foundation / toolchain | ||
|
|
||
| ``` | ||
| USE_TOOLCHAIN=1 swift package benchmark | ||
| ``` | ||
|
|
||
| On macOS this uses `Foundation.framework`. On Linux it uses the Foundation from the installed Swift toolchain. Use this only if you specifically want to measure the system-installed version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
foundation-localis set at the main Package.swift. Its value depends on whetherSWIFTCI_USE_LOCAL_DEPSis set. When it is set it's using local check, and remote one if unset.