You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
github-actionsbot
changed the title
[Spike] Performance improvement to memory footprint
[CT-2377] [Spike] Performance improvement to memory footprint
Apr 5, 2023
Spike resulted in a fix since it was easy-- but for future reference:
The issue at hand seems to be that ProviderContext and it's subclasses have an attribute dict called sql_results where all of the results from statement calls get stored via the store_results and/or store_raw_results context functions. Over time the number of entries in that dict grows and so does the memory used. The ideal solution would be to clear the dict when each calling macro is complete but unfortunately, determining the lifecycle of these classes once instantiated is a little tricky because it happens in the depths of the jinja code where we can't really effect the outcome (I think... I am def getting into language team things here).
That said, we can control what happens when we read the values via the load_results context function, so we can do something clever and remove the value from the dict as it's being returned. What this means is that <type>Context.sql_results will only ever get as big as the data you've put in but not yet assigned to a variable in jinja. For most use cases I think this works, however it does mean that we can only ever call {% set foo = load_result(result_name) %} once.
Instinctually, that feels like a best practice anyway, but I'd be curious to hear what others think.
When a macro runs a call statement with
fetch_result
set toTrue
, that result may be held in memory longer than it needs to be.The text was updated successfully, but these errors were encountered: