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

Seperate GC into multiple implementations #21

Closed
wants to merge 5 commits into from

Conversation

Techcable
Copy link
Member

@Techcable Techcable commented Jan 19, 2021

After refactoring out common code, I want to separate the different modes of zerogc-simple into their own crates.

Right now, we have two combinations of modes:

  1. Threading: Either thread-safe or thread-unsafe
  2. Count: Singleton or multiple collectors

Feature flags control these modes.

We've already finished separating the (very complex) context code into its own zerogc-context crate, so we've already made great progress! (See commit 44b3463)

I am planning to re-use much of this code when I implement generational GC (#14).

TODO

  • Seperate into zerogc-context
  • Special allocator crate
    • Basic interface
    • Delegating malloc implementation (using std::alloc)
    • Port the small-object-arenas code to the new API
      • TODO: Cleanup interface
    • Support controlling specific segments, chunks, and objects
    • Support compacting/copying collectors??
  • Finally split zerogc-simple into multiple implementations
    • Thread safe, global singleton implementation
    • Thread-unsafe, multiple collectors
      • This is essentially a garbage collected arena
      • Should the zerogc-arena collector be separate from zerogc-simple???
    • Thread-safe, multiple collectors (
    • I'm pretty sure I'm going to drop singleton/thread-unsafe

Open Questions

  1. Should we separate tracing code into a zerogc-mark or have it somewhat duplicated among implementations
    • I think zerogc-simple could maybe have its own implementation to avoid overhead
  2. Should we make the thread-unsafe version more lightweight and drop a bunch of dependencies?
  3. How are we going to fend off the growing usage of nightly features?
  4. Should we implement a basic copying/compacting collector
    • Maybe just jump straight to a generational GC?
  5. Should the (future) generational GC be flexible enough to replace the simple collector?
    • The 'simple' implementation would be zero nursery generations with no copying
  6. Which implementations should block the acceptance of this PR and remove the old zerogc-simple implementation?

To be clear, all of this will come before the release. zerogc v0.2.0 is gonna be big!

TODO: Get more comprehensive tests.

GC now has a seperate and customizable allocator interface.
This should allow the tracing and compacting code tight implementation
with the internals, while still maintaining some flexibility and code reuse.

This is the first step towards seperating `zerogc-simple` into
multiple different implementations. I am planning to re-use much
of this code when I implement generational gc (#14)
@Techcable Techcable added this to the 0.2.0 milestone Jan 19, 2021
@Techcable Techcable self-assigned this Jan 19, 2021
It's important to get the latest updates ;)
NOTE: This doesn't compile (beceause the original changes also dont)
Whether or not the small-object allocator is thread safe is
controlled by the 'AllocThreading' trait.

This is horrible, because it exposes all the internals
and breaks encapsulation......

I also really don't want this level of code duplication
across the entire crate (which its starting to look like
will happen if we continue down this path)
Very simple and lightweight... :)
The simple collector is broken right now

Should we abstract behind a trait?
It's a waste of space. If you want to call std::alloc/malloc
just call it directly.....
@Techcable
Copy link
Member Author

I do want to refactor this in the future, but I no longer believe it's feasible to share allocation codee between collector implementation (different thread-safety configurations are of course a different story).

Collection and allocation are too closely coupled for meaningful abstraction. This is as it should be.

@Techcable Techcable closed this Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant