Skip to content
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

Early check that a cached artifact is compatible with current CPU Features #4190

Merged
merged 3 commits into from
Aug 30, 2023

Conversation

ptitSeb
Copy link
Contributor

@ptitSeb ptitSeb commented Aug 30, 2023

Early check that a cached artifact is compatible with current CPU Features

This will fix #4188

This has been tested localy by:

  1. clearing cache
  2. Forcing an CPUFeatures with more feature than the CPU currently support with
  3. Generatic a cache (running will fail because of the super set of feature with this PR)
  4. Relaunching the wasm program with the PR, it will silently discard the cache and re-create it

Code to force more Feature than the cpu have (in my case at least, as my CPU is pretty old and only have EnumSet(SSE2 | SSE3 | SSSE3 | SSE41 | SSE42 | POPCNT | AVX)):

impl StoreOptions {
    /// Gets the store for the host target, with the compiler name selected
    pub fn get_store(&self) -> Result<(Store, CompilerType)> {
        let target = Target::default();
        let cpu_features = target.cpu_features().clone();
        cpu_features.insert(CpuFeature::AVX2);
        cpu_features.insert(CpuFeature::AVX512DQ);
        cpu_features.insert(CpuFeature::AVX512VL);
        cpu_features.insert(CpuFeature::AVX512F);
        let target = Target::new(target.triple().clone(), cpu_features);
        self.get_store_for_target(target)
    }

in lib/cli/src/store.rs

@ptitSeb ptitSeb requested a review from syrusakbary as a code owner August 30, 2023 09:45
@ptitSeb ptitSeb requested a review from theduke August 30, 2023 09:46
lib/compiler/src/engine/artifact.rs Outdated Show resolved Hide resolved
@ptitSeb ptitSeb enabled auto-merge (squash) August 30, 2023 11:20
@ptitSeb ptitSeb merged commit c123a5a into master Aug 30, 2023
@ptitSeb ptitSeb deleted the cache_discard_incomptible_cpu_artifact branch August 30, 2023 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Artifact Cache: Consider CPU Feature Flags When Loading Artifacts
2 participants