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 efficient resource reduction #1532

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Conversation

DavidLegg
Copy link
Contributor

@DavidLegg DavidLegg commented Aug 15, 2024

  • Tickets addressed: N/A
  • Review: By commit
  • Merge strategy: Merge (no squash)

Description

Adds reduce methods to a number of Resource monads, which do a "flat" resource reduction. That is, they use ThinResourceMonad.reduce to produce a single resource node, which collects all dependencies and reduces the dynamics, rather than the original Resources.reduce method, which creates a number of intermediate resources linear in the number of operands.

When doing large roll-ups, like a power model, those intermediate nodes each contribute a small performance overhead which can eventually add up. Providing a standard way to do reduction efficiently, and using that to do common operations like taking a sum or maximum, should help.

Verification

Some methods which use the new reduce operations, like PolynomialResources.min and max, already have unit tests. Those tests continue to pass unaltered.

Documentation

No documentation was invalidated - existing functions should have no logical changes, but they may be more efficient.
These reduce operators are mentioned in the streamline users' guide already. I wrote them once before and thought they were part of the main library, but I must have written them on another branch that has since been abandoned.

Future work

N/A

Adds reduce methods to a number of Resource monads, which do a "flat" resource reduction.
That is, they use ThinResourceMonad.reduce to produce a single resource node, which collects all dependencies and reduces the dynamics,
rather than the original Resources.reduce method, which creates a number of intermediate resources linear in the number of operands.

When doing large roll-ups, like a power model, those intermediate nodes each contribute a small performance overhead which can eventually add up.
Providing a standard way to do reduction efficiently, and using that to do common operations like taking a sum or maximum, should help.
@mattdailis mattdailis merged commit 51018bb into develop Sep 3, 2024
10 checks passed
@mattdailis mattdailis deleted the feature/streamline-reduction branch September 3, 2024 21:02
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