-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 Symbol
more
#60630
Use Symbol
more
#60630
Conversation
@bors try |
⌛ Trying commit b28d0aeaa86dd5079501c37d439b60771c34b2e8 with merge 1a89a3215ec97a7b0b2a010b773e7b8be90f6f4e... |
bors seems to have gotten stuck @bors try |
💥 Test timed out |
@oli-obk I think you have to use |
@bors retry |
⌛ Trying commit b28d0aeaa86dd5079501c37d439b60771c34b2e8 with merge ce805fd53ba59be4d9bd0f0987f1e5b764831307... |
☔ The latest upstream changes (presumably #60246) made this pull request unmergeable. Please resolve the merge conflicts. |
☀️ Try build successful - checks-travis |
@rust-timer build ce805fd53ba59be4d9bd0f0987f1e5b764831307 |
Success: Queued ce805fd53ba59be4d9bd0f0987f1e5b764831307 with parent b92d360, comparison URL. |
Finished benchmarking try commit ce805fd53ba59be4d9bd0f0987f1e5b764831307 |
I think github is being bugged by time travellers today |
One 1.4% perf improvement, many small ones (<1%) |
(I haven't done a full review but this does sound like something I've been wanting for a long time) |
The |
b28d0ae
to
6df17b0
Compare
src/libsyntax_pos/symbol.rs
Outdated
} | ||
|
||
// Non-identifer symbols that can be referred to with syntax_pos::nisymbols::*. | ||
NISymbols { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Non-identness" doesnt' really matter, entries in the Symbols { ... }
block should probably just allow an optional : "non-ident"
literal (with everything generated in one mod symbols
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't realize that was possible. Good suggestion, I will implement it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like us to have 2 namespaces here, so if you use symbols::a
you know you're getting a
and not some other identifier. It also ensure there won't be any name conflicts if you add a: "b"
and you want to add a
later.
We could probably rename symbols
to idents
in that case.
So, my primary concern is that we are front-loading interning of about 500 strings and do it in every compilation session even if most of them won't be actually used. Could you measure how much time the UI test suite (a lot of little programs) takes with and without these changes? |
Use `Symbol` more A `Symbol` can be equated with a string (e.g. `&str`). This involves a TLS lookup to get the chars (and a Mutex lock in a parallel compiler) and then a char-by-char comparison. This functionality is convenient but avoids one of the main benefits of `Symbol`s, which is fast equality comparisons. This PR removes the `Symbol`/string equality operations, forcing a lot of existing string occurrences to become `Symbol`s. Fortunately, these are almost all static strings (many are attribute names) and we can add static `Symbol`s as necessary, and very little extra interning occurs. The benefits are (a) a slight speedup (possibly greater in a parallel compiler), and (b) the code is a lot more principled about `Symbol` use. The main downside is verbosity, particularly with more `use syntax::symbol::symbols` items. r? @Zoxc
☀️ Test successful - checks-travis, status-appveyor |
Simplify use of keyword symbols They mirror non-keyword symbols now (see #60630). `keywords::MyKeyword.name()` -> `kw::MyKeyword` `keywords::MyKeyword.ident()` -> `Ident::with_empty_ctxt(kw::MyKeyword)` (not common) `keywords::Invalid.ident()` -> `Ident::invalid()` (more common) Keywords are simply `Symbol` constants now, the `Keyword` struct is eliminated. This means `kw::MyKeyword` can now be used in `match` in particular.
`Symbol` received the same treatment in rust-lang#60630. Also, we can derive `PartialEq` for `InternedString`.
… r=<try> Remove impls for `InternedString`/string equality. `Symbol` received the same treatment in #60630. Also, we can derive `PartialEq` for `InternedString`. r? @petrochenkov
…alEq-impls, r=petrochenkov Remove impls for `InternedString`/string equality. `Symbol` received the same treatment in rust-lang#60630. Also, we can derive `PartialEq` for `InternedString`. r? @petrochenkov
…alEq-impls, r=petrochenkov Remove impls for `InternedString`/string equality. `Symbol` received the same treatment in rust-lang#60630. Also, we can derive `PartialEq` for `InternedString`. r? @petrochenkov
Simplify use of keyword symbols They mirror non-keyword symbols now (see #60630). `keywords::MyKeyword.name()` -> `kw::MyKeyword` `keywords::MyKeyword.ident()` -> `Ident::with_empty_ctxt(kw::MyKeyword)` (not common) `keywords::Invalid.ident()` -> `Ident::invalid()` (more common) Keywords are simply `Symbol` constants now, the `Keyword` struct is eliminated. This means `kw::MyKeyword` can now be used in `match` in particular.
A
Symbol
can be equated with a string (e.g.&str
). This involves aTLS lookup to get the chars (and a Mutex lock in a parallel compiler)
and then a char-by-char comparison. This functionality is convenient but
avoids one of the main benefits of
Symbol
s, which is fast equalitycomparisons.
This PR removes the
Symbol
/string equality operations, forcing a lotof existing string occurrences to become
Symbol
s. Fortunately, theseare almost all static strings (many are attribute names) and we can add
static
Symbol
s as necessary, and very little extra interning occurs.The benefits are (a) a slight speedup (possibly greater in a parallel
compiler), and (b) the code is a lot more principled about
Symbol
use.The main downside is verbosity, particularly with more
use syntax::symbol::symbols
items.r? @Zoxc