A smart file prefetching system for deep learning workloads that predicts and pre-loads data files into memory before they're needed, reducing I/O bottlenecks during model training.
GoFetch is an intelligent prefetching daemon designed to accelerate deep learning training pipelines. It learns file access patterns during training and proactively loads files into the kernel page cache, minimizing disk I/O wait times.
With our latest updates, GoFetch now features a fully integrated GRU neural network predictor, automated dataset benchmarking, and a zero-code Docker deployment that intercepts DataLoader calls transparently!
- Access Pattern Learning — Uses Markov chains and a PyTorch-based GRU neural network to predict which files will be accessed next
- Kernel-Level Prefetching — Leverages Linux
posix_fadvise()to hint the OS kernel about upcoming file reads - Zero-Code Docker Deployment — Automatically instruments PyTorch DataLoaders using
sitecustomize.pywith no code changes needed - Real-Time Metrics & Hit Rates — Tracks windowed cache hits, prediction accuracy, and prefetch latency
- Configurable Policies — Choose between strict FIFO or Confidence-driven Heap prefetch scheduling
- Automated Benchmarks — Built-in test suites for real-world datasets like FashionMNIST and Flowers-102
GoFetch is Docker-only. It relies on Linux kernel prefetching, so host installs are not supported.
GoFetch is published on Docker Hub at parthhan/gofetch. No build step needed — just pull and run.
| Image Tag | Description |
|---|---|
parthhan/gofetch:pytorch-latest |
Recommended — Full PyTorch + CUDA + GoFetch daemon (all-in-one) |
parthhan/gofetch:daemon-latest |
Lightweight daemon-only image for multi-container setups |
# Pull the images
docker pull parthhan/gofetch:pytorch-latest
docker pull parthhan/gofetch:daemon-latestFor a full walkthrough, see docker/README.md.
Because posix_fadvise relies on the Linux kernel, we highly recommend running GoFetch via Docker. Our pre-built images on Docker Hub auto-instrument your code — no code changes required in your training scripts!
-
Pull the image directly from Docker Hub (no clone needed)
docker pull parthhan/gofetch:pytorch-latest
-
Run your own training script (zero-code instrumentation)
docker run --privileged \ -v $(pwd)/data:/app/data \ -v $(pwd)/models:/app/models \ parthhan/gofetch:pytorch-latest \ python your_train_script.py
(The
--privilegedflag gives the container optimal access to the Linux kernel page cache.) -
Or use it as a base image in your own Dockerfile
FROM parthhan/gofetch:pytorch-latest COPY . /my_project WORKDIR /my_project RUN pip install -r requirements.txt CMD ["python", "train.py"]
GoFetch includes a built-in suite to download datasets and test performance. Pull the image and run the benchmark directly — no build step needed:
# Run the full benchmark (FashionMNIST + Flowers-102, all modes)
docker run --privileged \
-v $(pwd)/data:/app/data \
-v $(pwd)/models:/app/models \
parthhan/gofetch:pytorch-latest \
python -m benchmarks.run_allThis downloads FashionMNIST and Flowers-102, runs Standard PyTorch, GoFetch (Markov), and GoFetch (GRU), then prints comparative speedups. Results are archived under benchmarks/results/ including runs.csv, summary.json, per-run metrics/*.csv, and predictor_accuracy.json.
For more reliable numbers across multiple iterations with cache drops:
docker run --privileged \
-v $(pwd)/data:/app/data \
-v $(pwd)/models:/app/models \
parthhan/gofetch:pytorch-latest \
python -m benchmarks.run_all --runs 3 --warmup-epochs 1 --drop-cachesTo benchmark only the GRU predictor on FashionMNIST:
docker run --privileged \
-v $(pwd)/data:/app/data \
-v $(pwd)/models:/app/models \
parthhan/gofetch:pytorch-latest \
python -m benchmarks.run_all --dataset fashion --predictor gru --trace-epochs 2 --gru-epochs 5 --runs 1 --no-shuffleFor a more aggressive GRU prefetch configuration:
docker run --privileged \
-v $(pwd)/data:/app/data \
-v $(pwd)/models:/app/models \
parthhan/gofetch:pytorch-latest \
python -m benchmarks.run_all --dataset fashion --predictor gru --trace-epochs 2 --gru-epochs 5 --runs 1 --no-shuffle \
--prefetch-confidence 0.9 --prefetch-top-k 8 --prefetch-batch-size 8 --prefetch-size-mb 0.25 --prefetch-rate-limit 30Note: The dataset benchmarks run synthetic training loops with pseudo-labels to measure pipeline throughput. They are not intended to train a useful model or report accuracy.
Edit config.yaml to customize behavior:
storage:
db_path: "traces.db"
prefetcher:
policy_type: "heap" # Options: "heap" or "fifo"
confidence_threshold: 0.6 # Minimum confidence to prefetch
rate_limit_per_sec: 20 # Max prefetch operations per second
top_k_predictions: 5 # Number of files to predict
max_prefetch_size_mb: 16 # Maximum file size to prefetch
predictor:
baseline:
enabled: true # Markov chain predictor
ml:
enabled: true # GRU neural network predictor
model_path: "models/prefetch_gru.pt"- Trace Collection — Captures file access events (path, offset, timestamp, worker_id) natively or via Docker auto-instrumentation.
- Pattern Learning — Our GRU model encodes temporal features to predict complex data loading behaviors.
- Prediction — Uses learned patterns to predict upcoming file accesses up to
top_ksteps ahead. - Prefetching — Calls
posix_fadvise()to hint the kernel to load predicted files into cache before PyTorch asks for them. - Cache Hit — When training reads the file, it's already in memory!
Contributions are welcome! Please feel free to submit a Pull Request.
- See ARCHITECTURE.md for detailed system design.
- Check the
examples/directory for sample usage.