High-performance parallel filesystem walker
Project description
python-pwalk
A high-performance toolkit for filesystem analysis and reporting — optimized for petabyte-scale filesystems and HPC environments.
Generate comprehensive filesystem metadata reports 5-10x faster than traditional tools, with true multi-threading, intelligent buffering, and automatic zstd compression achieving 23x size reduction. Perfect for system administrators, data scientists, and HPC users working with millions or billions of files.
Why python-pwalk?
Traditional filesystem traversal tools struggle with modern storage systems containing billions of files. python-pwalk solves this with a battle-tested approach combining Python's ease of use with C's raw performance.
Key Features
- 🚀 Extreme Performance: 8,000-30,000 files/second — traverse 50 million files in ~41 minutes
- 🔄 True Parallelism: Multi-threaded C implementation using up to 32 threads
- 🗜️ 23x Compression: Automatic zstd compression reduces 100 GB CSV to 4 GB
- 📦 Zero Dependencies: No PyArrow, no numpy — just Python + C
- 🔌 Drop-in Replacement: 100% compatible with
os.walk()API - 💾 Memory Efficient: Thread-local buffers with automatic spillover for billions of files
- 🎯 HPC Ready: SLURM-aware,
.snapshotfiltering, cross-filesystem detection - 🦆 DuckDB Native: Output
.csv.zstfiles readable directly by DuckDB - 🛡️ Production Tested: Based on John Dey's pwalk used in HPC environments worldwide
Perfect For
- System Administrators: Audit multi-petabyte filesystems in minutes
- Data Scientists: Analyze file distributions across massive datasets
- HPC Users: Track storage usage in supercomputing environments
- Storage Teams: Generate reports for NetApp, Lustre, GPFS filesystems
- Compliance: Create auditable records of filesystem contents
Installation
pip install pwalk
That's it! Pre-compiled binary wheels with zstd compression are available for:
- Linux: x86_64 (manylinux2014)
- Python: 3.10, 3.11, 3.12, 3.13, 3.14
No system dependencies needed — wheels include everything pre-compiled!
Quick Start
30-Second Example
from pwalk import walk, report
# 1. Drop-in replacement for os.walk() — but 5-10x faster!
for dirpath, dirnames, filenames in walk('/data'):
print(f"{dirpath}: {len(filenames)} files")
# 2. Generate compressed filesystem report
output, errors = report('/data', compress='zstd')
# Creates scan.csv.zst - 23x smaller than plain CSV!
# 3. Analyze with DuckDB
import duckdb
df = duckdb.connect().execute(f"SELECT * FROM '{output}'").fetchdf()
print(df.head())
Basic Usage
from pwalk import walk
# Identical to os.walk() but parallel and much faster
for dirpath, dirnames, filenames in walk('/data'):
print(f"Directory: {dirpath}")
print(f" Subdirectories: {len(dirnames)}")
print(f" Files: {len(filenames)}")
Full API Compatibility
from pwalk import walk
# All os.walk() parameters supported
for dirpath, dirnames, filenames in walk(
'/data',
topdown=True, # Process parents before children
onerror=handle_error, # Error callback
followlinks=False # Don't follow symlinks
):
# Modify dirnames in-place to prune traversal
dirnames[:] = [d for d in dirnames if not d.startswith('.')]
Advanced: Thread Control
from pwalk import walk
# Explicit thread count (default: cpu_count() or SLURM_CPUS_ON_NODE)
for dirpath, dirnames, filenames in walk('/data', max_threads=16):
process_directory(dirpath, filenames)
# Traverse snapshots (disabled by default)
for dirpath, dirnames, filenames in walk('/data', ignore_snapshots=False):
...
Filesystem Metadata Reports
CSV Output with Zstd Compression (Default)
from pwalk import report
# Generate compressed CSV (8-10x smaller, DuckDB compatible)
output, errors = report(
'/data',
output='scan.csv',
compress='zstd' # or 'gzip', 'auto', 'none'
)
print(f"Report saved to: {output}")
print(f"Inaccessible directories: {len(errors)}")
CSV Format (100% compatible with John Dey's pwalk):
inode,parent-inode,directory-depth,"filename","fileExtension",UID,GID,st_size,st_dev,st_blocks,st_nlink,"st_mode",st_atime,st_mtime,st_ctime,pw_fcount,pw_dirsum
Compression Options:
compress='auto': Use zstd if available, else uncompressed (default)compress='zstd': Force zstd compression (8-10x, fast)compress='gzip': Use gzip compression (6-7x, slower but universal)compress='none': No compression
DuckDB Analysis Workflow
# 1. Generate compressed CSV report
from pwalk import report
output, errors = report('/data', output='scan.csv', compress='zstd')
# 2. DuckDB reads .csv.zst natively!
import duckdb
con = duckdb.connect('fs_analysis.db')
con.execute("CREATE TABLE fs AS SELECT * FROM 'scan.csv.zst'")
# 3. Answer questions like "Who used the last 10TB?"
result = con.execute("""
SELECT
uid,
count(*) as file_count,
sum(st_size) / (1024*1024*1024*1024) as size_tb
FROM fs
WHERE st_ctime > unixepoch(now() - INTERVAL 7 DAY)
GROUP BY uid
ORDER BY size_tb DESC
LIMIT 10
""").fetchdf()
print(result)
# 4. Optional: Convert to Parquet for long-term storage
con.execute("""
COPY (SELECT * FROM 'scan.csv.zst')
TO 'scan.parquet' (FORMAT PARQUET, COMPRESSION SNAPPY)
""")
Filesystem Repair (Root Only)
from pwalk import repair
# Dry-run to preview changes
repair(
'/shared',
dry_run=True,
change_gids=[1234, 5678], # Treat these GIDs like private groups
force_group_writable=True, # Ensure group read+write+execute
exclude=['/shared/archive'] # Skip specific paths
)
# Apply changes
repair('/shared', dry_run=False, force_group_writable=True)
Real-World Use Cases
1. Answer Critical Storage Questions Fast
from pwalk import report
import duckdb
# Generate comprehensive filesystem metadata
report('/data', compress='zstd') # Done in minutes, not hours!
# Who used the last 10 TB this week?
con = duckdb.connect()
result = con.execute("""
SELECT UID, COUNT(*) as files, SUM(st_size)/1e12 as TB
FROM 'scan.csv.zst'
WHERE st_ctime > unixepoch(now() - INTERVAL 7 DAY)
GROUP BY UID ORDER BY TB DESC LIMIT 10
""").fetchdf()
2. Find Storage Hogs and Opportunities
# Find directories with >1M files (performance issues!)
huge_dirs = con.execute("""
SELECT "filename", pw_fcount, pw_dirsum/1e9 as GB
FROM 'scan.csv.zst'
WHERE pw_fcount > 1000000
ORDER BY pw_fcount DESC
""").fetchdf()
# Find ancient files (cleanup candidates)
old_files = con.execute("""
SELECT "filename", st_size, datetime(st_mtime, 'unixepoch')
FROM 'scan.csv.zst'
WHERE st_mtime < unixepoch(now() - INTERVAL 2 YEAR)
ORDER BY st_size DESC LIMIT 100
""").fetchdf()
3. Monitor Growth Over Time
# Weekly snapshots
import schedule
def weekly_snapshot():
timestamp = time.strftime('%Y%m%d')
report('/data', output=f'snapshot_{timestamp}.csv.zst')
schedule.every().sunday.at("02:00").do(weekly_snapshot)
Performance
Based on John Dey's pwalk C implementation with additional optimizations:
- Speed: 8,000-30,000 stat operations per second
- Speedup: 5-10x faster than os.walk()
- Example: 50 million files in ~41 minutes at 20K stats/sec
- Scaling: Performance depends on storage system, host CPU, and file layout
- Compression: Zstd reduces CSV size by 8-10x with minimal overhead
Benchmark vs os.walk()
import time
from pwalk import walk
import os
# Test directory with 10M files
path = '/large_dataset'
# Standard os.walk()
start = time.time()
count = sum(len(files) for _, _, files in os.walk(path))
print(f"os.walk(): {count} files in {time.time()-start:.1f}s")
# Parallel pwalk
start = time.time()
count = sum(len(files) for _, _, files in walk(path))
print(f"pwalk: {count} files in {time.time()-start:.1f}s")
Expected speedup: 10-100x depending on filesystem characteristics.
Technical Architecture
- Single Optimized C Extension:
_pwalk_core— 320 lines of highly optimized C - Thread-Local Buffers: 512KB per thread, zero lock contention during traversal
- Multithreaded Traversal: Up to 32 parallel threads using John Dey's proven algorithm
- Streaming Compression: Zstd level 1 for 23x compression at 200-400 MB/s
- SLURM Integration: Auto-detects
SLURM_CPUS_ON_NODEfor HPC environments - Zero Dependencies: No external Python packages — ships ready to run
Why No Dependencies Matters
Unlike other tools that require PyArrow (~50 MB), numpy, pandas, etc., pwalk installs in seconds with zero dependencies. This means:
- ✅ Instant installation on air-gapped HPC systems
- ✅ No version conflicts with existing packages
- ✅ Minimal attack surface for security-conscious environments
- ✅ Works everywhere Python 3.10+ works
Contributing
Contributions welcome! Based on the rock-solid filesystem-reporting-tools by John Dey.
License
GPL v2 — Same as John Dey's original pwalk implementation.
Links
- PyPI: https://pypi.org/project/pwalk/
- GitHub: https://github.com/dirkpetersen/python-pwalk
- Issues: https://github.com/dirkpetersen/python-pwalk/issues
- DuckDB: https://duckdb.org — Perfect companion for analyzing pwalk output
- Original pwalk: https://github.com/john-dey/filesystem-reporting-tools
Built with ❤️ for system administrators and HPC users worldwide. Based on John Dey's battle-tested pwalk implementation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pwalk-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pwalk-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 31.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
988e0374a8b87d159448a7fd85bbdf7325e87dbae18c3425e90ef079bb2393ca
|
|
| MD5 |
6cbe82f22e1a65c67a1eb128a1c97ebb
|
|
| BLAKE2b-256 |
e6931ae93c04c55e5987a3e27845bb196b9ebed1b9921906e0395d8b29df970d
|
Provenance
The following attestation bundles were made for pwalk-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on dirkpetersen/python-pwalk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pwalk-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
988e0374a8b87d159448a7fd85bbdf7325e87dbae18c3425e90ef079bb2393ca - Sigstore transparency entry: 621695486
- Sigstore integration time:
-
Permalink:
dirkpetersen/python-pwalk@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dirkpetersen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pwalk-0.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pwalk-0.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 31.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5db96d06c2de43cf08c1e68ccf0c9a09e844950f32583b34bc2e6b6904387c2
|
|
| MD5 |
921bc3deb152a86d3348b441731723e3
|
|
| BLAKE2b-256 |
533045cc792b7e82ecde8739d5c8a6b7ec3820ce27f821f56484eb7aa8f30994
|
Provenance
The following attestation bundles were made for pwalk-0.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl:
Publisher:
publish-pypi.yml on dirkpetersen/python-pwalk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pwalk-0.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl -
Subject digest:
d5db96d06c2de43cf08c1e68ccf0c9a09e844950f32583b34bc2e6b6904387c2 - Sigstore transparency entry: 621695493
- Sigstore integration time:
-
Permalink:
dirkpetersen/python-pwalk@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dirkpetersen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pwalk-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pwalk-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 32.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87b6f255558f38e9fa60add93f726d90a04f687c75836dadbb7d20f42673f966
|
|
| MD5 |
b0a56d1d7b08e4c774b86045ddd832ec
|
|
| BLAKE2b-256 |
db047506b08493f1e3ad336d7dced106424b0ce0302df1bfedfd745218d12a29
|
Provenance
The following attestation bundles were made for pwalk-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on dirkpetersen/python-pwalk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pwalk-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
87b6f255558f38e9fa60add93f726d90a04f687c75836dadbb7d20f42673f966 - Sigstore transparency entry: 621695491
- Sigstore integration time:
-
Permalink:
dirkpetersen/python-pwalk@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dirkpetersen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pwalk-0.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pwalk-0.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 31.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1246d9e03368baaa35f7569ca04939f61c5cf6e2181706ad5fd399784bf3047
|
|
| MD5 |
7c71bdb65c35a02e411092fb92d9bc33
|
|
| BLAKE2b-256 |
54d15edaa65932d7f78d3d9e962aa27d8f863e46293a1422308618567ce5d41c
|
Provenance
The following attestation bundles were made for pwalk-0.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl:
Publisher:
publish-pypi.yml on dirkpetersen/python-pwalk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pwalk-0.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl -
Subject digest:
c1246d9e03368baaa35f7569ca04939f61c5cf6e2181706ad5fd399784bf3047 - Sigstore transparency entry: 621695489
- Sigstore integration time:
-
Permalink:
dirkpetersen/python-pwalk@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dirkpetersen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pwalk-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pwalk-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 31.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35362ea425ec6a54f4513bd65e1f0e89d3d22f088a9fe42cbfcf618508b2e3e1
|
|
| MD5 |
dbe4ad1189e1eb5798aff0f010ce58b8
|
|
| BLAKE2b-256 |
a2f5b228dfbe729578159b5e536cf3b5c6755bee0c42fe9f0cc85dfe8e8bf2e2
|
Provenance
The following attestation bundles were made for pwalk-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on dirkpetersen/python-pwalk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pwalk-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
35362ea425ec6a54f4513bd65e1f0e89d3d22f088a9fe42cbfcf618508b2e3e1 - Sigstore transparency entry: 621695484
- Sigstore integration time:
-
Permalink:
dirkpetersen/python-pwalk@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dirkpetersen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pwalk-0.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pwalk-0.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 30.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d48ade9f4b0a892c997a9e049959c3bde106f48edddcf81f9e1ba4df5da9cc77
|
|
| MD5 |
ef98192d33d1a8cf86ed954029a67cf0
|
|
| BLAKE2b-256 |
f496a2ab1feaf5356374d56bb8e875bb3d0dfc97d002c88b3b19e1b71eb10986
|
Provenance
The following attestation bundles were made for pwalk-0.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl:
Publisher:
publish-pypi.yml on dirkpetersen/python-pwalk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pwalk-0.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl -
Subject digest:
d48ade9f4b0a892c997a9e049959c3bde106f48edddcf81f9e1ba4df5da9cc77 - Sigstore transparency entry: 621695488
- Sigstore integration time:
-
Permalink:
dirkpetersen/python-pwalk@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dirkpetersen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@33ec6f0a58d4472c4376b4c6dd741482590c0334 -
Trigger Event:
release
-
Statement type: