Skip to content

Refactor and improve: Arena, TypedArena - #27807

Merged
bors merged 10 commits into
rust-lang:masterfrom
pczarn:arena-internals
Jan 11, 2016
Merged

Refactor and improve: Arena, TypedArena#27807
bors merged 10 commits into
rust-lang:masterfrom
pczarn:arena-internals

Conversation

@pczarn

Copy link
Copy Markdown
Contributor

Fixes#18037 "TypedArena cannot handle zero-sized types".
Closes#17931 "improve chunk allocation scheme used by Arena / TypedArena".
Closes#22847 "TypedArena should implement Send". - N.B. Arena cannot implement Send, since it may contain non-Send values.
Closes#18471 "Arena::alloc_copy_inner (at least) should be renamed and made public." - Added Arena::alloc_bytes.
Closes#18261 "support clearing TypedArena with the chunks preserved". - Only the largest chunk is preserved.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @huonw

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

@huonw

Copy link
Copy Markdown
Contributor

cc @gankro particularly for the RawVec changes.

Comment threadsrc/libarena/lib.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 think this possibly needs to be RawVec<UnsafeCell<u8>> since there's effectively a transmute from &Chunk -> &mut [u8] in the various allocation methods; however I'm not totally sure it's needed because the Arena ensures non-aliased-ness of everything it hands out.

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.

I think UnsafeCell can be left out as long as we only use non-aliased or raw pointers. UnsafeCell's docs say:

In general, transmuting an &T type into an &mut T is considered undefined behavior.

@huonw

Copy link
Copy Markdown
Contributor

I idly wonder if this will slow the typedarena down noticably: it is adding an extra allocation (the Vec of chunks) and more indirection to get to the elements of the last chunk (have to index the vector and then dereference, instead of just a straight dereference).

That said I imagine it's not noticable.

@pczarn
pczarnforce-pushed the arena-internals branch 5 times, most recently from ef5f6e9 to 8a08f17CompareAugust 14, 2015 17:49
@bors

bors commented Sep 8, 2015

Copy link
Copy Markdown
Collaborator

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

Comment threadsrc/liballoc/raw_vec.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.

explicit return not needed

@Gankra

Copy link
Copy Markdown
Contributor

\o/ for RawVec helping out even more!

All the RawVec-internal stuff seems good, but I don't have the bandwidth to review the Arena stuff, sadly :(

@pczarn

Copy link
Copy Markdown
ContributorAuthor

Thanks. Changes are pushed.

@bors

bors commented Sep 11, 2015

Copy link
Copy Markdown
Collaborator

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

@bors

bors commented Sep 25, 2015

Copy link
Copy Markdown
Collaborator

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

@bors

bors commented Oct 14, 2015

Copy link
Copy Markdown
Collaborator

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

@pczarn

Copy link
Copy Markdown
ContributorAuthor

Updated

@Gankra

Copy link
Copy Markdown
Contributor
rustc: x86_64-unknown-linux-gnu/stage2/test/arenatest-x86_64-unknown-linux-gnu
src/libarena/lib.rs:610:29: 610:59 error: box expression syntax is experimental; you can call `Box::new` instead. (see issue #27779)
src/libarena/lib.rs:610 let _: Box<_> = box Point { x: 1, y: 2, z: 3 };
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/libarena/lib.rs:610:29: 610:59 help: add #![feature(box_syntax)] ```to the crate attributes to enable
error: aborting due to previous error

@pczarn

Copy link
Copy Markdown
ContributorAuthor

Corrected

@bors

bors commented Nov 25, 2015

Copy link
Copy Markdown
Collaborator

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

@shepmaster

Copy link
Copy Markdown
Member

@pczarn great, I appreciate that! Although I'm totally cool with it having well-tested unsafe code ;-) I could always do some head-to-head perf testing between the two implementations to see if it's useful.

@pczarn

Copy link
Copy Markdown
ContributorAuthor

@bluss: It's deprecated. :shipit: 🎉

@aturon

Copy link
Copy Markdown
Contributor

Nominating for libs team discussion re: deprecation.

@aturonaturon added I-nominated T-libs-api [DEPRECATED; DO NOT USE] and removed I-nominated labels Jan 6, 2016
@aturon

Copy link
Copy Markdown
Contributor

Libs team consensus: the deprecation here isn't really relevant, as the crate is already gated by rustc_private.

@bluss

bluss commented Jan 8, 2016

Copy link
Copy Markdown
Contributor

Thank you @aturon. Let's go again!

@bors r+

@bors

bors commented Jan 8, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit e2ccc4f has been approved by bluss

@bors

bors commented Jan 8, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e2ccc4f with merge 927d22d...

@bors

bors commented Jan 8, 2016

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-linux-64-nopt-t

@bluss

Copy link
Copy Markdown
Contributor

@bors retry

@bors

bors commented Jan 11, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e2ccc4f with merge d3e5b72...

@bors

bors commented Jan 11, 2016

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-mac-64-opt

@alexcrichton

Copy link
Copy Markdown
Member

@bors: retry

On Mon, Jan 11, 2016 at 3:07 PM, bors notifications@github.com wrote:

[image: 💔] Test failed - auto-mac-64-opt
http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/7619


Reply to this email directly or view it on GitHub
#27807 (comment).

@bors

bors commented Jan 11, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e2ccc4f with merge 02dc12b...

@bors

bors commented Jan 11, 2016

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-linux-64-nopt-t

@alexcrichton

Copy link
Copy Markdown
Member

@bors: retry

On Mon, Jan 11, 2016 at 7:41 PM, bors notifications@github.com wrote:

[image: 💔] Test failed - auto-linux-64-nopt-t
http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/7595


Reply to this email directly or view it on GitHub
#27807 (comment).

@bors

bors commented Jan 11, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e2ccc4f with merge dfaddb7...

bors added a commit that referenced this pull request Jan 11, 2016
Fixes#18037 "TypedArena cannot handle zero-sized types".
Closes#17931 "improve chunk allocation scheme used by Arena / TypedArena".
Closes#22847 "TypedArena should implement Send". - N.B. Arena cannot implement Send, since it may contain non-Send values.
Closes#18471 "`Arena::alloc_copy_inner` (at least) should be renamed and made public." - Added `Arena::alloc_bytes`.
Closes#18261 "support clearing TypedArena with the chunks preserved". - Only the largest chunk is preserved.
@bors
bors merged commit e2ccc4f into rust-lang:masterJan 11, 2016
Comment threadsrc/libarena/lib.rs

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.

This comment should be removed, right?

@Gankra

Copy link
Copy Markdown
Contributor

🎊

Thanks so much for persevering on this, @pczarn!

Comment threadsrc/libarena/lib.rs
#[unstable(feature = "rustc_private",
reason = "Private to rustc", issue = "0")]
#[rustc_deprecated(since = "1.6.0-dev", reason =
"The reflection-based arena is superseded by the any-arena crate")]

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.

Where is this crate?

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.

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

Labels

T-libs-api[DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

12 participants

@pczarn@rust-highfive@huonw@bors@Gankra@bluss@arielb1@shepmaster@aturon@alexcrichton@SimonSapin@jethrogb