Skip to content

Commit 0523a96

Browse files
committed
improve README, add benchmark results
1 parent 4a79493 commit 0523a96

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
[package]
22
name = "poptrie"
3+
version = "0.1.0"
34
description = "A pure-rust implementation of poptrie"
5+
authors = ["Nicolas Kagami <nicolaskagami@gmail.com>"]
46
homepage = "https://github.com/nicolaskagami/poptrie"
5-
version = "0.1.0"
7+
repository = "https://github.com/nicolaskagami/poptrie"
68
license = "Apache-2.0 OR MIT"
79
edition = "2024"
810
readme = "README.md"
11+
keywords = ["poptrie", "ip", "prefix", "trie"]
12+
categories = ["network-programming", "data-structures", "no-std"]
913

1014
[dependencies]
1115

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Poptrie
22
====
3-
A pure Rust implementation of [Poptrie](https://dl.acm.org/doi/10.1145/2740070.2626377), a data structure for efficient longest-prefix matching (LPM) lookups.
3+
A pure Rust implementation of [Poptrie](https://dl.acm.org/doi/abs/10.1145/2829988.2787474), a data structure for efficient longest-prefix matching (LPM) lookups.
44

55
Poptrie uses bitmaps combined with popcount to achieve fast IP routing table lookups with high cache locality. During lookup, the key is consumed in the biggest step that can be represented in a bitmap for which the native popcount instruction exists (i.e. 6-bit steps in a 64-bit bitmap).
66

@@ -48,17 +48,30 @@ assert_eq!(trie.lookup(u32::from_be_bytes([192, 168, 1, 5])), Some(&"192.168.0.0
4848

4949
| Function | Description |
5050
|---|---|
51-
| `Poptrie::new()` | Construct a new, empty poptrie |
51+
| `new()` | Construct a new, empty poptrie |
5252
| `insert(key, key_length, value)` | Insert a value associated with the given prefix |
5353
| `lookup(key)` | Longest-prefix match lookup, returns `Option<&V>` |
5454
| `contains_key(key, key_length)` | Returns `true` if the exact prefix is present |
5555
| `remove(key, key_length)` | Remove a prefix and return its value |### License
5656

57-
### Reference
57+
### Lookup performance
58+
59+
Benchmarked with random lookups on tables of 1k, 10k and 100k random prefixes. All contenders were built with `RUSTFLAGS="-C target-cpu=native"`, which enables the use of architecture-specific instructions, if available. This is critical for performance as the poptrie relies on native `POPCNT` and bit manipulation instructions (e.g. `BEXTR` on x86) to achieve its performance characteristics.
60+
61+
| Implementation | 1k prefixes | 10k prefixes | 100k prefixes |
62+
|---|---|---|---|
63+
| **nicolaskagami/poptrie** (this crate) | 462.9 Mlookups/s | 326.6 Mlookups/s | 171.1 Mlookups/s |
64+
| [tiborschneider/prefix-trie](https://github.com/tiborschneider/prefix-trie) | 296.9 Mlookups/s | 292.9 Mlookups/s | 110.5 Mlookups/s |
65+
| [oxidecomputer/poptrie](https://github.com/oxidecomputer/poptrie) | 270.1 Mlookups/s | 197.7 Mlookups/s | 86.9 Mlookups/s |
66+
67+
> Benchmarked on an AMD Ryzen 9 7900 (12-core, x86_64), Linux kernel 6.18, rustc 1.93.1.
5868
59-
Hirochika Asai and Yasuhiro Ohara. 2015. **[Poptrie: A Compressed Trie with Population Count for Fast and Scalable Software IP Routing Table Lookup](https://doi.org/10.1145/2740070.2626377)**. In *Proceedings of the 2015 ACM Conference on Special Interest Group on Data Communication* (SIGCOMM '15). ACM, New York, NY, USA, 57–70.
6069

6170

71+
### Reference
72+
73+
Asai, Hirochika, and Yasuhiro Ohara. "**[Poptrie: A Compressed Trie with Population Count for Fast and Scalable Software IP Routing Table Lookup](https://doi.org/10.1145/2829988.2787474)** ACM SIGCOMM Computer Communication Review 45.4 (2015): 57-70.
74+
6275
### License
6376

6477
This project is licensed under either of:

0 commit comments

Comments
 (0)