Skip to content
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

allow opting out of garbage collection overhead #11425

Closed
thestinger opened this issue Jan 9, 2014 · 5 comments
Closed

allow opting out of garbage collection overhead #11425

thestinger opened this issue Jan 9, 2014 · 5 comments
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.

Comments

@thestinger
Copy link
Contributor

Rust currently imposes overhead on all compiled code to accommodate managed pointers and will need to continue doing so to some extent for a real garbage collector. Trait objects and closures are opaque, and may contain garbage collected boxes. Support for correctly rooting references may involve overhead even for unique pointers without managed data inside.

  • closures currently have a 4-word header which is unnecessary
  • procs currently have a 4-word header including a TyDesc, which should just be a destructor pointer
  • &Trait has a TyDesc, which is unnecessary
  • ~Trait has a TyDesc, which should just be a destructor pointer
  • free glue is unnecessary, and should just be drop glue
  • take glue is unnecessary
  • any future support for tracing (shadow stack, references inside unique pointers, etc.) should be entirely disabled
@pnkfelix
Copy link
Member

pnkfelix commented Jan 9, 2014

cc me

@nikomatsakis
Copy link
Contributor

To clarify: &Trait and ~Trait include the tydesc in the vtable, no?

@huonw
Copy link
Member

huonw commented Jan 25, 2014

I believe it's the first field of the vtable.

cc #11723 for the removal of the take glue.

@eddyb
Copy link
Member

eddyb commented Jan 25, 2014

I suggest replacing the vtable pointer for &Trait/&mut Trait with a function pointer where there is only one method callable through the trait object - that way &Fn/&mut FnMut trait objects will be compatible with the current closure representation (well, not for backwards compatibility's sake, but to avoid a pointless indirect access).

@thestinger
Copy link
Contributor Author

#12059 finishes off the TyDescs as @pnkfelix and @pcwalton did not consider them necessary for garbage collection (can use side tables)

I'll just keep a careful eye on future changes and open a bug if and when there's any new overhead there should be an opt-out from. There's not much point having a bug for a presumed future issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-slow Issue: Problems and improvements with respect to performance of generated code.
Projects
None yet
Development

No branches or pull requests

5 participants