Increase performance by reducing lookups #1456
Labels
core
Issues related to the computational core in Julia
performance
Relates to runtime performance or convergence
#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 theEdgeMetadata
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 whoseformulate_flow!
uses this function:PidControl
will probably never be used heavily enough so that this becomes a performance bottleneckUserDemand
: store the upstream basin index perUserDemand
nodeManningResistance
: store the upstream and downstream basin index perManningresistance
nodeLinearResistance
,Outlet
: store the upstream and downstream basin index perLinearResistance
node (although both can beLevelBoundary
nodes, not sure yet about this)basin_bottom
also because of a basin index lookup. This function is only used forTabulatedRatingCurve
, so I propose storing upstream and downstream bottoms in theTabulatedRatingCurve
struct.The text was updated successfully, but these errors were encountered: