Skip to content

Introduce kvdb-lmdb#121

Closed
ordian wants to merge 51 commits into
masterfrom
ao-lmdb
Closed

Introduce kvdb-lmdb#121
ordian wants to merge 51 commits into
masterfrom
ao-lmdb

Conversation

@ordian
Copy link
Copy Markdown
Contributor

@ordian ordian commented Apr 4, 2019

On top of #120 (last commit only)

ordian added 30 commits January 21, 2019 18:40
* master: (284 commits)
  fix(serde deser): remove needless `len` check
  Update ci to crate removal.
  fix(deser): fix indexing into `str` bug
  Clean deprecated crate.
  Remove deps to hashdb, memdb, patricia-trie, keccak-hash.
  add uint operator benchmarks (#82)
  Update repo url
  Add issue number
  Fix ethereum-types tests
  readme: remove broken appveyor badge
  Update parity-crypto to ring v0.14 (#99)
  update impl-codec and update primitive-types (#101)
  primitive types new release
  Use TryFrom trait
  Use local path deps
  Deal with remaining merge issues
  update parity-codec for primitive types (#98)
  Update uint to 0.6
  Add more conversion functions for U128
  typo: duplicate features key
  ...
ordian added 6 commits March 27, 2019 16:55
* master:
  Fix impl-rlp for uint in primitive-types (#117)
* master:
  change dependencies of `keccak-hash`and `trie-standardmap` (#111)
  bring appveyor back (#118)
  Extract `should_replace` from Scoring and supply pooled txs from same sender (#116)
Comment thread kvdb-lmdb/src/lib.rs

fn iter(&self, col: usize) -> Self::Iterator {
// TODO: how to handle errors properly?
let ro_txn = self.ro_txn().expect("lmdb: transaction creation failed");
Copy link
Copy Markdown
Contributor Author

@ordian ordian Apr 5, 2019

Choose a reason for hiding this comment

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

Read-only transaction creation can fail if too many thread are trying to create a read-only transaction or we're out of memory (cf. http://www.lmdb.tech/doc/group__mdb.html#gad7ea55da06b77513609efebd44b26920)

Comment thread kvdb-lmdb/src/lib.rs
Comment thread kvdb/src/lib.rs
Comment thread kvdb/src/lib.rs Outdated
Comment thread kvdb/src/lib.rs
/// Get value by partial key. Prefix size should match configured prefix size. Only searches flushed values.
pub fn get_by_prefix(&self, col: Option<u32>, prefix: &[u8]) -> Option<Box<[u8]>> {
match self.iter_from_prefix(col, prefix).next() {
Some((k, v)) => if k.starts_with(prefix) { Some(v) } else { None },
Copy link
Copy Markdown
Contributor

@dvdplm dvdplm Apr 5, 2019

Choose a reason for hiding this comment

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

Why is this starts_with check necessary? Can LMDB return values that do not match the prefix?

Can't we do just:

		match self.iter_from_prefix(col, prefix).next() {
			Some((_, v)) => Some(v),
			_ => None
		}

or even self.iter_from_prefix(col, prefix).next().map(|(_,v)| v)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is actually coming from rocksdb implementation (

Some((k, v)) => if k[0 .. prefix.len()] == prefix[..] { Some(v) } else { None },
).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting. I guess the same question applies! Doesn't rocksdb support prefix matching?

If it's a rocksdb quirk, maybe we can add a TODO to clean it up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For posterity, this seems to be fixed in upstream rocksdb, from which we have diverged quite a bit I believe. Oddly enough the parity-rocksdb fork names prefix search as one of the reasons for forking, and yet I can't find it in our code.

ordian and others added 2 commits April 15, 2019 12:47
Comment thread kvdb-lmdb/src/lib.rs Outdated
Comment thread kvdb-lmdb/src/lib.rs Outdated
Comment thread kvdb-lmdb/src/lib.rs Outdated
Comment thread kvdb-lmdb/src/lib.rs Outdated
Thanks David :)

Co-Authored-By: ordian <write@reusable.software>
@debris
Copy link
Copy Markdown
Contributor

debris commented Oct 15, 2019

worth reading if we ever want to get back to this pr:

@ordian
Copy link
Copy Markdown
Contributor Author

ordian commented Mar 26, 2020

we're already using zerocopy bindings to lmdb here, but https://github.com/Kerollmops/heed also worth considering if we're getting back to this

@ordian
Copy link
Copy Markdown
Contributor Author

ordian commented Mar 26, 2020

Currently sled looks like a more promising approach and lmdb slow write speed is also something sled acknoledges https://github.com/spacejam/sled/wiki/motivating-experiences#lmdb

@ordian
Copy link
Copy Markdown
Contributor Author

ordian commented Aug 27, 2020

Closing as stale.

@ordian ordian closed this Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants