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

Reduce size_of Node for better cache performance in render loop #208

Open
1 of 5 tasks
orottier opened this issue Aug 13, 2022 · 2 comments
Open
1 of 5 tasks

Reduce size_of Node for better cache performance in render loop #208

orottier opened this issue Aug 13, 2022 · 2 comments

Comments

@orottier
Copy link
Owner

orottier commented Aug 13, 2022

std::mem::size_of::<Node>() == 160 currently. I think we gain some nice performance (better cache utilization) if we trim it down a bit.

Some suggestions:

  • Use u8 instead of usize for input/output indices
  • Use u32 for NodeIndex instead of u64
  • Store outgoing_edges on the heap
  • Pack ChannelConfig as a single Arc<(count, mode, interp)> ChannelConfig is now a single Arc instead of 3 #307
  • Use bitflags to combine the boolean fields in a single u8

On a different note, we can explore to store the Nodes as an "struct of arrays" instead of "array (hashmap in our case) of structs" https://news.ycombinator.com/item?id=17981306

@b-ma
Copy link
Collaborator

b-ma commented Aug 14, 2022

On a different note, we can explore to store the Nodes as an "struct of arrays" instead of "array (hashmap in our case) of structs" https://news.ycombinator.com/item?id=17981306

Very nice direction to dig I think, kind of related to this comment there #55 (comment) (in a more interesting way :)

@orottier
Copy link
Owner Author

orottier commented Oct 27, 2023

For the record, in the current implementation:

        assert_eq!(160, std::mem::size_of::<RefCell<Node>>());

        assert_eq!(8, std::mem::size_of::<RefCell<()>>());

        assert_eq!(8, std::mem::size_of::<Option<llq::Node<AudioNodeId>>>());
        assert_eq!(16, std::mem::size_of::<Box<dyn AudioProcessor>>());
        assert_eq!(24, std::mem::size_of::<Vec<AudioRenderQuantum>>()); // times 2
        assert_eq!(8, std::mem::size_of::<ChannelConfig>());
        assert_eq!(64, std::mem::size_of::<SmallVec<[OutgoingEdge; 2]>>());
        assert_eq!(1, std::mem::size_of::<bool>()); // times 3

This is expected to grow because we need to use more SmallVecs in #368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants