-
Notifications
You must be signed in to change notification settings - Fork 5
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
Possible memory allocations improvements #53
Comments
I had a quick go to preallocate the buffers for julia> tdac(TDAC.tdac_params(;nprt = 1, n_time_step = 1, n_integration_step = 251, time_step = 251.0, nobs = 4, enable_timers = true));
────────────────────────────────────────────────────────────────────────────────
Time Allocations
────────────────────── ───────────────────────
Tot / % measured: 449ms / 100% 54.7MiB / 100%
Section ncalls time %tot avg alloc %tot avg
────────────────────────────────────────────────────────────────────────────────
Particle State Update 1 174ms 38.9% 174ms 9.52KiB 0.02% 9.52KiB
True State Update 1 154ms 34.4% 154ms 8.69KiB 0.02% 8.69KiB
Initialization 1 99.1ms 22.1% 99.1ms 44.2MiB 81.0% 44.2MiB
Process Noise 1 19.4ms 4.33% 19.4ms 8.55MiB 15.6% 8.55MiB
Particle Variance 1 607μs 0.14% 607μs 1.83MiB 3.35% 1.83MiB
Resample 1 271μs 0.06% 271μs 96.0B 0.00% 96.0B
Particle Mean 1 213μs 0.05% 213μs 0.00B 0.00% 0.00B
State Copy 1 61.9μs 0.01% 61.9μs 32.0B 0.00% 32.0B
Observations 2 17.7μs 0.00% 8.84μs 224B 0.00% 112B
Weights 1 14.9μs 0.00% 14.9μs 1.03KiB 0.00% 1.03KiB
Observation Noise 1 884ns 0.00% 884ns 48.0B 0.00% 48.0B
──────────────────────────────────────────────────────────────────────────────── Total memory used is cut down by more than 90%. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now that the timer tooling is directly in the main code, it's a bit easier to play with it.
By looking at the output of this run:
We can see that most of memory allocations come from the updates of the states, which call the function
tsunami_update!
. We can save some memory allocations by havingstate
to be a matrix of the right shape, and just slice the needed parts, to geteta
,mm
,nn
, etc...An additional improvement for memory allocations is to pass to
LLW2d.timestep!
the preallocated buffers fordxeta
,dyeta
,dxM
, anddyN
. This shouldn't give much speedup, but it would reduce sensibly memory allocations, and hence the pressure on the garbage collector.The text was updated successfully, but these errors were encountered: