-
Notifications
You must be signed in to change notification settings - Fork 166
perf: optimize Request.read
#1410
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
Conversation
@felangel – enable CI workflows? |
I’m not part of the organization anymore so I don’t have permissions unfortunately. @wolfenrain @alestiago can help 👍 |
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. |
Co-authored-by: Jochum van der Ploeg <[email protected]>
Co-authored-by: Jochum van der Ploeg <[email protected]>
@tomarra – done! |
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. |
I found this piece of documentation from the Flutter Style:
This said, this usage could be an exception. Flutter itself still uses Expando in some occurrences. |
I think it depends on usage. I wouldn't land this PR unless there were performance tests run first! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
I ran some benchmarks locally and the Expando
refactor does have a measurable performance impact.
For example, with a request body size of 1,071,472 bytes, and 100,000,000 calls to request.body
, using Expando
performed approximately 3% better (~500ms faster in the test I ran).
@kevmoo I expected to see a more significant performance improvement but since there is still a measurable performance gain and we're able to make the internal request
final again, I think it's worth merging.
It was a bit of an experiment on my side to see if this pattern would work. It'd LOVE to know MEMORY impact, too. Might be interesting to look at. |
Just took a quick look and the memory impact is much more significant in the test case I ran.
Just took a quick peak and memory impact seems to be more significant. I'll post some more detailed benchmarks/snapshots in a bit but thanks again for the contribution and glad we were finally able to land it 🎉 |
Status
READY
Description
Use
Expando
instead of cloning each request._request
to be final. (Potentially allows future use ofextension type
Type of Change