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

registerCallback returning Any considered harmful #404

Open
thirtytwobits opened this issue Nov 23, 2024 · 3 comments
Open

registerCallback returning Any considered harmful #404

thirtytwobits opened this issue Nov 23, 2024 · 3 comments

Comments

@thirtytwobits
Copy link
Contributor

thirtytwobits commented Nov 23, 2024

In the current design all of the places where we have Any registerCallback(Function&&) inhibit the ability of users to author custom executors and to integrate with various platforms. The primary issue is the method is required to move a node into an opaque container that is then moved into an unknown caller. There is no canonical key available for the implementation of registerCallback to retain. This prohibits filtering callbacks within execution stages based on type and writing event-driven rescheduling of callbacks by platform layers.

We need to modify this design to use a allocation pool instead of Any types so there is only ever a single memory location containing a given callback within a process.

@pavel-kirienko
Copy link
Member

pavel-kirienko commented Nov 25, 2024

The primary issue is the method is required to move a node into an opaque container that is then moved into an unknown caller.

This design was chosen to eliminate the need for pmr allocation in the executor et al.

There is no canonical key available for the implementation of registerCallback to retain. This prohibits filtering callbacks within execution stages based on type and writing event-driven rescheduling of callbacks by platform layers.

I think this could be addressed without compromising on memory management by replacing Any with an ImplementationCell, where the implementation cell offers an interface that enables the client to query relevant properties of the callback. Should we see how such an interface could be designed?

@pavel-kirienko
Copy link
Member

pavel-kirienko commented Nov 25, 2024

I should add that the minimization of dynamic memory allocation (incl. pmr and pools) was one of the core design goals, hence why this design was chosen:

image

Here, "heap" includes all kinds of dynamic memory, including pmr and pools.

@thirtytwobits
Copy link
Contributor Author

If you look at #402 you'll see my attempts to attach custom properties to these nodes are thwarted by unknown and mysterious forces lurking in the depths of CAVL.

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

No branches or pull requests

2 participants