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

Optimizing simplefs_ext_search Function with Binary Search #43

Closed
wants to merge 2 commits into from

Conversation

apfeet
Copy link

@apfeet apfeet commented Apr 23, 2024

👋 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! 😊

extent.c Outdated Show resolved Hide resolved
jserv

This comment was marked as resolved.

@apfeet apfeet requested a review from jserv April 23, 2024 16:40
Copy link
Collaborator

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Use git rebase -i to squash the commits and read the article How to Write a Git Commit Message to refine the commit message.

@jserv
Copy link
Collaborator

jserv commented Apr 24, 2024

Close in favor of #42

@jserv jserv closed this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants