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

Speed-boost for close!(dh::MixedDofHandler) #533

Merged
merged 2 commits into from
Nov 6, 2022

Conversation

kimauth
Copy link
Member

@kimauth kimauth commented Nov 6, 2022

Edges out a couple of anti-patterns in close!(dh::MixedDofHandler).

Example benchmark:

function construct_mixed_dof_handler(grid)
    mixed_dh = MixedDofHandler(grid)
    push!(mixed_dh, :f1, 1, Lagrange{2,RefCube,1}())
    push!(mixed_dh, :f2, 2, Lagrange{2,RefCube,1}())
    push!(mixed_dh, :f3, 1, Lagrange{2,RefCube,2}())
    close!(mixed_dh);
end
small_grid = generate_grid(Quadrilateral, (10, 10))
@btime construct_mixed_dof_handler($small_grid); 

# master: 196.791 μs (4493 allocations: 324.43 KiB)
# this PR: 52.959 μs (153 allocations: 186.04 KiB)

or for a bigger grid:

big_grid = generate_grid(Quadrilateral, (1000, 1000))
@btime construct_mixed_dof_handler($big_grid); 

# master: 3.821 s (70005918 allocations: 2.69 GiB)
# this PR: 1.229 s (454 allocations: 1.05 GiB)

Sidenote: Unfortunately the MixedDofHandler is still twice as slow as the DofHandler even with this PR, for comparison:

function construct_dof_handler(grid)
    dh = DofHandler(grid)
    push!(dh, :f1, 1, Lagrange{2,RefCube,1}())
    push!(dh, :f2, 2, Lagrange{2,RefCube,1}())
    push!(dh, :f3, 1, Lagrange{2,RefCube,2}())
    close!(dh)
end
@btime construct_dof_handler($small_grid) # 28.209 μs (140 allocations: 119.84 KiB)
@btime construct_dof_handler($big_grid) # 751.856 ms (341 allocations: 630.22 MiB)

@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2022

Codecov Report

Base: 92.31% // Head: 92.31% // No change to project coverage 👍

Coverage data is based on head (82b60c8) compared to base (8e447e2).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #533   +/-   ##
=======================================
  Coverage   92.31%   92.31%           
=======================================
  Files          22       22           
  Lines        3776     3776           
=======================================
  Hits         3486     3486           
  Misses        290      290           
Impacted Files Coverage Δ
src/Dofs/MixedDofHandler.jl 86.29% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kimauth kimauth merged commit f0efd13 into master Nov 6, 2022
@kimauth kimauth deleted the ka/speed_up_mixeddofhandler branch November 6, 2022 18:41
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.

3 participants