Open-source project
spacejam/sled avatar
spacejam/sled

sled: optimistic transactions, big-endian keys, and a 500 ms fsync window

the champagne of beta embedded databases

9,127 stars430 forksRustApache-2.0

At a glance

What is it?
A read of the Rust embedded database sled as its README, manifest and gotchas actually describe it: a durable-on-a-timer write path, optimistic transaction closures, one open instance per process, and an alpha manifest sitting years past the last tag.
Who is it for?
sled fits a single-process Rust service that can live with a 500 ms durability window and big-endian keys: the API is small, transactions are optimistic, and no second process shares the file with you. It fits badly if you need per-commit fsync semantics, cross-process access, or a stable release, since the three most recent tags are all 0.34.x while the manifest reads 1.0.0-alpha.124.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Activity is slowing. The repository last received commits 7 months ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 23, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • spacejam/sled9,127 ★ · +34
Star history
Repository2026-09-222026-11-23
spacejam/sled9.1k9.1k

34 Stars in the last 62 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The README says it no longer matches the main branch

The repository is candid about its own state. A red note near the top of the README says it is out of sync with the main branch, which contains a large in-progress rewrite. The version numbers reinforce the point: Cargo.toml declares 1.0.0-alpha.124 on edition 2024, while the three most recent tags are v0.34.7 from 2021-09-12, v0.34.6 from 2020-11-13 and v0.34.5 from 2020-11-09. Nothing after 0.34.7 has been tagged, so the crate described in the prose and the crate in the tree are not obviously the same generation of API.

The last push to the repository is dated 2026-04-04 and it is not archived, so the rewrite is still moving, but the documentation you read most easily is the documentation the project itself flags as out of date.

Two smaller mismatches are worth knowing before you plan around the examples. The README links examples/structured.rs for structured access, while the tracked example files are examples/bench.rs and examples/bench_large.rs. The manifest also sets exclude = ["benchmarks", "examples", "bindings", "scripts", "experiments"], so example and benchmark code never ships inside the published crate. Licensing is the one unambiguous part: MIT OR Apache-2.0, with both LICENSE-MIT and LICENSE-APACHE tracked.

Durability runs on a background fsync every 500 ms

Opening a database is one call, and what comes back behaves like a threadsafe `BTreeMap<[u8], [u8]>`:

rust
let tree = sled::open("/tmp/welcome-to-sled")?;

// insert and get, similar to std's BTreeMap
let old_value = tree.insert("key", "value")?;

assert_eq!(
  tree.get(&"key")?,
  Some(sled::IVec::from("value")),
);

// range queries
for kv_result in tree.range("key_1".."key_9") {}

// deletion
let old_value = tree.remove(&"key")?;

// atomic compare and swap
tree.compare_and_swap(
  "key",
  Some("current_value"),
  Some("new_value"),
)?;

// block until all operations are stable on disk
// (flush_async also available to get a Future)
tree.flush()?;

The last line is the one that matters if you have a durability requirement. sled fsyncs automatically every 500 ms by default, and that interval is configurable through `flush_every_ms`. A process that dies between syncs loses whatever it wrote since the last one, which is a fair trade for a cache and the wrong trade for anything you would call a record. For that case the API offers `flush` to block until operations are stable on disk and `flush_async` when you want a Future instead. The automatic syncing runs several times per second in the background without blocking user threads, so the default is a bounded loss window in exchange for fewer fsyncs than your workload would otherwise force.

Transaction closures have to be idempotent because commits are optimistic

Transactions are serializable and ACID, and they span multiple keys across multiple keyspaces. The qualifier that changes how you write them is that they are optimistic. The README warns against interacting with external state or performing IO inside a transaction closure unless that work is idempotent.

That is a constraint on your code, not a style preference. A closure that publishes to a queue, calls a service or bumps a counter outside the database can run a second time when a commit has to be retried, and sled cannot roll back the side effect the first run already caused. Idempotency is what makes the retry safe, so anything non-idempotent belongs after the transaction returns, not inside it.

Single-key operations are a separate guarantee and are fully atomic, which is what `compare_and_swap` in the example above relies on: you hand it the value you expect and the value you want, and the swap only lands if the stored value still matches your expectation. For several keys at once the documented tool is `apply_batch`, and for reacting to change rather than making it, `watch_prefix` subscribes to events on key prefixes. Merge operators are available for accumulating values instead of replacing them.

One open instance per process, kept open for the whole process

sled does not support multiple open instances for the time being, and the guidance is to keep one instance open for the duration of your process's lifespan. A global lazy_static instance is called totally safe and often convenient, modulo the normal global variable trade-offs, on the grounds that every operation is threadsafe and most are implemented with lock-free algorithms that avoid blocking in hot paths.

The consequence shows up in process layout rather than in the type system. Two processes, or a CLI and a daemon, cannot both open the same path, because that arrangement sits outside what the library supports. A test suite feels this first: a fixture that opens a fresh database per test against one shared path fights the process-wide instance, and unique directories per test are the usual answer instead of another `sled::open` on the same path.

The other thing you inherit without asking is the `IVec` type, an inlinable Arc'ed slice that is the first oddity most callers notice when a method returns it instead of a Vec.

Integer keys must be big-endian or range scans quietly lie

sled's ordering is lexicographic over serialized bytes, so the byte layout of a numeric key decides the order of every ordered operation. The README gives this its own section because the failure is quiet: little endian, the default of many things, appears to work right up until you have more than 256 items, and beyond that point the lexicographic ordering of the serialized bytes diverges from the ordering of the numbers you meant. One byte of key sorts the same in either layout, two bytes already do not.

Once the keyspace crosses that line, every ordered operation inherits the error. Range queries, forward and reverse iteration and prefix subscriptions all hand back results in an order you did not ask for, and nothing raises an error while it happens. A test that asserts a single `get` still passes; a test that walks a range discovers that entries are missing or reordered. Debugging that from the outside is painful because the storage layer is behaving exactly as specified.

The fix lives in your key encoding, not in a sled option. Rust integral types have `to_be_bytes` and `from_be_bytes` built in, and bincode can be configured to write integral types in big-endian form. Related shape advice in the same section: nodes skip length and offset pointers when keys or values are all the same length, tracked separately for keys and values, so fixed-length keys can reduce space usage and make structured access easier.

Release builds keep overflow checks and abort on panic

The release profile in Cargo.toml is unusual enough to read twice:

toml
[profile.release]
debug = true
opt-level = 3
overflow-checks = true
panic = "abort"

[profile.test]
debug = true
overflow-checks = true
panic = "abort"

When this manifest is the workspace root, its release profile requests optimization, debug information, overflow checks and aborting on panic, subject to Cargo configuration overrides. Cargo ignores profile settings in dependencies, so an application that depends on sled uses the profile selected by its own workspace. Cargo also ignores the panic setting for tests, benchmarks, build scripts and procedural macros; the test-profile entry does not establish abort behavior for ordinary tests.

The dependency list points the same way. `ebr` handles epoch-based reclamation, `rayon` and `zstd` are regular dependencies, and `fault-injection` appears alongside a tracked fuzz/ directory, tsan_suppressions.txt and a SAFETY.md, which is tooling aimed at failure paths rather than a claim that they are all covered.

Async only works without a runtime while the dataset fits in cache

sled is synchronous, and the answer to async in the README is conditional. If your dataset resides entirely in cache, achievable at startup by setting the cache to a large enough value and performing a full iteration, then all reads and writes are non-blocking and async-friendly without needing Futures or an async runtime at all.

That condition is the whole promise. A working set larger than the cache means sled does blocking work, so calling it directly from an async task ties up a runtime thread, and moving those calls onto a blocking pool becomes your problem rather than the library's.

Two async-friendly pieces do exist. `flush_async` returns a Future that tasks can await when they need high durability guarantees and are willing to pay the latency cost of fsync. The `Subscriber` struct implements `Future<Output=Option<Event>>`, which is what makes async subscription to events on key prefixes possible. Both help with durability and with notification; neither makes a cache miss non-blocking, so an edge service with a dataset larger than its cache still needs a thread boundary around every call.

The headline numbers assume a small dataset on 16 cores

The performance claims are specific enough to use and narrow enough to be careful with. The headline is over a billion operations in under a minute at 95 percent reads and 5 percent writes on 16 cores on a small dataset, framed as LSM tree-like write performance with traditional B+ tree-like read performance. The crash-safe monotonic ID generator is documented as capable of generating 75-125 million unique IDs per second. The same section then tells you to measure your own workloads rather than relying on marketing for contrived workloads, which is the right instruction given the shape of that headline number.

Two knobs decide what you actually get. The README says compression is behind the `compression` build feature and disabled by default, but the current Cargo.toml defines no `compression` feature and lists zstd as a regular dependency. The `monotonic-behavior` feature is documented in the manifest as turning off re-use of object IDs and heap slots, disabling tree leaf merges and disabling heap file truncation.

Storage savings are also key-shape dependent. Prefix encoding and suffix truncation mean keys that share long prefixes cost less, and when keys are the same length and sequential the system can avoid storing more than 99 percent of the key data in most cases. Random keys gain little of that, so the space argument has to be argued per workload rather than per crate.

Editorial conclusion

sled fits a single-process Rust service that can live with a 500 ms durability window and big-endian keys: the API is small, transactions are optimistic, and no second process shares the file with you. It fits badly if you need per-commit fsync semantics, cross-process access, or a stable release, since the three most recent tags are all 0.34.x while the manifest reads 1.0.0-alpha.124. Before adopting it, read CHANGELOG.md for the rewrite, check your own workspace’s release profile for panic and overflow behavior, and settle your key encoding before any range scan reaches production.

Frequently asked questions

What does the acronym SLED stand for in the spacejam sled crate?

The manifest does not expand an acronym. The Cargo.toml description is Lightweight high-performance pure-rust transactional embedded database, and the repository description is the champagne of beta embedded databases, which is the only naming hint offered.

What does sled mean in tech sales?

That question is about sales language and has no answer in this repository, which contains no discussion of sales terminology. The manifest keywords are redis, mongo, sqlite, lmdb and rocksdb, all of them storage engines rather than anything to do with selling.

What is SLED technology and what are its key features?

sled is an embedded database written in Rust whose API is similar to a threadsafe BTreeMap<[u8], [u8]>. Listed features include serializable ACID transactions, fully atomic single-key operations including compare and swap, zero-copy reads, write batches, subscriptions on key prefixes, multiple keyspaces, merge operators, forward and reverse iterators, a crash-safe monotonic ID generator, and zstd compression behind the disabled-by-default compression build feature.

What does sled mean as a crate?

The name belongs to the crate itself: Cargo.toml names the package sled at version 1.0.0-alpha.124, edition 2024, with documentation pointing at docs.rs/sled. The README calls it an embedded database, and the repository tagline is the champagne of beta embedded databases.

Official sources

  1. Issues
  2. License: Apache-2.0
  3. README
  4. Releases
  5. spacejam/sled on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/spacejam-sled.svg)](https://hysenlabs.com/projects/spacejam-sled)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/spacejam-sled.svg)](https://hysenlabs.com/projects/spacejam-sled)

Was this useful?