Skip to content

Conversation

@munsonbh
Copy link
Owner

Summary

This PR implements several performance optimizations to significantly speed up image processing, along with critical bug fixes.

Changes

  • Parallel image processing: Processes multiple images concurrently using threading (default: CPU core count)
  • Parallel format conversion: Converts to JPEG XL and WebP simultaneously for each image
  • Optimized compression settings:
    • JPEG XL effort reduced from 9 to 7 (faster with minimal size difference)
    • WebP method reduced from 6 to 4 (faster with minimal size difference)
  • Smart skipping: Automatically skips files already in optimized formats (JXL/WebP)
  • New flag: Added --workers flag to control parallelism
  • Fixed exception logging: Exception tracebacks are now properly logged in worker threads where exceptions occur
  • Fixed hang detection: Added comprehensive hang detection to parallel processing path to match single-threaded behavior

Performance Improvements

  • Individual images: ~2-3x faster per image (lower compression effort + parallel conversions)
  • Overall throughput: ~4-8x faster with parallel processing (depends on CPU cores)
  • Example: Processing 76 images could go from ~85 minutes to ~10-15 minutes on an 8-core system

Bug Fixes

  1. Exception logging fix: Moved exc_info=True to worker thread where exception context exists
  2. Hang detection fix: Added timeout and hang detection to parallel processing path to prevent indefinite blocking

Testing

  • All existing functionality preserved
  • Compression quality maintained (minimal size difference with faster settings)
  • Thread-safe implementation with proper error handling
  • Exception logging fixed to properly capture tracebacks in worker threads
  • Hang detection works in both single-threaded and parallel processing paths

Documentation

  • Updated README with performance optimizations section
  • Added usage examples for --workers flag

…settings

- Add parallel image processing using threading (default: CPU core count)
- Convert JPEG XL and WebP simultaneously for each image
- Reduce JPEG XL effort from 9 to 7 (faster with minimal size difference)
- Reduce WebP method from 6 to 4 (faster with minimal size difference)
- Skip files already in optimized formats (JXL/WebP)
- Add --workers flag to control parallelism
- Update README with performance optimizations documentation

Expected speed improvements: 4-8x faster overall processing time
The exc_info=True parameter only works within an active exception handler.
Moved exception logging with full traceback to worker thread where exceptions occur,
and removed exc_info=True from main thread where we only have error message strings.
The multi-threaded path was missing hang detection that exists in the
single-threaded path. Added timeout to result_queue.get() and implemented
hang detection logic with notifications to match single-threaded behavior.

- Add timeout to result_queue.get() to prevent indefinite blocking
- Implement hang detection checking every 60 seconds
- Identify and report stuck images when no progress for 5+ minutes
- Send notifications matching single-threaded path behavior
@munsonbh munsonbh merged commit 2b4adfb into main Dec 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants