electrs icon indicating copy to clipboard operation
electrs copied to clipboard

Implement multiple Backing Store using Generics

Open KhaledEmaraDev opened this issue 2 years ago • 9 comments

This PR adds different Backing Database Stores for the Index Structures. This is done using generics. Each Backing Store is behind a feature flag and its dependencies only compile when this features is enabled.

KhaledEmaraDev avatar Aug 19 '22 20:08 KhaledEmaraDev

I had to change the toolchain to version 1.61.0 because of redb.

KhaledEmaraDev avatar Aug 19 '22 20:08 KhaledEmaraDev

@romanz Also, Cargo.toml feature dep: needs cargo 1.56.0 at least. That's why it's failing the CI.

KhaledEmaraDev avatar Aug 19 '22 20:08 KhaledEmaraDev

@cberner will definitely be interested in this!

casey avatar Aug 19 '22 20:08 casey

This is still incomplete as for instance in redb. I haven't been able to get a prefix iterator so far. For instance in the test:

let items: &[&[u8]] = &[
    b"ab",
    b"abcdefgh",
    b"abcdefghj",
    b"abcdefghjk",
    b"abcdefghxyz",
    b"abcdefgi",
    b"b",
    b"c",
];

It returns everything after abcdefgh. So it's insert time order not prefix search.

I have been trying to track the prefix manually, but so far have been unsuccessful. It's very slow. However; I'm currently trying a new way of tracking prefixs.

KhaledEmaraDev avatar Aug 19 '22 20:08 KhaledEmaraDev

I had to change the toolchain to version 1.61.0

Unfortunately, we want to support Debian stable which only has 1.48. I personally wouldn't mind having higher MSRV with opt-in feature but it needs CI modified to use 1.48 to test without it and use 1.61 with it.

Kixunil avatar Aug 20 '22 07:08 Kixunil

Many thanks for the contribution! Unfortunately, I am not available now - will review in two weeks.

romanz avatar Aug 20 '22 14:08 romanz

@romanz I rebased on master.

The CI is failing because:

  1. Audit: Because the GitHub action is running from a fork.
  2. Build: Because the redb backend has one slight problem just like I said above. It's making prefix scans wrong. I'm working on fixing it.
  3. Integration: Due to the Rust toolchain. I'll fix it.

Can I get the testnet indexing performance instead? I don't have the space right now to download mainnet. I can try in a few days, though.

KhaledEmaraDev avatar Aug 30 '22 21:08 KhaledEmaraDev

is this PR still being worked on? i think it would be useful to allow for different databases (maybe helps to optimize for hdd/ssd performance), but instead of choosing one at compile time, a command line flag (choose at runtime) would be better (if you use a precompiled release you can still choose) and use feature flags to choose which database backend get compiled in, especially useful for big dependencies or ones that bind to C code

antonilol avatar Apr 13 '23 17:04 antonilol

@antonilol I think I can make to that backed-in storage backends are selectable using a CLI flag.

I think we should do this after merging this PR first. I still need to enhance the redb logic. I'll try to work on that sometime soon.

KhaledEmaraDev avatar Apr 14 '23 09:04 KhaledEmaraDev

how is this pr going?

are you still working on it, and which things are still missing/planned (like the ones you named here, but maybe more)?

antonilol avatar May 23 '24 17:05 antonilol

Closing due to inactivity.

romanz avatar May 24 '24 11:05 romanz