Skip to content

Commit

Permalink
smaller refcounts RFC
Browse files Browse the repository at this point in the history
  • Loading branch information
Clark Gaebel committed Mar 29, 2014
1 parent 6d24223 commit a1d6e9e
Showing 1 changed file with 38 additions and 0 deletions.
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.

0 comments on commit a1d6e9e

Please sign in to comment.