Skip to content

BTreeMap: let NodeRef point to the actual type of the node - #78222

Closed
ssomers wants to merge 3 commits into
rust-lang:masterfrom
ssomers:btree_explicitly_typed_noderef
Closed

BTreeMap: let NodeRef point to the actual type of the node #78222
ssomers wants to merge 3 commits into
rust-lang:masterfrom
ssomers:btree_explicitly_typed_noderef

Conversation

@ssomers

Copy link
Copy Markdown
Contributor

Building on #78104, it's relatively easy to confine mangled target types to the space-efficient BoxedNode, and let both the map's roots and node references on the fly point to the correct type. This reduces casts to two places: one for unpacking a boxed node to its actual target, and one for Global::dealloc.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @withoutboats

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 22, 2020
@ssomers

Copy link
Copy Markdown
ContributorAuthor

r? @Mark-Simulacrum

@ssomers

Copy link
Copy Markdown
ContributorAuthor

Performance is affected:

 name old ns/iter new ns/iter diff ns/iter diff % speedup
btree::map::clone_fat_val_100_and_remove_all 82,461 69,990 -12,471 -15.12% x 1.18
btree::map::clone_slim_100 2,609 2,096 -513 -19.66% x 1.24
btree::map::clone_slim_100_and_clear 2,598 2,112 -486 -18.71% x 1.23
btree::map::clone_slim_100_and_into_iter 2,587 2,103 -484 -18.71% x 1.23
btree::map::clone_slim_100_and_remove_half 3,694 3,314 -380 -10.29% x 1.11
btree::map::clone_slim_10k_and_drain_half 332,653 374,100 41,447 12.46% x 0.89
btree::map::clone_slim_10k_and_remove_all 575,600 643,555 67,955 11.81% x 0.89
btree::map::first_and_last_0 10 34 24 240.00% x 0.29
btree::map::first_and_last_100 35 45 10 28.57% x 0.78
btree::map::first_and_last_10k 57 73 16 28.07% x 0.78
btree::map::iter_100 12,039 10,812 -1,227 -10.19% x 1.11
btree::map::iteration_mut_1000 3,664 3,127 -537 -14.66% x 1.17
btree::map::iteration_mut_100000 518,260 436,225 -82,035 -15.83% x 1.19
btree::map::iteration_mut_20 66 56 -10 -15.15% x 1.18
btree::map::range_included_excluded 416,977 461,305 44,328 10.63% x 0.90
btree::map::range_included_unbounded 144,098 177,614 33,516 23.26% x 0.81
btree::map::range_unbounded_unbounded 77,250 104,874 27,624 35.76% x 0.74
btree::set::clone_100_and_drain_half 2,366 2,887 521 22.02% x 0.82
btree::set::clone_100_and_pop_all 2,934 3,234 300 10.22% x 0.91
btree::set::clone_100_and_remove_all 3,370 4,887 1,517 45.01% x 0.69
btree::set::clone_100_and_remove_half 2,368 2,946 578 24.41% x 0.80
btree::set::clone_10k_and_drain_half 272,063 319,056 46,993 17.27% x 0.85
btree::set::clone_10k_and_remove_all 394,995 549,870 154,875 39.21% x 0.72
btree::set::clone_10k_and_remove_half 423,185 495,710 72,525 17.14% x 0.85
btree::set::difference_random_100_vs_100 707 859 152 21.50% x 0.82
btree::set::difference_random_100_vs_10k 2,363 2,790 427 18.07% x 0.85
btree::set::difference_random_10k_vs_100 52,948 63,523 10,575 19.97% x 0.83
btree::set::difference_staggered_100_vs_100 682 917 235 34.46% x 0.74
btree::set::difference_staggered_100_vs_10k 2,200 2,722 522 23.73% x 0.81
btree::set::difference_staggered_10k_vs_10k 67,823 85,244 17,421 25.69% x 0.80
btree::set::intersection_100_neg_vs_100_pos 17 27 10 58.82% x 0.63
btree::set::intersection_100_neg_vs_10k_pos 17 32 15 88.24% x 0.53
btree::set::intersection_100_pos_vs_100_neg 17 27 10 58.82% x 0.63
btree::set::intersection_100_pos_vs_10k_neg 17 32 15 88.24% x 0.53
btree::set::intersection_10k_neg_vs_100_pos 17 30 13 76.47% x 0.57
btree::set::intersection_10k_neg_vs_10k_pos 18 33 15 83.33% x 0.55
btree::set::intersection_10k_pos_vs_100_neg 17 31 14 82.35% x 0.55
btree::set::intersection_10k_pos_vs_10k_neg 18 33 15 83.33% x 0.55
btree::set::intersection_random_100_vs_100 635 728 93 14.65% x 0.87
btree::set::intersection_random_100_vs_10k 2,129 2,567 438 20.57% x 0.83
btree::set::intersection_random_10k_vs_100 2,121 2,706 585 27.58% x 0.78
btree::set::intersection_staggered_100_vs_100 617 790 173 28.04% x 0.78
btree::set::intersection_staggered_100_vs_10k 2,031 2,502 471 23.19% x 0.81
btree::set::intersection_staggered_10k_vs_10k 60,891 75,550 14,659 24.07% x 0.81
btree::set::is_subset_100_vs_10k 1,185 1,445 260 21.94% x 0.82
btree::set::is_subset_10k_vs_10k 59,529 52,343 -7,186 -12.07% x 1.14

And it has been a struggle to get gdb introspection to work, one that apparently makes no impression on CI.

@ssomers
ssomers marked this pull request as draft October 22, 2020 08:32
@jyn514jyn514 added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Oct 22, 2020
@ssomersssomers closed this Oct 24, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@ssomers@rust-highfive@Mark-Simulacrum@withoutboats@jyn514