Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Clone to Decoder #227

Closed
wants to merge 1 commit into from
Closed

Conversation

tristan-morris
Copy link

Added clone to image-tiff, allowing the Decoder to be cloned and re-used.

Useful for Tiffs located on remote storage, without needing decoding.

@fintelia
Copy link
Contributor

fintelia commented Apr 5, 2024

Could you say a bit more about the motivation for this PR?

@tristan-morris
Copy link
Author

tristan-morris commented Apr 10, 2024

My motivation was being able to performantly perform concurrent reads into a geotiff. This is most problematic/slow during the initial IFD and header parse as there are many seek and reads which need to be performed. This slowness is most pronounced when a geotiff is hosted on a remote s3 bucket, and opening multiple readers would be very slow.

I'll end up closing this PR as I've since discovered std::fs::File (rust-lang/rfcs#2259) essentially shares the same file handle and so the seek+read breaks down very quickly as the position is moved. Not sure I agree with this design decision behind a cloned Reader sharing the OS file handle, but it makes sense. So simply adding Clone isn't so simple for the 99% use-case :)

@fintelia
Copy link
Contributor

Hm, that does seem like too much of a gotcha to go forward with this PR. I would like to have a better API that was more conducive to parallel decoding, but API design is hard and I haven't been able to devote much time to refactoring/improvements to this crate

@fintelia fintelia closed this Apr 11, 2024
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