Skip to content

refactor: use FutureExt if possible#923

Merged
Berrysoft merged 1 commit into
compio-rs:masterfrom
Berrysoft:refactor/future-ext
May 17, 2026
Merged

refactor: use FutureExt if possible#923
Berrysoft merged 1 commit into
compio-rs:masterfrom
Berrysoft:refactor/future-ext

Conversation

@Berrysoft
Copy link
Copy Markdown
Member

A small optimization to reduce memory usage.

@Berrysoft Berrysoft self-assigned this May 17, 2026
@github-actions github-actions Bot added the enhancement New feature or request label May 17, 2026
@Berrysoft Berrysoft requested a review from Copilot May 17, 2026 13:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors a couple of async call sites to use futures_util::FutureExt combinators (map) instead of creating new async state machines, aligning with the goal of slightly reducing per-future memory overhead in hot paths.

Changes:

  • Refactor Runtime::spawn_blocking to map the Submit future output directly rather than wrapping it in an async move block.
  • Refactor BufReader::fill_buf’s Buffer::with(...) callback to return a mapped future instead of an async move closure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
compio-runtime/src/lib.rs Uses FutureExt::map to avoid an extra async wrapper in spawn_blocking.
compio-io/src/read/buf.rs Uses FutureExt::map to avoid an extra async closure when refilling the buffer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@AsakuraMizu AsakuraMizu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, but just a minor nitpicking: why are the two files importing FutureExt at different locations?

@Berrysoft
Copy link
Copy Markdown
Member Author

I prefer importing at the top, but there's another FutureExt in compio-runtime. rustc complains about that.

@Berrysoft Berrysoft merged commit ad15f53 into compio-rs:master May 17, 2026
83 checks passed
@Berrysoft Berrysoft deleted the refactor/future-ext branch May 17, 2026 16:12
@github-actions github-actions Bot mentioned this pull request May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants