Optimizing simplefs_ext_search Function with Binary Search #43
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.
👋 Hello everyone,
I’ve been working on a function in the code that I believed could be optimized. The original simplefs_ext_search function was using a linear search, which can be quite slow for large values of SIMPLEFS_MAX_EXTENTS.
In my commit, I’ve implemented a binary search in place of the linear search. This has reduced the time complexity from O(n) to O(log n), making the function much faster for large values of SIMPLEFS_MAX_EXTENTS.
Additionally, I’ve added a preliminary sorting of extents based on ee_block to ensure the binary search works correctly. This sorting has a time cost, but should be acceptable if index->extents doesn’t change frequently.
I hope these changes are helpful and improve the performance of our project. I’m open to feedback and suggestions on how we might further improve this code. 😊
Thank you for considering my pull request!
I hope this helps! 😊