Skip to content

Smaller Refcounts #23

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

Merged
merged 1 commit into from
Apr 29, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions active/0000-smaller-refcounts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
- Start Date: 2014-03-28
- RFC PR #:
- Rust Issue #:

# Summary

I propose removing support for weak pointers from `Rc<T>`, and adding it to a
separate type `WRc<T>`.

# Motivation

`Rc<T>` currently uses two words for reference counting, to support an
infrequently used feature - weak pointers. A search of the rust and servo
codebases show zero uses of weak pointers, and the vast majority of reference
counted code does not create cycles. However, outside of the spirit of not
paying for what you don't use, every single `Rc<T>` keeps an extra word,
the weak count, than it needs to.

Hopefully this will help decrease the memory usage of rustc after all of the
managed boxes get turned into `Rc<T>`s.

# Detailed design

I just want to rename `Rc<T>` to `WRc<T>`, and create a similar datastructure
with its old name `Rc<T>` which just does not have a weak count. It will
support all of the same operations except for downgrading.

A similar transformation will also be done on `ARc<T>`, with a renaming to
`AWRc<T>`.

# Alternatives

Of course, we could do nothing. That's fine, but using all this memory for no
good reason is kind of unfortunate.

# Unresolved questions

Bikeshedding over the naming.