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

Decrease allocations #60

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Decrease allocations #60

wants to merge 6 commits into from

Conversation

oxinabox
Copy link
Member

@oxinabox oxinabox commented Feb 2, 2020

Turns out type-stability was causing a bunch of allocations.
Type inference was failing for some reason.

Also tracking history surpisingly, causes allocations.
We don't need to track history when doing grad anyway.

This is built ontop of #59 and that should be merged first.

using BenchmarkTools
using FiniteDifferences

const _fdm = central_fdm(2,1);
const _fdm5 = central_fdm(5,1);

const xs = collect(1:0.1:200);
f(x) = sum(sin, x);
@btime grad($_fdm, $f, $xs);
@btime grad($_fdm5, $f, $xs);

This PR decreases allocation count by >60%
and decreases allocation amoun t by >30%.

But that does not translate directly into speed.
I guess it won't pay off much til the garbage collector gets avoided...

Current (oxmut1)

julia> @btime grad($_fdm, $f, $xs);
  202.552 ms (154789 allocations: 4.26 MiB)

julia> @btime grad($_fdm5, $f, $xs);
  413.311 ms (162753 allocations: 5.45 MiB)

New with Stability improvements

julia> @btime grad($_fdm, $f, $xs);
  200.205 ms (49777 allocations: 2.66 MiB)

julia> @btime grad($_fdm5, $f, $xs);
  398.832 ms (59732 allocations: 3.87 MiB)

src/methods.jl Outdated Show resolved Hide resolved
@willtebbutt
Copy link
Member

@oxinabox what's the status of this PR?

@oxinabox
Copy link
Member Author

oxinabox commented Apr 9, 2020

Current status is the test failures need debugging and fixing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants