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

Increase performance by reducing lookups #1456

Closed
3 tasks done
SouthEndMusic opened this issue May 7, 2024 · 0 comments · Fixed by #1457
Closed
3 tasks done

Increase performance by reducing lookups #1456

SouthEndMusic opened this issue May 7, 2024 · 0 comments · Fixed by #1457
Labels
core Issues related to the computational core in Julia performance Relates to runtime performance or convergence

Comments

@SouthEndMusic
Copy link
Collaborator

SouthEndMusic commented May 7, 2024

#1448 Gave some nice performance improvements. With these changes, a small number of utility functions are now dominating the profile (for the RWS HWS model):

  • set_flow! because of a dictionary lookup. To resolve this without much added complexity, I propose to not (just) store inflow and outflow IDs like in Pre-calculate flow neighbor IDs for Pump, Outlet, UserDemand, FractionalFlow, TabulatedRatingCurve #1448, but to store the EdgeMetadata of the inflow and outflow edges (which also includes the inflow and outflow IDs). Also add the flow index to the metadata (and make the distinction between that and the edge ID clear), so that it doesn't have to be retrieved by the aforementioned lookup.
  • get_level because of a basin index lookup. Per node type whose formulate_flow! uses this function:
    • PidControl will probably never be used heavily enough so that this becomes a performance bottleneck
    • UserDemand: store the upstream basin index per UserDemand node
    • ManningResistance: store the upstream and downstream basin index per Manningresistance node
    • LinearResistance, Outlet: store the upstream and downstream basin index per LinearResistance node (although both can be LevelBoundary nodes, not sure yet about this)
  • basin_bottom also because of a basin index lookup. This function is only used for TabulatedRatingCurve, so I propose storing upstream and downstream bottoms in the TabulatedRatingCurve struct.
@SouthEndMusic SouthEndMusic added performance Relates to runtime performance or convergence core Issues related to the computational core in Julia labels May 7, 2024
SouthEndMusic added a commit that referenced this issue May 13, 2024
Fixes #1456. The main speedup
is due to adding basin indices to the edge metadata, and precalculating
vectors of the metadata of inflow and outflow edges of several node
types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues related to the computational core in Julia performance Relates to runtime performance or convergence
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant