Skip to content

Commit a468e4b

Browse files
committed
Merge remote-tracking branch 'cgaebel/master'
2 parents 7a70960 + a1d6e9e commit a468e4b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

active/0000-smaller-refcounts.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
- Start Date: 2014-03-28
2+
- RFC PR #:
3+
- Rust Issue #:
4+
5+
# Summary
6+
7+
I propose removing support for weak pointers from `Rc<T>`, and adding it to a
8+
separate type `WRc<T>`.
9+
10+
# Motivation
11+
12+
`Rc<T>` currently uses two words for reference counting, to support an
13+
infrequently used feature - weak pointers. A search of the rust and servo
14+
codebases show zero uses of weak pointers, and the vast majority of reference
15+
counted code does not create cycles. However, outside of the spirit of not
16+
paying for what you don't use, every single `Rc<T>` keeps an extra word,
17+
the weak count, than it needs to.
18+
19+
Hopefully this will help decrease the memory usage of rustc after all of the
20+
managed boxes get turned into `Rc<T>`s.
21+
22+
# Detailed design
23+
24+
I just want to rename `Rc<T>` to `WRc<T>`, and create a similar datastructure
25+
with its old name `Rc<T>` which just does not have a weak count. It will
26+
support all of the same operations except for downgrading.
27+
28+
A similar transformation will also be done on `ARc<T>`, with a renaming to
29+
`AWRc<T>`.
30+
31+
# Alternatives
32+
33+
Of course, we could do nothing. That's fine, but using all this memory for no
34+
good reason is kind of unfortunate.
35+
36+
# Unresolved questions
37+
38+
Bikeshedding over the naming.

0 commit comments

Comments
 (0)