Use Rc<str> and Rc<[T]> instead of Rc<String> and Rc<Vec<T>>#49645
Use Rc<str> and Rc<[T]> instead of Rc<String> and Rc<Vec<T>>#49645birkenfeld wants to merge 3 commits intorust-lang:masterfrom
Conversation
|
@bors try I'd like to check the perf. cc @Mark-Simulacrum |
Use Rc<str> and Rc<[T]> instead of Rc<String> and Rc<Vec<T>> to save a bit of memory and pointer chasing. For the `Vec<T>` case, there is one instance each of `get_mut` and `make_mut` that preclude the use of the slice type: * the `get_mut` one does `push`, so I left it as is * the `make_mut` one does a `reverse`, which would be fine but `Lrc<[T]>` does not impl `Clone` (should it?) - however, the reverse seems to be unnecessary - please if the solution makes sense Had some unrelated-looking local test failures, let's see if if CI gets them too.
|
Your PR failed on Travis. Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
@TimNN Questionable fragment ;) Fixing the test now... |
src/libstd/collections/hash/map.rs
Outdated
There was a problem hiding this comment.
I think we shouldn't promote use of Rc<String>, rather show that Rc<str> is now feasible and preferable.
|
Your PR failed on Travis. Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
The try build is successful. Again, the reply is missing, probably because new commits are pushed in between. Anyway, please schedule |
|
Your PR failed on Travis. Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
Try build queued for perf. |
nikomatsakis
left a comment
There was a problem hiding this comment.
so r=me for the compiler stuff, but I don't feel qualified to r+ the changes to the libstd docs
|
r? @steveklabnik for the changes to hashmap example etc |
|
Ignoring the spurious |
|
☔ The latest upstream changes (presumably #49696) made this pull request unmergeable. Please resolve the merge conflicts. |
There is one instace where Lrc::get_mut().unwrap() is used on the reference to make a push, this cannot be converted. One instance of Lrc::make_mut() was removed -- the side effect of changing the original vector cannot have mattered since make_mut() might have cloned it.
|
Updated. |
|
☔ The latest upstream changes (presumably #49672) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Hmm. I'm torn on this change. I wouldn't expect a real performance win -- as we saw on perf, this is basically in the noise, which is what I would expect. (Note also that even when judged from a "micro-efficiency" perspective, this is not an obvious win: My bigger concern though is that constructing a Note all that we don't really get much increased flexibility here. e.g.,, given a So in summary:
cc @rust-lang/compiler -- thoughts? |
|
👍 for elegance |
Yeah - you need |
|
Actually I would have expected a performance loss because constructing a |
|
I've been wanting to get rid of the |
|
Ping from triage! What's the status of this PR? |
1 similar comment
|
Ping from triage! What's the status of this PR? |
|
Looks like the change is not unanimous, and a significant part is likely to be refactored away, so I'll close it. |
to save a bit of memory and pointer chasing.
For the
Vec<T>case, there is one instance each ofget_mutandmake_mutthat preclude the use of the slice type:get_mutone doespush, so I left it as ismake_mutone does areverse, which would be fine butLrc<[T]>does not implClone(should it?) - however, the reverse seems to be unnecessary - please check if the solution makes senseHad some unrelated-looking local test failures, let's see if if CI gets them too.