Skip to content

Comments

Avoid deepcopy pt. 2#16

Merged
murrellb merged 2 commits intoMurrellGroup:mainfrom
nossleinad:copy_partition
Apr 18, 2024
Merged

Avoid deepcopy pt. 2#16
murrellb merged 2 commits intoMurrellGroup:mainfrom
nossleinad:copy_partition

Conversation

@nossleinad
Copy link
Member

@nossleinad nossleinad commented Apr 9, 2024

Follow up to PR #6

-Implements copy_partition, which falls back to deepcopy but is overloaded for <:DiscretePartition and GaussianPartition in this PR.
-copy_message is implemented as the trivial generalization of copy_partition.
-deepcopy calls are replaced with copy_message calls in internal_message_init!.

Note: It is meant for copy_partition and copy_message to replace deepcopy calls throughout the whole package. A follow up PR will carry out the rest of these replacements.

Example with GaussianPartition:

tree = sim_tree(n = 1_000_000)
@time internal_message_init!(tree, GaussianPartition())

# main
 10.450746 seconds (50.00 M allocations: 3.178 GiB, 19.87% gc time, 0.05% compilation time)

# PR
 1.794678 seconds (20.00 M allocations: 1.032 GiB, 46.68% gc time)

Example with NucleotidePartition:

tree = sim_tree(n = 100_000)
@time internal_message_init!(tree, NucleotidePartition(30))

# main
 1.075276 seconds (4.43 M allocations: 1.081 GiB, 23.23% gc time, 1.02% compilation time)

# PR
 0.416153 seconds (3.20 M allocations: 912.376 MiB, 58.30% gc time)

Example with both:

tree = sim_tree(n = 100_000)
@time internal_message_init!(tree, [GaussianPartition(), NucleotidePartition(30)])

# main
 1.759613 seconds (6.13 M allocations: 1.084 GiB, 13.33% gc time, 0.63% compilation time)

# PR
0.621201 seconds (5.91 M allocations: 971.212 MiB, 41.53% gc time, 9.70% compilation time)

@murrellb murrellb merged commit 7538152 into MurrellGroup:main Apr 18, 2024
@nossleinad nossleinad mentioned this pull request Apr 19, 2024
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.

2 participants