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

[Merged by Bors] - Make some asset loading functions monomorphic #1861

Closed
wants to merge 1 commit into from

Conversation

bjorn3
Copy link
Contributor

@bjorn3 bjorn3 commented Apr 9, 2021

This reduces the size of executables when using bevy as dylib by
ensuring that they get codegened in bevy_assets instead of the game
itself. This by extension avoids pulling in parts of bevy_tasks and
async_task.

Before this change the breakout example was 923k big after this change
it is only 775k big for cg_clif. For cg_llvm in release mode breakout
shrinks from 356k to 316k. For cg_llvm in debug mode breakout shrinks
from 3814k to 3057k.

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

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

None of the changes are public facing, this is entirely internal.

@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change labels Apr 9, 2021
@bjorn3
Copy link
Contributor Author

bjorn3 commented Apr 9, 2021

For cg_llvm in release mode breakout shrinks from 356k to 316k. For cg_llvm in debug mode breakout shrinks from 3814k to 3057k.

@bjorn3 bjorn3 force-pushed the monomorphize_asset_loading branch 3 times, most recently from a6217c2 to 0851fd8 Compare April 9, 2021 17:26
}

// TODO: properly set failed LoadState in all failure cases
async fn load_async<'a, P: Into<AssetPath<'a>>>(
async fn load_async<'a>(
Copy link
Member

Choose a reason for hiding this comment

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

For now I think this is reasonable because we don't export it. But some potential future pub async load_async() variant should be generic to have parity with load().

This reduces the size of executables when using bevy as dylib by
ensuring that they get codegened in bevy_assets instead of the game
itself. This by extension avoids pulling in parts of bevy_tasks and
async_task.

Before this change the breakout example was 923k big after this change
it is only 775k big for cg_clif. For cg_llvm in release mode breakout
shrinks from 356k to 316k. For cg_llvm in debug mode breakout shrinks
from 3814k to 3057k.
@bjorn3 bjorn3 force-pushed the monomorphize_asset_loading branch from 0851fd8 to 8592b86 Compare April 10, 2021 07:48
@bjorn3
Copy link
Contributor Author

bjorn3 commented Apr 10, 2021

CI passes.

@bjorn3 bjorn3 added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Apr 10, 2021
@cart
Copy link
Member

cart commented Apr 10, 2021

bors r+

bors bot pushed a commit that referenced this pull request Apr 10, 2021
This reduces the size of executables when using bevy as dylib by
ensuring that they get codegened in bevy_assets instead of the game
itself. This by extension avoids pulling in parts of bevy_tasks and
async_task.

Before this change the breakout example was 923k big after this change
it is only 775k big for cg_clif. For cg_llvm in release mode breakout
shrinks from 356k to 316k. For cg_llvm in debug mode breakout shrinks
from 3814k to 3057k.
@bors bors bot changed the title Make some asset loading functions monomorphic [Merged by Bors] - Make some asset loading functions monomorphic Apr 10, 2021
@bors bors bot closed this Apr 10, 2021
@bjorn3 bjorn3 deleted the monomorphize_asset_loading branch April 10, 2021 16:34
jihiggins pushed a commit to jihiggins/bevy that referenced this pull request Apr 18, 2021
This reduces the size of executables when using bevy as dylib by
ensuring that they get codegened in bevy_assets instead of the game
itself. This by extension avoids pulling in parts of bevy_tasks and
async_task.

Before this change the breakout example was 923k big after this change
it is only 775k big for cg_clif. For cg_llvm in release mode breakout
shrinks from 356k to 316k. For cg_llvm in debug mode breakout shrinks
from 3814k to 3057k.
ostwilkens pushed a commit to ostwilkens/bevy that referenced this pull request Jul 27, 2021
This reduces the size of executables when using bevy as dylib by
ensuring that they get codegened in bevy_assets instead of the game
itself. This by extension avoids pulling in parts of bevy_tasks and
async_task.

Before this change the breakout example was 923k big after this change
it is only 775k big for cg_clif. For cg_llvm in release mode breakout
shrinks from 356k to 316k. For cg_llvm in debug mode breakout shrinks
from 3814k to 3057k.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants