Skip to content

Fix just a few stacked borrow issues, and improve extend performance - #111

Merged
bluss merged 3 commits into
masterfrom
miri-complaints
Nov 25, 2018
Merged

Fix just a few stacked borrow issues, and improve extend performance#111
bluss merged 3 commits into
masterfrom
miri-complaints

Conversation

@bluss

Copy link
Copy Markdown
Owner

Extend: This simplification -- borrowing self.len instead of self, leads to
an improvement in the extend_from_slice benchmark.

It's also guided by the discussion of stacked borrows; the old code
would be invalid, because the whole self is borrowed while ptr is derived from
self.

In truncate, don't access self while holding raw pointer derived from self

Again, stacked borrows model makes the self.set_len() call illegal
because we are holding (and are going to use) another raw pointer
derived from self, tail.

bench comparison for extend. Caveat might be that optimization can also be influenced by how the code can be optimized in the benchmark.

 name 63 ns/iter 62 ns/iter diff ns/iter diff % extend_with_constant 290 (1765 MB/s) 296 (1729 MB/s) 6 2.07% extend_with_range 288 (1777 MB/s) 287 (1783 MB/s) -1 -0.35% extend_with_slice 828 (618 MB/s) 218 (2348 MB/s) -610 -73.67%

This simplification -- borrowing self.len instead of self, leads to
an improvement in the extend_from_slice benchmark.
It's also guided by the discussion of stacked borrows; the old code
would be invalid, because the whole self is borrowed while ptr is derived from
self.
The benchmark was optimized out totally. We think of that as a good
sign, the new extend became transparent to the compiler and we had to
get smarter in how to fool it.
… from self
Again, stacked borrows model makes the `self.set_len()` call illegal
because we are holding (and are going to use) another raw pointer
derived from self, `tail`.
@bluss

Copy link
Copy Markdown
OwnerAuthor

There is bound to be more issues to fix than this. cc #97

@bluss
bluss merged commit d84cb37 into masterNov 25, 2018
@bluss
bluss deleted the miri-complaints branch November 25, 2018 16:17
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@bluss