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

Custom allocators #24

Open
james7132 opened this issue Jun 13, 2022 · 3 comments
Open

Custom allocators #24

james7132 opened this issue Jun 13, 2022 · 3 comments

Comments

@james7132
Copy link

I've been working on a specialized fork of async_executor focused on prioritized execution high performance CPU bound tasks for bevy. Thus far I've made a number of optimizations that definitely have helped out with overhead, but spawning tasks remains one of the primary bottlenecks, which is coming from spawn_unchecked.

One of the primary use cases is a lifetime limited scoped batch of tasks that we know the inner tasks cannot outlive. As we know that futures and tasks cannot outlive the scope, one of the more appealing options is to use bumpalo or some thread safe wrapper around it to speed up allocation.

It'd be super helpful to be able to provide a version of the API that allows specifying your own allocator or a callback for allocating memory for use in non-nightly environments.

@notgull
Copy link
Member

notgull commented Jun 14, 2022

Has there been any high-level work to integrate custom allocators into other crates in the Rust ecosystem? I support this idea in theory, but I think some finesse will be needed in practice to ensure it works with past, present and future Rust versions.

@james7132
Copy link
Author

Has there been any high-level work to integrate custom allocators into other crates in the Rust ecosystem? I support this idea in theory, but I think some finesse will be needed in practice to ensure it works with past, present and future Rust versions.

Generally, outside of the std lib and a bunch of low level crates, no. The standard allocators API is not stablized yet. I wouldn't mind a TaskSpawner type that just wraps an allocator impl, and should be flexible enough that it'd be easy to migrate once a more standardized option becomes available.

@notgull
Copy link
Member

notgull commented Jun 15, 2022

I'm afraid that, if we decide to commit to an API design, and the ecosystem as a whole moves onto a different API (or if the allocator API becomes stable), we'll be forced to either stay with the old API and alienate new users, or make a breaking change and alienate old ones. Although I'm a fan of this idea, I'd hold off on it until the ecosystem makes a move in one direction of the other.

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

No branches or pull requests

2 participants