-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[ci] Optimizations to reduce critical-path length #13340
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 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
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,17 @@ | ||
| //! Exit 0 if Wasmtime's MPK runtime support is available on this host, | ||
| //! 1 otherwise. This shares the detection logic with `wasmtime`'s runtime | ||
| //! `is_supported()` check via [`wasmtime_internal_core::mpk::is_supported`], | ||
| //! so CI's "should we set `WASMTIME_TEST_FORCE_MPK=1`?" decision can never | ||
| //! drift from what the runtime itself reports. | ||
|
|
||
| use std::process::exit; | ||
|
|
||
| fn main() { | ||
| if wasmtime_internal_core::mpk::is_supported() { | ||
| eprintln!("MPK is available"); | ||
| exit(0); | ||
| } else { | ||
| eprintln!("MPK is not available"); | ||
| exit(1); | ||
| } | ||
| } |
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,44 @@ | ||
| //! Detection of Memory Protection Keys (MPK) support on the host system. | ||
| //! | ||
| //! This is the single source of truth for whether Wasmtime's MPK | ||
| //! implementation can be used on the current target. The runtime in the | ||
| //! `wasmtime` crate consults [`is_supported`], and `examples/mpk-available.rs` | ||
| //! exposes it as a CLI exit code so CI can decide whether to set | ||
| //! `WASMTIME_TEST_FORCE_MPK=1`. | ||
|
|
||
| /// Returns `true` if Wasmtime's MPK support can be used on this host. | ||
| pub fn is_supported() -> bool { | ||
| cfg!(target_os = "linux") && cpuid_pku_bit_set() | ||
| } | ||
|
|
||
| /// Check the `ECX.PKU` flag (bit 3, zero-based) of the `07h` `CPUID` leaf; see | ||
| /// the Intel Software Development Manual, vol 3a, section 2.7. This flag is | ||
| /// only set on Intel CPUs, so this function also checks the `CPUID` vendor | ||
| /// string. | ||
| #[cfg(target_arch = "x86_64")] | ||
| fn cpuid_pku_bit_set() -> bool { | ||
| is_intel_cpu() && { | ||
| #[allow( | ||
| unused_unsafe, | ||
| reason = "rust is transitioning to `__cpuid` being a safe function" | ||
| )] | ||
| let result = unsafe { core::arch::x86_64::__cpuid(0x07) }; | ||
| (result.ecx & 0b1000) != 0 | ||
| } | ||
| } | ||
|
|
||
| #[cfg(not(target_arch = "x86_64"))] | ||
| fn cpuid_pku_bit_set() -> bool { | ||
| false | ||
| } | ||
|
|
||
| /// Check the `CPUID` vendor string for `GenuineIntel`; see the Intel Software | ||
| /// Development Manual, vol 2a, `CPUID` description. | ||
| #[cfg(target_arch = "x86_64")] | ||
| fn is_intel_cpu() -> bool { | ||
| #[allow(unused_unsafe, reason = "see above about __cpuid")] | ||
| let result = unsafe { core::arch::x86_64::__cpuid(0) }; | ||
| result.ebx == u32::from_le_bytes(*b"Genu") | ||
| && result.edx == u32::from_le_bytes(*b"ineI") | ||
| && result.ecx == u32::from_le_bytes(*b"ntel") | ||
| } |
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
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.
While I realize that Cargo has no way of splitting this up, personally I don't think this is viable to add to CI. If a new test is added to the
wasmtime-clicrate it'll never get run on CI because it's not mentioned here, and we basically have no way of knowing that (it's pretty unlikely someone checks CI logs to ensure the test is being run).I don't really know of a great answer for this otherwise. The only other thing I can think of is to move test suites around to keep the "single crate buckets" from before as still just crates. For example we could create a dedicated crate to just doing the
*.wasttests and leave thealltest where it is. Or... something like that.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.
We can use
cargo metadataand parse the JSON output to get alltesttargets for a crate.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.
That's a very good point, yes. I added a
cargo metadatabased attempt to address this over here.