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

Avoid FieldVector outer constructor inference #2115

Merged
merged 2 commits into from
Sep 22, 2023
Merged

Avoid FieldVector outer constructor inference #2115

merged 2 commits into from
Sep 22, 2023

Conversation

charleskawczynski
Copy link
Member

@charleskawczynski charleskawczynski commented Sep 19, 2023

I realized that most of the allocations in the callbacks are actually coming from inference in the FieldVector outer constructor:

Screen Shot 2023-09-19 at 11 08 19 AM

This PR should (hopefully) avoid this, by calling the outer constructor where the undertype is pre-specified.

@charleskawczynski
Copy link
Member Author

Also, I plan to update the flame allocation tests once we get numbers from CI.

@charleskawczynski
Copy link
Member Author

Allocations in the callbacks flame in this PR:

Screen Shot 2023-09-19 at 11 47 51 AM

@simonbyrne
Copy link
Member

should we just @nospecialize the constructor?

@charleskawczynski
Copy link
Member Author

should we just @nospecialize the constructor?

Will that help? I think it's the recursive promote_type (T = promote_type(map(RecursiveArrayTools.recursive_bottom_eltype, values)...,)) that's type unstable. I think it's okay so long we avoid it in hot loops 🤷🏻

@charleskawczynski
Copy link
Member Author

I realized that most of the allocations in the callbacks are actually coming from inference in the FieldVector outer constructor:

Correction: most of the allocations in the callbacks that Profile.allocs sees (see JuliaLang/julia#50187)

@charleskawczynski
Copy link
Member Author

bors r+

bors bot added a commit that referenced this pull request Sep 20, 2023
2115: Avoid FieldVector outer constructor inference r=charleskawczynski a=charleskawczynski

I realized that most of the allocations in the callbacks are actually coming from _inference_ in the FieldVector outer constructor:

<img width="1896" alt="Screen Shot 2023-09-19 at 11 08 19 AM" src="https://github.com/CliMA/ClimaAtmos.jl/assets/1880641/9600dd17-4862-4730-8180-6e5d19a163d8">

This PR should (hopefully) avoid this, by calling the outer constructor where the undertype is pre-specified.

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
@bors
Copy link
Contributor

bors bot commented Sep 20, 2023

Build failed:

@charleskawczynski
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 22, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 0b4a150 into main Sep 22, 2023
7 of 8 checks passed
@bors bors bot deleted the ck/cb_inf branch September 22, 2023 01:49
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