Skip to content

cache symbol names in ty::maps - #41507

Merged
bors merged 3 commits into
rust-lang:masterfrom
arielb1:symbol-cache
Apr 27, 2017
Merged

cache symbol names in ty::maps#41507
bors merged 3 commits into
rust-lang:masterfrom
arielb1:symbol-cache

Conversation

@arielb1

@arielb1arielb1 commented Apr 24, 2017

Copy link
Copy Markdown
Contributor

this fixes a performance regression introduced in commit 39a58c3.

r? @nikomatsakis

Comment threadsrc/librustc/ty/maps.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you mean by "don't rely on interning or equality here"? Maybe you mean for equality? The main thing to be careful of (which &'tcx str would solve) is that we hash the string contents (if you use Symbol, things go awry).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Actually, that comment was needed because a previous try used Symbol there, which as you said is dangerous. I'll remove it.

Comment threadsrc/librustc_trans/context.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just remove 'a? I think I added it in my PR expressly for this field. But whatever, seems fine.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Missed that. Didn't want to cause unnecessary diffs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we just replace this entire function with a call to symbol_name (and change return type to InternedString, of course)? It seems like we should remove the secondary caching performed by SymbolMap, and instead have that also use the queries, no?

@nikomatsakisnikomatsakis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, but I'm curious what you think about removing the SymbolMap too.

Comment threadsrc/librustc_trans/partitioning.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm confused by this. Aren't there sometimes multiple items with the same node-id that nonetheless deserve a consistent ordering (e.g., different instantiations of the same instance?)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yup. Let me fix that.

@nikomatsakisnikomatsakis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious about the sorting thing, otherwise seems good.

Comment threadsrc/librustc_trans/partitioning.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 to making this a method, the fn was awkward.

Comment threadsrc/librustc_trans/context.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Total nit, but I'd expect tcx to be the first argument. Having this be a method seems even better (didn't you do this elsewhere? Or is that just for TransItem?) But I don't care much.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It was this way originally. Let me move it all the way to a method on Instance.

@arielb1
arielb1force-pushed the symbol-cache branch 3 times, most recently from a8c9623 to 1199e3eCompareApril 24, 2017 17:50
Comment threadsrc/librustc_trans/partitioning.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 simpler this way anyhow

@arielb1

Copy link
Copy Markdown
ContributorAuthor

@bors r=nikomatsakis

@bors

bors commented Apr 24, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit af63f14 has been approved by nikomatsakis

@arielb1

Copy link
Copy Markdown
ContributorAuthor

Fixed finish micro-opt

@bors r=nikomatsakis

@bors

bors commented Apr 24, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 07d1233 has been approved by nikomatsakis

@frewsxcvfrewsxcv mentioned this pull request Apr 24, 2017
@arielb1arielb1 added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 25, 2017
@bors

bors commented Apr 26, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #41504) made this pull request unmergeable. Please resolve the merge conflicts.

@arielb1

Copy link
Copy Markdown
ContributorAuthor

@bors r=nikomatsakis

@bors

bors commented Apr 26, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 07b16cb has been approved by nikomatsakis

@frewsxcvfrewsxcv mentioned this pull request Apr 27, 2017
@bors

bors commented Apr 27, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 07b16cb with merge aed35b2...

@bors

bors commented Apr 27, 2017

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-appveyor

@aidanhs

Copy link
Copy Markdown
Contributor

@bors retry

Appveyor network issues https://appveyor.statuspage.io/incidents/06gzq846jl9x

@bors

bors commented Apr 27, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 07b16cb with merge 4961d72...

bors added a commit that referenced this pull request Apr 27, 2017
cache symbol names in ty::maps
this fixes a performance regression introduced in commit 39a58c3.
r? @nikomatsakis
@bors

bors commented Apr 27, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 4961d72 to master...

@bors
bors merged commit 07b16cb into rust-lang:masterApr 27, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@arielb1@bors@aidanhs@nikomatsakis