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

chore: optimize Request.read #1410

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kevmoo
Copy link

@kevmoo kevmoo commented Jun 22, 2024

Status

READY

Description

Use Expando instead of cloning each request.

  • Should improve performance. Should be measured.
  • Allows nested _request to be final. (Potentially allows future use of extension type

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@kevmoo kevmoo requested a review from a team as a code owner June 22, 2024 00:58
@kevmoo
Copy link
Author

kevmoo commented Jun 22, 2024

@felangel – enable CI workflows?

@felangel
Copy link
Contributor

@felangel – enable CI workflows?

I’m not part of the organization anymore so I don’t have permissions unfortunately. @wolfenrain @alestiago can help 👍

@@ -158,3 +154,5 @@ class Request {
return Request._(_request.change(headers: headers, path: path, body: body));
}
}

final _bodyFutureExpando = Expando<Future<String>>('dart_frog.request.body');
Copy link
Member

Choose a reason for hiding this comment

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

Not that familiar with Expandos, would love to see a description on the PR to explain how this improves performance

Copy link
Author

Choose a reason for hiding this comment

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

You all would have to measure it.

On the VM, they're pretty cheap. And now you're avoiding copying everything all the time which should be a lot cheaper

@tomarra
Copy link
Contributor

tomarra commented Jun 25, 2024

Hi @kevmoo 👋 Thanks for opening this PR. Would you be able to fill in the description of the PR with more details on what the goal of this change is and how it accomplishes that? I added our normal PR template back into the description so all you should need to do is fill out the description section with those details for us to do a proper review.

kevmoo and others added 2 commits June 25, 2024 12:44
Co-authored-by: Jochum van der Ploeg <[email protected]>
Co-authored-by: Jochum van der Ploeg <[email protected]>
@kevmoo
Copy link
Author

kevmoo commented Jun 25, 2024

@tomarra – done!

@kevmoo
Copy link
Author

kevmoo commented Jun 29, 2024

Do ya'll have benchmarks we could look at?

@tomarra
Copy link
Contributor

tomarra commented Jul 1, 2024

Do ya'll have benchmarks we could look at?

We do not. There are some benchmarks that are out there which you may be able to run locally, https://github.com/sharkbench/sharkbench comes to mind given their website https://sharkbench.dev/web/dart-dartfrog, to help validate this.

@alestiago alestiago requested a review from wolfenrain August 13, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Community
Development

Successfully merging this pull request may close these issues.

4 participants