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

Use LazyBTreeMap for region constraints. #50491

Closed
wants to merge 1 commit into from

Conversation

nnethercote
Copy link
Contributor

Because a lot of these BTreeMaps don't get anything inserted into them.

In the most extreme case, this halves the number of total bytes
allocated for a debug build of tuple-stress, from 2.2GB to 1.1GB. That
reduction in turn speeds up runs of many benchmarks, the best by 3%.

Because a lot of these BTreeMaps don't get anything inserted into them.

In the most extreme case, this halves the number of total bytes
allocated for a debug build of tuple-stress, from 2.2GB to 1.1GB. That
reduction in turn speeds up runs of many benchmarks, the best by 3%.
@rust-highfive
Copy link
Collaborator

r? @estebank

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 7, 2018
@nnethercote
Copy link
Contributor Author

Here are the benchmarks that had a run sped up by 1% or more.

tuple-stress-check
	avg: -2.2%	min: -3.3%	max: 0.0%
tuple-stress
	avg: -1.6%	min: -2.5%	max: -0.2%
deep-vector-check
	avg: -1.5%	min: -2.1%	max: 0.0%
coercions-check
	avg: -1.0%	min: -2.0%	max: 0.0%
tuple-stress-opt
	avg: -1.5%	min: -1.9%	max: -0.4%
coercions
	avg: -0.9%	min: -1.5%	max: -0.4%
syn-check
	avg: -0.7%	min: -1.5%	max: -0.1%
deep-vector
	avg: -1.0%	min: -1.5%	max: -0.0%
serde-opt
	avg: -0.6%	min: -1.3%	max: -0.0%
deep-vector-opt
	avg: -0.7%	min: -1.2%	max: -0.0%
coercions-opt
	avg: -0.8%	min: -1.2%	max: -0.2%
regex-check
	avg: -0.4%	min: -1.2%	max: -0.1%
piston-image-check
	avg: -0.8%	min: -1.2%	max: -0.1%
hyper-check
	avg: -0.6%	min: -1.2%	max: -0.1%
encoding-check
	avg: -0.6%	min: -1.2%	max: -0.1%
serde-check
	avg: -0.7%	min: -1.2%	max: -0.1%
html5ever-check
	avg: -0.7%	min: -1.1%	max: -0.2%
style-servo-check
	avg: -0.7%	min: -1.1%	max: -0.1%
encoding
	avg: -0.5%	min: -1.0%	max: -0.1%
serde
	avg: -0.5%	min: -1.0%	max: -0.3%

@@ -124,7 +124,7 @@ pub fn maybe_print_constraints_for<'a, 'gcx, 'tcx>(
struct ConstraintGraph<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
graph_name: String,
region_rels: &'a RegionRelations<'a, 'gcx, 'tcx>,
map: &'a BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>,
map: &'a LazyBTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this even be an FxHashMap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ConstraintGraph::map is changed to an FxHashMap, then all the other LazyBTreeMap instances in this patch have to change to an FxHashMap as well. Maybe that's what you're suggesting? The various BTreeMaps are iterated over in multiple places. I don't know if the iteration order is important, but I'm inclined to be conservative.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Constraint just seems to have a derived Ord implementation, so the order might not be important. I don't know this code though.

@Gankra
Copy link
Contributor

Gankra commented May 9, 2018

We should possibly close this on the basis that the proper BTreeMap fix is ready and just needs to be profiled?

@nnethercote
Copy link
Contributor Author

Fixed in a better way by #50352.

@nnethercote nnethercote deleted the LazyBTree-more branch May 13, 2018 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants