chore: optimize Request.read
Status
READY
Description
Use Expando instead of cloning each request.
- Should improve performance. Should be measured.
- Allows nested
_requestto be final. (Potentially allows future use ofextension 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)
- [x] π§Ή Code refactor
- [ ] β Build configuration change
- [ ] π Documentation
- [ ] ποΈ Chore
@felangel β enable CI workflows?
@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.
@tomarra βΒ done!
Do ya'll have benchmarks we could look at?
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:
Generally speaking,
Expandoobjects are a sign of an architectural problem. Carefully consider whether your usage is actually necessary. When your classes have clear documented ownership rules, there is usually a better solution.Expando objects tend to invite code that is hard to understand because one cannot simply follow references to find all the dependencies.
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!
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.
100,000,000
Just took a quick look and the memory impact is much more significant in the test case I ran.
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 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 π