Skip to content

Commit 9384250

Browse files
authored
ci: save/restore cargo registry for windows (#11133)
- Restore and save Cargo registry state for Windows CI run. - Make assemblers emit reproducible code (they've written timestamp to .obj files before). - Revert Windows linker from rust-lld with link.exe since rust-ldd generated significantly more cache misses. --------- Signed-off-by: Mikhail Kot <[email protected]>
1 parent b277e58 commit 9384250

3 files changed

Lines changed: 99 additions & 19 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,17 @@ jobs:
414414
${{ github.repository == 'vortex-data/vortex'
415415
&& format('runs-on={0}/region=us-east-1/pool=windows-x64-pre/extras=s3-cache', github.run_id)
416416
|| 'windows-latest' }}
417+
env:
418+
NEXTEST_WINDOWS_ARGS: >-
419+
--cargo-profile ci --locked --workspace --all-features
420+
--exclude vortex-bench
421+
--exclude vortex-python
422+
--exclude vortex-fuzz --exclude vortex-cuda --exclude vortex-cuda-ffi
423+
--exclude vortex-nvcomp --exclude vortex-cub --exclude vortex-test-e2e-cuda --exclude vortex-python-cuda
424+
--exclude duckdb-bench
425+
--exclude lance-bench --exclude datafusion-bench --exclude random-access-bench
426+
--exclude compress-bench --exclude xtask --exclude vortex-datafusion
427+
--exclude gpu-scan-cli
417428
steps:
418429
- parallel:
419430
- uses: runs-on/action@v2
@@ -424,37 +435,66 @@ jobs:
424435
- name: Setup (Windows)
425436
run: |
426437
echo "C:\rust\cargo\bin" >> $env:GITHUB_PATH
438+
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { Join-Path $env:USERPROFILE ".cargo" }
439+
echo "CARGO_HOME=$cargoHome" >> $env:GITHUB_ENV
427440
- parallel:
428441
- uses: ./.github/actions/setup-prebuild
429442
with:
430443
enable-sccache: "true"
431444
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
432445
with:
433446
python-version: "3.11"
434-
435-
- name: Rust Tests (Windows)
436-
id: tests
437-
env:
447+
- name: Restore Cargo registry
448+
id: cargo-registry
449+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
450+
with:
451+
path: |
452+
${{ env.CARGO_HOME }}/registry/index
453+
${{ env.CARGO_HOME }}/registry/cache
454+
${{ env.CARGO_HOME }}/git/db
455+
${{ env.CARGO_HOME }}/git/checkouts
456+
key: cargo-registry-v1-windows-x64-${{ hashFiles('Cargo.lock') }}
457+
restore-keys: cargo-registry-v1-windows-x64-
458+
459+
- name: Assemblers emit reproducible code
460+
run: |
461+
$vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
462+
$ml64 = & $vswhere -latest -products * -find "VC\Tools\MSVC\**\bin\Hostx64\x64\ml64.exe" |
463+
Sort-Object -Descending | Select-Object -First 1
464+
if (-not $ml64) { throw "ml64.exe not found" }
465+
echo "VORTEX_ML64=$ml64" >> $env:GITHUB_ENV
466+
echo "CC_MASM_ASM_x86_64_pc_windows_msvc=$env:pythonLocation\python.exe $env:GITHUB_WORKSPACE\scripts\ml64_reproducible.py" >> $env:GITHUB_ENV
467+
echo "NASMENV=--reproducible" >> $env:GITHUB_ENV
468+
469+
- name: Build Rust Tests (Windows)
470+
id: build-tests
471+
env: &windows-test-env
438472
# Stable proc-macro DLL contents let dependent crates reuse sccache entries.
439473
# duckdb_static.lib is built with /MT and thus requires crt-static
440474
RUSTFLAGS: "-C link-arg=/Brepro -C target-feature=+crt-static"
441-
# link.exe spends ~1.5 min on the test binaries after compilation finishes.
442-
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: rust-lld
443-
run: |
444-
cargo nextest run --cargo-profile ci --locked --workspace --all-features --no-fail-fast `
445-
--exclude vortex-bench `
446-
--exclude vortex-python `
447-
--exclude vortex-fuzz --exclude vortex-cuda --exclude vortex-cuda-ffi `
448-
--exclude vortex-nvcomp --exclude vortex-cub --exclude vortex-test-e2e-cuda --exclude vortex-python-cuda `
449-
--exclude duckdb-bench `
450-
--exclude lance-bench --exclude datafusion-bench --exclude random-access-bench `
451-
--exclude compress-bench --exclude xtask --exclude vortex-datafusion `
452-
--exclude gpu-scan-cli
475+
run: cargo nextest run --no-run @($env:NEXTEST_WINDOWS_ARGS -split ' ')
476+
477+
- name: Run Rust Tests (Windows)
478+
id: tests
479+
if: ${{ !cancelled() && steps.build-tests.outcome == 'success' }}
480+
env: *windows-test-env
481+
run: cargo nextest run --no-fail-fast @($env:NEXTEST_WINDOWS_ARGS -split ' ')
482+
483+
- name: Save Cargo registry
484+
if: ${{ !cancelled() && steps.cargo-registry.outputs.cache-hit != 'true' && (steps.build-tests.outcome == 'success' || steps.build-tests.outcome == 'failure') }}
485+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
486+
with:
487+
path: |
488+
${{ env.CARGO_HOME }}/registry/index
489+
${{ env.CARGO_HOME }}/registry/cache
490+
${{ env.CARGO_HOME }}/git/db
491+
${{ env.CARGO_HOME }}/git/checkouts
492+
key: ${{ steps.cargo-registry.outputs.cache-primary-key }}
453493

454494
# The test outputs fill the default disk, and the wheel build cannot reuse
455495
# them: it uses other RUSTFLAGS and its own target directory.
456496
- name: Delete the Rust test outputs
457-
if: ${{ !cancelled() && (steps.tests.outcome == 'success' || steps.tests.outcome == 'failure') }}
497+
if: ${{ !cancelled() && (steps.build-tests.outcome == 'success' || steps.build-tests.outcome == 'failure') }}
458498
shell: cmd
459499
run: if exist target\ci rmdir /s /q target\ci
460500

@@ -463,7 +503,7 @@ jobs:
463503
- name: Build wheel
464504
id: wheel
465505
# Build the wheel also when a Rust test fails, but not when the setup failed.
466-
if: ${{ !cancelled() && (steps.tests.outcome == 'success' || steps.tests.outcome == 'failure') }}
506+
if: ${{ !cancelled() && (steps.build-tests.outcome == 'success' || steps.build-tests.outcome == 'failure') }}
467507
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
468508
with:
469509
command: build

‎_typos.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ extend-ignore-re = [
1111
# scripts/measurement_id_golden.json is a frozen hash-pin artifact whose vectors include
1212
# deliberate Unicode edge cases (JSON-escaped, so "café" reads as the token "caf"); its bytes
1313
# must never change, so it is excluded rather than "fixed".
14-
extend-exclude = ["/vortex-bench/**", "/docs/references.bib", "benchmarks/**", "vortex-sqllogictest/slt/**", "encodings/fsst/src/dfa/tests.rs", "encodings/fsst/src/dfa/flat_contains.rs", "scripts/measurement_id_golden.json"]
14+
extend-exclude = ["/vortex-bench/**", "/docs/references.bib", "benchmarks/**",
15+
"vortex-sqllogictest/slt/**", "encodings/fsst/src/dfa/tests.rs",
16+
"encodings/fsst/src/dfa/flat_contains.rs",
17+
"scripts/measurement_id_golden.json", "scripts/ml64_reproducible.py"]
1518

1619
[type.py]
1720
extend-ignore-identifiers-re = [

‎scripts/ml64_reproducible.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python3
2+
# SPDX-License-Identifier: Apache-2.0
3+
# SPDX-FileCopyrightText: Copyright the Vortex contributors
4+
5+
import os
6+
import subprocess
7+
import sys
8+
9+
COFF_MACHINES = {b"\x64\x86", b"\x4c\x01"}
10+
11+
12+
def output_path(args: list[str]) -> str | None:
13+
for arg in args:
14+
if arg[:3].lower() in ("-fo", "/fo") and len(arg) > 3:
15+
return arg[3:]
16+
return None
17+
18+
19+
def zero_timestamp(path: str):
20+
with open(path, "r+b") as obj:
21+
if obj.read(2) not in COFF_MACHINES:
22+
return
23+
obj.seek(4)
24+
obj.write(b"\x00\x00\x00\x00")
25+
26+
27+
def main() -> int:
28+
args = sys.argv[1:]
29+
status = subprocess.run([os.environ["VORTEX_ML64"], *args]).returncode
30+
path = output_path(args)
31+
if status == 0 and path is not None:
32+
zero_timestamp(path)
33+
return status
34+
35+
36+
if __name__ == "__main__":
37+
sys.exit(main())

0 commit comments

Comments
 (0)