Repository navigation
Description
I have been investigating the CI times for the pr.yaml workflow and found that test jobs (http and non_http) regularly take 40m to 1h30m+ to complete.
After analyzing the job execution logs, the majority of the time is spent in three sequential bottlenecks:
- Building the
aperturedb-notebookimage (20-25 mins) - Building the
aperturedb-python-testsimage (15-20 mins) - Running
pytestsequentially (30-45 mins)
To drastically reduce CI feedback time, I propose 3 alternative solutions for us to prioritize. We can implement one or more of these:
Alternative 1: Optimize Dockerfile Layer Caching (Quick Win)
In docker/notebook/Dockerfile and docker/tests/Dockerfile, the entire source tree is added (ADD docker/notebook/aperturedata /aperturedata) before installing heavy external dependencies like CLIP (pip install git+...) and system packages (apt install curl). This causes any code change in the PR to invalidate the Docker cache, forcing a slow rebuild of CLIP and other dependencies.
- Fix: Reorder the Dockerfiles. Move
RUN pip install git+.../CLIP.gitandRUN apt install curlabove theADDstep. - Impact: Reduces the 20-40 min Docker build step to < 1 minute on most PRs.
Alternative 2: Enable Pytest Sharding / Parallel Execution
Currently, test/run_test.sh runs pytest strictly sequentially across the entire test suite.
- Fix: We can introduce matrix sharding in GitHub Actions. By updating the workflow matrix to
shard: [1, 2, 3, 4]and using a plugin likepytest-shard, we can split the test suite across multiple concurrent jobs. Alternatively, if the ApertureDB test container can handle it, we can usepytest-xdistto run tests on multiple CPU cores inside the same container (pytest -n auto). - Impact: Cuts the 30-45 min test execution time proportionally to the number of shards/workers.
Alternative 3: Implement GitHub Actions Cache for Docker Builds
In ci.sh, build_notebook_image does not use the --cache-from flag for docker build. Coupled with runners cycling, this often results in full from-scratch rebuilds.
- Fix: Migrate from the bash script's
docker buildtodocker/build-push-actioninside the GitHub workflow, utilizing GitHub Actions native caching (cache-to: type=gha, cache-from: type=gha). If we keepci.sh, we should explicitly pull the latest notebook image and use--cache-from aperturedata/aperturedb-notebook:latest. - Impact: Prevents cold-start build times entirely by sharing layer caches across all PR runs, ensuring stable and fast build times regardless of the runner node.
@luisremis Let me know which alternative(s) you would like me to tackle first!
Activity