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

Allow initialising shaders in parallel #455

Merged
merged 7 commits into from
Feb 22, 2024

Conversation

DJMcNab
Copy link
Member

@DJMcNab DJMcNab commented Feb 21, 2024

Headline stats: Reduces shader initialisation time from ~5seconds on Pixel 6 to ~2 seconds (with no compromises on runtime performance)

This is disabled on wasm because there are no threads.
This is disabled on macOS, following the prior art in Bevy (bevyengine/bevy#10812 (comment))

This work queuing system is not intended to be the final form of this, which is why I have made this optional.
This would not be suitable for many consumers, who will likely already have their own thread pool.
We currently just create short lived threads using std::thread::scope.

I still think this is useful to have for experimental purposes, and I think it should also be useful in Xilem in its current form. @xorgy might need you to confirm that

This is not async shader initialisation, which I do also plan to add. This is a useful first step towards that, however

crates/tests/src/lib.rs Outdated Show resolved Hide resolved
@xorgy
Copy link
Member

xorgy commented Feb 21, 2024

Is there any reason somebody would want not to initialize in parallel if it is supported on the platform? Memory?

(talking about aside from cases where people have their own thread pooling)

@xorgy
Copy link
Member

xorgy commented Feb 21, 2024

I still think this is useful to have for experimental purposes, and I think it should also be useful in Xilem in its current form. @xorgy might need you to confirm that

I'll give it a go and let you know.

@DJMcNab
Copy link
Member Author

DJMcNab commented Feb 21, 2024

Is there any reason somebody would want not to initialize in parallel if it is supported on the platform? Memory?

(talking about aside from cases where people have their own thread pooling)

There is also a possibility of starving other threads of the resources they need. And yeah, there is some additional (temporary) memory usage required, although I think (but haven't checked exact numbers) that the amount should be minimal

@waywardmonkeys
Copy link
Contributor

This is disabled on macOS, following the prior art in

I think you left off something...

@DJMcNab
Copy link
Member Author

DJMcNab commented Feb 21, 2024

Thanks, resolved

Copy link
Contributor

@ratmice ratmice left a comment

Choose a reason for hiding this comment

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

Given that the bits I was worried about commitment to semver for it turns out are not actually pub at the package level, this seems fine to me.

@DJMcNab DJMcNab added this pull request to the merge queue Feb 22, 2024
Merged via the queue into linebender:main with commit 6fa114c Feb 22, 2024
8 checks passed
@DJMcNab DJMcNab deleted the parallel-initialisation branch February 22, 2024 11:25
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.

4 participants