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
base: master
from

Conversation

Projects
None yet
5 participants
@nnethercote
Contributor

nnethercote commented May 7, 2018

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%.

Use LazyBTreeMap for region constraints.
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

This comment has been minimized.

Collaborator

rust-highfive commented May 7, 2018

r? @estebank

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

@nnethercote

This comment has been minimized.

Contributor

nnethercote commented May 7, 2018

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>>,

This comment has been minimized.

@michaelwoerister

michaelwoerister May 8, 2018

Contributor

Could this even be an FxHashMap?

This comment has been minimized.

@nnethercote

nnethercote May 9, 2018

Contributor

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.

This comment has been minimized.

@michaelwoerister

michaelwoerister May 9, 2018

Contributor

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

@Gankro

This comment has been minimized.

Contributor

Gankro 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

This comment has been minimized.

Contributor

nnethercote commented May 13, 2018

Fixed in a better way by #50352.

@nnethercote nnethercote deleted the nnethercote:LazyBTree-more branch May 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment