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

Naive search internals (core only) #2885

Merged
merged 18 commits into from
Dec 4, 2024
Merged

Naive search internals (core only) #2885

merged 18 commits into from
Dec 4, 2024

Conversation

mitchellh
Copy link
Contributor

@mitchellh mitchellh commented Dec 4, 2024

Towards #189

This PR implements a simple, single-threaded, single-direction Booyer-Moore-Horspool search on top of PageList.

The code in this PR is not utilized in builds yet. It is only part of unit tests. I want to open a PR incrementally so we don't have one mega PR for search. I want to be very clear that this does not finish #189, there's many more steps before that.

High-level technical overview: we maintain a circular buffer of UTF-8 encoded terminal page contents that is just large enough to fit the larger of a single page or the search term. As we search, the circular buffer is pruned and additional terminal pages are added to search. This minimizes our memory usage to the minimum necessary for this approach. In practice, the overhead is very small for realistic search terms!

Some limitations that need to be resolved in future work:

  • Single-direction: We only search oldest-to-newest. We'll want to search newest-to-oldest by default. It shouldn't be hard to implement directionality but I wanted to wait until I needed it.
  • Single-threaded: Search only works as long as the PageList is not being actively modified. That's not going to work for a real final user-facing solution.

@mitchellh
Copy link
Contributor Author

Going to merge this. This isn't in use at all yet so there's no potential harm here in a merge. I'll still be notified and read any feedback if anyone has any. Then I'll plan follow ups to keep working on this...

@mitchellh mitchellh merged commit 711f947 into main Dec 4, 2024
34 checks passed
@mitchellh mitchellh deleted the search branch December 4, 2024 21:48
@mitchellh mitchellh mentioned this pull request Dec 4, 2024
4 tasks
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.

1 participant