SpaceHoarder is a GTK3-based disk space visualization tool that uses interactive treemap visualizations to help users understand and manage their storage usage. The application features high-performance rendering with optional Rust acceleration.
/home/ray/Desktop/files/wrk/sphoard exp (copy)/
├── main.py # Application entry point
├── spacehoarder/ # Main application package
├── scanners/ # Experimental scanner implementations
├── doc/ # Documentation and benchmarks
├── benchmark_accelerator.py # Performance testing for Rust accelerator
├── verify_accelerator.py # Validation tests for accelerator
├── verify_import.py # Import verification script
├── check_assignment.py # Development utility
├── check_cairo_ptr.py # Cairo pointer validation utility
├── goals.txt # Project TODOs
├── notes.md # Performance tuning documentation
└── .agent/ # AI agent workflow definitions
The main application package containing all GTK3 UI components and business logic.
| File | Purpose |
|---|---|
__init__.py |
Package initializer |
main_window.py |
Primary application window (SpaceHoarderApp, SpaceHoarderWindow) |
header_bar.py |
GTK HeaderBar implementation with navigation controls |
treemap_widget.py |
Core rendering engine - Highly optimized treemap visualization widget |
scanner.py |
Directory scanning logic with size calculation |
gio_scanner.py |
GIO-based scanner for virtual filesystems (FTP, SMB, WebDAV, etc.) |
resolvers.py |
Path resolution strategies (FUSE → native backend URIs) |
models.py |
Data models for directory/file representation |
config.py |
Application configuration and color themes |
utils.py |
Utility functions (e.g., hex to RGB conversion) |
- SpaceHoarderApp: GTK Application class handling CLI arguments and activation
- SpaceHoarderWindow: Main window with:
- Treemap visualization integration
- Thread-safe directory scanning
- Context menu operations (copy path, open, show in file manager, trash)
- Navigation controls (up directory, refresh)
- D-Bus integration for file manager highlighting
High-performance Cairo-based treemap renderer with:
- Squarified treemap layout algorithm
- Size culling (configurable via
CULL_SIZEconstant) - Smart text rendering with adaptive character estimation
- Loop-invariant optimization for color calculations
- Interactive features: click navigation, right-click context menus
- Theme-aware rendering (light/dark mode support)
Performance Tunables (documented in notes.md):
CULL_SIZE = 2.0: Skip boxes smaller than 2 pixelsTEXT_THRESHOLD: Minimum box size for text rendering- Character width estimation multiplier (0.4-0.6 range)
Directory traversal and size calculation with:
- Recursive directory scanning
- Size aggregation
- Error handling for permission issues
- Optional Rust accelerator integration
GIO-based scanner for virtual filesystems (FTP, SMB, WebDAV).
Scan Modes:
- Deep Threading (
_WorkQueueScanner): Work-queue based parallel scanning. All threads share a queue of directories. Supports adaptive concurrency (ADAPTIVE_SCANNING=Trueramps threads up/down based on server stability). - Single-Threaded (
_recursive_scan_gio): Fallback for debugging or servers rejecting concurrent connections. Triggered byMAX_SCAN_THREADS=1. - Async (experimental): Dispatches to
gio_async.pywhenUSE_ASYNC_SCANNER=True.
Features:
- Adaptive concurrency management (auto-adjusts thread count based on success/failure)
- Retry logic for transient network errors (via
gio_guards) - Content-type sniffing to handle misidentified files (e.g.,
.lnkfiles) - Protocol detection (FTP, SMB, WebDAV)
- Integration with path resolvers to bypass FUSE layer
Note: Shallow parallel scanning and fixed-thread modes were removed in Jan 2026.
- Shallow parallel was redundant — deep threading handles both wide and deep trees.
- Fixed threads can be achieved by setting
ADAPTIVE_SCANNING=False. TheDEEP_THREADINGconfig flag is now deprecated (always True whenMAX_SCAN_THREADS > 1).
Path resolution utilities for network filesystems:
- GMount resolution (preferred): Bypasses kernel FUSE layer entirely
- String parsing fallback: Manual extraction from FUSE paths
- Converts FUSE/GVfs paths to native backend URIs (e.g.,
ftp://,dav://) - Configurable fallback strategies via
config.ENABLE_FUSE_FALLBACK
treemap_accelerator_rust_source/
├── Cargo.toml # Rust project manifest
├── Cargo.lock # Dependency lock file
├── src/
│ └── lib.rs # Rust layout calculation implementation
└── target/ # Compiled Rust artifacts (build output)
Optional native Rust implementation for treemap layout calculations to further accelerate performance on large directory trees. Provides Python bindings via PyO3/maturin.
Related Files:
benchmark_accelerator.py: Performance comparison scriptverify_accelerator.py: Correctness validation against pure Python
Experimental implementations for directory scanning optimization:
| File | Description |
|---|---|
scanner.py |
Pure Python scanner (baseline) |
scanner_threaded.py |
Multi-threaded FUSE-based scanner using ThreadPoolExecutor |
only pure rs.py |
Pure Rust scanner implementation |
both.py |
Hybrid Python/Rust scanner |
ftp_async.py |
Async FTP scanner experiment |
Purpose: Testing different approaches for optimal scanning performance before integration into main codebase.
| File | Content |
|---|---|
benchmarks.md |
Comprehensive performance benchmarks |
count.md |
File counting strategy analysis |
scandir.md |
os.scandir() vs alternatives |
walk.md |
os.walk() performance analysis |
smooth treemap.txt |
Rendering smoothness optimization notes |
benchmark.py: Main benchmark harnesscount.py,count_cm.py: File counting testsscandir.py: Scandir performance testswalk.py: Walk performance tests
examples/: Sample data/test casesimages/: Screenshots and visual documentationscandir-rs docs/: Documentation and benchmarks for scandir-rs libraryREADME.md,benchmarks.md: Performance analysiscount.md,scandir.md,walk.md: Algorithm comparisons- Test scripts:
benchmark.py,count.py,scandir.py,walk.py
Purpose: Application launcher that:
- Sets up Python module path
- Parses color configuration from
config.COLORS_STRING - Converts hex colors to RGB tuples
- Instantiates and runs
SpaceHoarderApp - Handles graceful exit
- Defined in
spacehoarder/config.py - Parsed as hex color strings → RGB tuples
- Applied to treemap rendering based on directory depth
- Supports light/dark theme switching
See notes.md for detailed tuning guidelines:
- Visual quality vs. Speed trade-offs
- Pixel-level culling thresholds
- Text rendering optimization
- Character width estimation tuning
python3 main.py [directory_path]cd spacehoarder/treemap_accelerator_rust_source
cargo build --releasepython3 benchmark_accelerator.py
python3 verify_accelerator.py- Main Thread: GTK UI event loop
- Scan Threads: Background directory scanning
- Thread Safety: Scan state management with ID-based invalidation
- Directory scan →
scanner.py - Data model creation →
models.py - Layout calculation →
treemap_widget.py(or Rust accelerator) - Cairo rendering →
treemap_widget.py - Interactive events → GTK signal handlers
- Cairo Drawing: Loop-invariant hoisting, size culling
- Text Rendering: Adaptive character estimation, threshold-based skipping
- Optional Rust: Native acceleration for layout calculations
- Lazy Rendering: Only draw visible/significant rectangles
- ✅ Connect UI selector to scanner (scanner type selection)
- 🔜 Add AVX detection to prevent SIMD-related crashes
- GTK 3.0: UI framework
- Cairo: 2D graphics rendering
- GLib: Event loop and utilities
- Python 3.x: Runtime
- Rust + Cargo (optional): For accelerator compilation
- The project is actively optimized for sub-millisecond treemap rendering
- Performance tuning parameters are externalized in
notes.md - Multiple scanner implementations suggest ongoing performance research
- Rust accelerator is optional - application functions with pure Python