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 rayon feature #241

Merged
merged 3 commits into from
Nov 6, 2024
Merged

Conversation

oligamiq
Copy link
Contributor

No description provided.

Cargo.toml Outdated

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
Copy link
Contributor

@fintelia fintelia Oct 12, 2024

Choose a reason for hiding this comment

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

This isn't needed anymore, since docs.rs recently added it as the default.

@fintelia
Copy link
Contributor

Not a maintainer, but FYI this is an API breaking change because any downstream code relying on the now cfg'd out methods will no longer compile. If rayon was left as a default feature, this change could be done in a backwards compatible way

@oligamiq
Copy link
Contributor Author

All the tests have passed, but indeed, this might be a breaking change.

@johannesvollmer
Copy link
Owner

Thanks for taking the time to contribute! The changed you proposed seem solid. I would have solved it differently, but I don't have the time to do that:

As the calls to rayon are quite few and isolated, it should be possible to keep the API as-is. Then at runtime falling back to sequential processing if the rayon feature is disabled. This would require some more complicated code changed, but it would avoid us having to sprinkle cfg attributes in multiple unrelated code sections, which seems hard to maintain in my eyes (and is not backwards compatible).

The backwards incompatible changes would require major version upgrade, exr 2.0, which makes it harder for people to use the newest versions, as they have to manually update the version in their projects.

What do you think?

@oligamiq
Copy link
Contributor Author

I think it’s possible to maintain all the public structs and APIs while marking them as deprecated and falling back. I'll be busy for a few days, but after that, I can give it a try if you'd like.

@johannesvollmer
Copy link
Owner

johannesvollmer commented Oct 13, 2024

Checked the exr code and found something problematic, there is at least one public function that exposes a rayon item at compile time: pub fn new_with_thread_pool.

Someone might rely on this function. As it references the rayon thread pool in the function type signature, it would no longer compile if rayon is removed. This means we cannot get around a breaking change. Please correct me if I'm wrong.

Maybe it would be ok if the default is to enable rayon? Then the breaking change would be opt-in.

@oligamiq
Copy link
Contributor Author

That's right. I share the same opinion. While it's possible to replace the dependent types with generics, it would cause some significant breaking changes. In the case of removing Rayon from image-rs, it's acceptable to have Rayon set to default ON. However, setting Rayon to default ON is generally not advisable.

@oligamiq
Copy link
Contributor Author

Since there seem to be a lot of issues left, how about removing rayon from the default feature list at the time of a major version update?

@johannesvollmer
Copy link
Owner

after thinking about this, I'm happy to merge this. (of course we need to fix the 3 small conflicts, but that's not a big deal.) thanks for your contribution!

Cargo.toml Outdated Show resolved Hide resolved
@johannesvollmer
Copy link
Owner

johannesvollmer commented Nov 3, 2024

@fintelia (edit:) I see that image-rs uses rayon, but only with a flag. I assume image will pass this flag to the exrs dependency?

@fintelia
Copy link
Contributor

fintelia commented Nov 3, 2024

Yes. After this lands, image will switch to only enabling the rayon feature on exr when its own rayon feature is enabled

@oligamiq
Copy link
Contributor Author

oligamiq commented Nov 5, 2024

I accepted the CI-related reviews and resolved the conflicts.

Copy link
Owner

@johannesvollmer johannesvollmer left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time for the follow up! I appreciate your contributions.

@johannesvollmer johannesvollmer merged commit c405bd8 into johannesvollmer:master Nov 6, 2024
5 checks 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.

3 participants