Skip to content

Commit 343eeef

Browse files
committed
document afetisov's data
1 parent d466533 commit 343eeef

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

text/0000-dyn-upcasting.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ This RFC does not specify the validity invariant, instead delegating that decisi
168168

169169
Although the precise layout of vtables is not stabilized in this RFC (and is never expected to be), adopting this feature does imply that vtables must *somehow* support upcasting. For "single-inheritance" scenarios, where traits have a single supertrait, this is not an issue, but for "multiple inheritance" scenarios, where traits have multiple supertraits, it may imply that vtables become larger. Under the current vtable design, we generate one additional vtable for each supertraits after the first. This leads to larger binaries, which can be an issue for some applications (particularly embedded).
170170

171-
(Note that the we are already generating the larger vtables as of Rust 1.56, in anticipation of adopting this RFC.)
171+
Note that the we are already generating the larger vtables as of Rust 1.56, in anticipation of adopting this RFC. We do not have data about real-world impact, but some synthetic benchmarks have been generated. [afetisov writes:](https://github.com/rust-lang/rfcs/pull/3324#issuecomment-1308124173)
172+
173+
> I don't have any data from real-world projects, but I have made a test crate, which uses proc macro to generate a graph of traits and impls with width W and depth D, as in my example above. At least when generating rlibs, I did not see any exponential blowup of artifact size, which I predicted above. The rlib size seemed to grow roughly linearly in W and D.
174+
175+
This is suggestive that increased binary size will not be an issue in practice.
172176

173177
## Multi-trait dyn is more complex
174178

0 commit comments

Comments
 (0)