{"id":16936426,"url":"https://github.com/jonhoo/ordsearch","last_synced_at":"2025-10-28T05:32:07.477Z","repository":{"id":57650324,"uuid":"107903880","full_name":"jonhoo/ordsearch","owner":"jonhoo","description":"A Rust data structure for efficient lower-bound lookups","archived":false,"fork":false,"pushed_at":"2024-02-26T19:13:30.000Z","size":149,"stargazers_count":90,"open_issues_count":3,"forks_count":8,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-31T15:20:42.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonhoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-22T21:22:42.000Z","updated_at":"2025-03-09T11:52:21.000Z","dependencies_parsed_at":"2023-11-11T10:21:52.794Z","dependency_job_id":"b8a2dd94-3cdf-4844-a467-2b18f2865b03","html_url":"https://github.com/jonhoo/ordsearch","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.0357142857142857,"last_synced_commit":"140ef3cc2c137c7d825ca9a7644fcb41204916cb"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fordsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fordsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fordsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Fordsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonhoo","download_url":"https://codeload.github.com/jonhoo/ordsearch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247704571,"owners_count":20982298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T20:56:54.938Z","updated_at":"2025-10-28T05:32:07.429Z","avatar_url":"https://github.com/jonhoo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ordsearch\n\n[![Crates.io](https://img.shields.io/crates/v/ordsearch.svg)](https://crates.io/crates/ordsearch)\n[![Documentation](https://docs.rs/ordsearch/badge.svg)](https://docs.rs/ordsearch/)\n[![Build Status](https://travis-ci.org/jonhoo/ordsearch.svg?branch=master)](https://travis-ci.org/jonhoo/ordsearch)\n\nThis crate provides a data structure for approximate lookups in ordered collections.\n\nMore concretely, given a set `A` of `n` values, and a query value `x`, this library provides an\nefficient mechanism for finding the smallest value in `A` that is greater than or equal to `x`.\nIn particular, this library caters to the important case where there are many such queries to\nthe same array, `A`.\n\nThis library is constructed from the best solution identified in [Array Layouts for\nComparison-Based Searching](https://arxiv.org/abs/1509.05053) by Paul-Virak Khuong and Pat\nMorin. For more information, see the paper, [their\nwebsite](http://cglab.ca/~morin/misc/arraylayout-v2/), and the [C++ implementation\nrepository](https://github.com/patmorin/arraylayout).\n\n## Current implementation\n\nAt the time of writing, this implementation uses a branch-free search over an\nEytzinger-arranged array with masked prefetching based on the [C++\nimplementation](https://github.com/patmorin/arraylayout/blob/3f20174a2a0ab52c6f37f2ea87d087307f19b5ee/src/eytzinger_array.h#L253)\nwritten by the authors of the aforementioned paper. This is the recommended algorithm from the\npaper, and what the authors suggested in\nhttps://github.com/patmorin/arraylayout/issues/3#issuecomment-338472755.\n\nNote that prefetching is *only* enabled with the (non-default) `nightly` feature due to\nhttps://github.com/aweinstock314/prefetch/issues/1. Suggestions for workarounds welcome.\n\n## Performance\n\nThe included benchmarks can be run with\n\n```console,ignore\n$ cargo +nightly bench --features nightly\n```\n\nThis will benchmark both construction and search with different number of values, and\ndifferently sized values -- look for the line that aligns closest with your data. The general\ntrend is that `ordsearch` is faster when `n` is smaller and `T` is larger as long as you\ncompile with\n[`target-cpu=native`](https://github.com/jonhoo/ordsearch/issues/2#issuecomment-390441137) and\n[`lto=thin`](https://github.com/jonhoo/ordsearch/issues/2#issuecomment-390446671). The\nperformance gain seems to be best on Intel processors, and is smaller since the (relatively)\nrecent improvement to [SliceExt::binary_search\nperformance](https://github.com/rust-lang/rust/pull/45333).\n\nBelow are summarized results from an Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz CPU run with:\n\n```console\n$ rustc +nightly --version\nrustc 1.75.0-nightly (e0d7ed1f4 2023-10-01)\n$ env CARGO_INCREMENTAL=0 RUSTFLAGS='-C target-cpu=native' cargo +nightly bench --features nightly\n```\n\n![](./plots/plot.svg)\n\n## Future work\n\n - [ ] Implement aligned operation: https://github.com/patmorin/arraylayout/blob/3f20174a2a0ab52c6f37f2ea87d087307f19b5ee/src/eytzinger_array.h#L204\n - [ ] Implement deep prefetching for large `T`: https://github.com/patmorin/arraylayout/blob/3f20174a2a0ab52c6f37f2ea87d087307f19b5ee/src/eytzinger_array.h#L128\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Fordsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonhoo%2Fordsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Fordsearch/lists"}