Skip to content

Conversation

imstevenpmwork
Copy link
Collaborator

@imstevenpmwork imstevenpmwork commented Oct 7, 2025

This PR steams from the conversation in: #1959

Rationale

Why is compression not critical at this step?
We aim to preserve as much raw image information as possible, as these images are intermediate artifacts. They will later be compressed during video encoding at the end of each episode, where compression efficiency potentially matters more.

How was the compression level chosen?
The optimal compression level depends on the entropy characteristics of the images. However, since our main goal here is speed rather than file size, a low compression level is preferred to minimize CPU overhead during frequent writes.

Why compress_level=1 instead of 0?
Although 0 uses the least CPU for compression, it can paradoxically result in slower overall performance due to the larger output files. Writing significantly larger files increases I/O time, often offsetting any CPU gains.
Setting compress_level=1 provides a better balance between CPU usage and disk throughput.

Future Work

As suggested in the original ticket, compression and encoding parameters (e.g., format, compression level, codec options) should eventually be exposed to users for fine-grained control. This will be addressed in a future PR; although it is not currently a priority.

@imstevenpmwork imstevenpmwork self-assigned this Oct 7, 2025
@imstevenpmwork imstevenpmwork added enhancement Suggestions for new features or improvements dataset Issues regarding data inputs, processing, or datasets refactor Code cleanup or restructuring without changing behavior performance Issues aimed at improving speed or resource usage labels Oct 7, 2025
@imstevenpmwork imstevenpmwork linked an issue Oct 7, 2025 that may be closed by this pull request
2 tasks
Copy link
Collaborator

@CarolinePascal CarolinePascal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment : wouldn't this be the perfect occasion to add a docstring to this method ? c:

@imstevenpmwork
Copy link
Collaborator Author

Just a small comment : wouldn't this be the perfect occasion to add a docstring to this method ? c:

Done in: d52473b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dataset Issues regarding data inputs, processing, or datasets enhancement Suggestions for new features or improvements performance Issues aimed at improving speed or resource usage refactor Code cleanup or restructuring without changing behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

write_image() is slow due to default compress_level=6
2 participants