Skip to content

Improved History recording efficiency - no more exponential run-time increase possibly #275

@sniffo

Description

@sniffo

Hi,

Some people might be interested so I am posting here.

I noticed that increasing the length of a simulation using the EulerSolver caused the total run time of simulations to increase exponentially (Don't have testing data as I did not save the run times but noticed as I was tracking them, will gather some when I have time). Once I did some profiling and improved the efficiency of some geometry and gradient methods, the behavior persisted but then I found that the History.record method was to blame.

The method uses pd.concat method every time to add the datasets onto increasingly larger datasets in History.datasets. This causes the method to slow down during the course of the simulation as it is loaded on to memory each time with a larger dataframe. I've changed it so that History.datasets is now a dictionary of dictionaries. History.datasets now contains dictionaries for all elements (vert, edge, face, and cell if necessary), and each element dictionary now contains all the datasets as key value pairs with the keys being the time points and the values being the datasets at those time points.

I then introduced a History instance method History.update_datasets(), which is run within the EulerSolver.solve() method at the final time-point, which concatenates all of the datasets within the dictoinaries to provide the History.datasets as was implemented previously. This significantly reduced the time to record and it no longer increases the tun time exponentially. I have not done extensive testing yet, but all other History methods should still work as intended.

@glyg please let me know if you would like me to add these changes to my PR and any specific tests you'd like to see. I will be updating this issue with run-time tests with different numbers of time-steps.

Thanks,
Tasnif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions