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 the size of the future returned by async get_with and friend methods (v0.10) #220

Merged
merged 5 commits into from
Feb 6, 2023

Conversation

tatsuya6502
Copy link
Member

@tatsuya6502 tatsuya6502 commented Feb 4, 2023

This PR will mitigate #212 for upcoming Moka v0.10.0 release.

Changes

This PR does the same thing to PR #222, but on the master branch instead of the maint-09 branch.

future::Cache:

  1. To mitigate current rustc's optimization issue, switched the internally using type for the init future from impl Future to a reference Pin<&mut impl Future>.
  2. Eliminated an internal async function ValueInitializer:init_or_read(..., init, ...) from the call path.

Updated Methods:

future::Cache:

  • get_with(...)
  • get_with_if(...)
  • optionally_get_with(...)
  • try_get_with(...)
  • get_with_by_ref(...)
  • optionally_get_with_by_ref(...)
  • try_get_with_by_ref(...)
  • entry(...).or_insert_with(...)
  • entry(...).or_insert_with_if(...)
  • entry(...).or_optionally_insert_with(...)
  • entry(...).or_try_insert_with(...)
  • entry_by_ref(...).or_insert_with(...)
  • entry_by_ref(...).or_insert_with_if(...)
  • entry_by_ref(...).or_optionally_insert_with(...)
  • entry_by_ref(...).or_try_insert_with(...)

@tatsuya6502 tatsuya6502 added this to the v0.10.0 milestone Feb 4, 2023
@tatsuya6502 tatsuya6502 added the enhancement New feature or request label Feb 4, 2023
@tatsuya6502 tatsuya6502 self-assigned this Feb 4, 2023
Correct a wrong `TypeId` for `optionally_get_with`.
@Swatinem
Copy link
Contributor

Swatinem commented Feb 4, 2023

Hm, The usage of macros is very interesting, I haven’t thought of that one. Though admittedly it is a bit sad that futures have such an overhead that one workaround is to replace them with something as unergonomic as macros. :-D

Change the type of the `init` future argument for internal `async fn`s
from `Future<...>` to `Pin<&mut Future<...>>`.
@tatsuya6502 tatsuya6502 changed the title Reduce the size of the future returned by async get_with and friend methods Reduce the size of the future returned by async get_with and friend methods (v0.10) Feb 5, 2023
Change the macros back to private functions.
src/future/cache.rs Outdated Show resolved Hide resolved
@tatsuya6502 tatsuya6502 marked this pull request as ready for review February 6, 2023 06:57
Copy link
Member Author

@tatsuya6502 tatsuya6502 left a comment

Choose a reason for hiding this comment

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

I will merge this into the master branch once all CI jobs are completed. I will do a squash merge.

@tatsuya6502 tatsuya6502 merged commit 63e04c0 into master Feb 6, 2023
@tatsuya6502 tatsuya6502 deleted the reduce-fut-overhead-v0.10 branch February 6, 2023 07:34
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.

None yet

2 participants