Optimize OverlapIterator #53
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my project, I noticed that writing to flash was pretty slow, so I tried to trace it out, and I pin-pointed the culprit to the
OverlapIterator
.This PR optimizes the
OverlapIterator
so that in my test case, writing a 400 kB file to flash went down from 204 s to 14 s !So basically, I went from unusable to good enough with just this change.
Note that to optimize the
OverlapIterator
, it needs to know the start and end of theRegion
, so I needed to add those the theRegion
trait. So this is a breaking change and will require a version bump.I'm not sure how do you prefer to handle this version bump ? Would you like me to include it in this PR ? (I propose to bump embedded-storage to 0.4.0)
For the record, my test case is running on a STM32F407 with an external SPI flash (W25Q32) handled by the
w25q32jv
crate (implementingembedded-storage
) and formatted as FAT32 usingembedded-fatfs
. The whole thing is running withembassy
and I'm downloading the file thru HTTP on the ethernet port usingreqwless
.