Skip to content

Make Bus much more memory efficient#58

Merged
mitchmindtree merged 2 commits intoRustAudio:masterfrom
mitchmindtree:bus
Jul 17, 2017
Merged

Make Bus much more memory efficient#58
mitchmindtree merged 2 commits intoRustAudio:masterfrom
mitchmindtree:bus

Conversation

@mitchmindtree
Copy link
Member

Previously a Bus would require a unique VecDeque for keeping pending
frames for each Output. It also did not provide a way of removing
outputs, meaning busses with a growing number of outputs would
infinitely grow in memory usage.

This new implementation only requires a single VecDeque for pending
frames, regardless of the number of outputs. Instead, we just store a
HashMap from the output's unique key to its current index into the
pending frames buffer.

Outputs now also implement Drop and will remove themselves from the
HashMap. It will also drain the front of the buffer and
update the buffer indices for each of the outputs if the removed output
was the "latest" to receive frames.

Previously a `Bus` would require a unique `VecDeque` for keeping pending
frames for each `Output`. It also did not provide a way of removing
outputs, meaning busses with a growing number of outputs would
infinitely grow in memory usage.

This new implementation only requires a single VecDeque for pending
frames, regardless of the number of outputs. Instead, we just store a
HashMap from the output's unique key to its current index into the
pending frames buffer.

Outputs now also implement Drop and will remove themselves from the
HashMap. It will also drain the front of the front of the buffer and
update the buffer indices for each of the outputs if the removed output
was the "latest" to receive frames.
@mitchmindtree
Copy link
Member Author

Ahh seems like HashMap isn't provided from the collections crate. I wonder if there is a minimal HashMap crate that just builds on core and alloc?

@mitchmindtree
Copy link
Member Author

collections does provide a BTreeMap which would probably be fine to use for this case in the meantime.

@mitchmindtree mitchmindtree merged commit bfa7902 into RustAudio:master Jul 17, 2017
mitchmindtree added a commit to mitchmindtree/dasp that referenced this pull request Sep 7, 2017
This publish includes:

- Signal Map and ZipMap RustAudio#68
- impl Signal for Box<Signal> RustAudio#67
- Change Signal::next return type from Option<Frame> to Frame RustAudio#57
- Make `Bus` more memory efficient RustAudio#58
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