importer icon indicating copy to clipboard operation
importer copied to clipboard

v3.0 KV Protocol Proposal: Strip the first 11 bytes from key in WriteEngine, specify it in ImportEngine

Open kennytm opened this issue 6 years ago • 6 comments

message ImportEngineRequest {
    bytes uuid = 1;
    string pd_addr = 2;
    bytes key_prefix = 3;
}

Rationale:

An engine currently targets a single table, and contains either only data or only index. This means the first 11 bytes of all keys in an engine are always the same (t«tableID»_r or t«tableID»_i). If a table has 1 billion entries this will waste 11 GB of Lightning → Importer traffic. This also allows the engine be agnostic of table ID, so that the engine file could be reused multiple times.

kennytm avatar May 25 '19 12:05 kennytm

Note: this optimization cannot be applied to partitioned tables, where the table ID differ for every partition, unless we store each partition into separate engines (but this will blow up the max-open-engine).

kennytm avatar Jul 04 '19 20:07 kennytm

Is there a uniform routine for normal and partitioned tables? I could only imagine two types of engines for two tables.

lance6716 avatar Aug 20 '19 08:08 lance6716

For normal table we set the prefix to be t«tableID»_r, and for partitioned table we set the prefix to be t (or just an empty string).

kennytm avatar Aug 20 '19 09:08 kennytm

Sounds like the prefix compression of RocksDB? https://github.com/facebook/rocksdb/blob/9a449865e3963e7cff0bc7fc7f0731d3dea459de/table/block_based/block_builder.cc#L10-L32

overvenus avatar Aug 30 '19 07:08 overvenus

Sounds like the prefix compression of RocksDB? https://github.com/facebook/rocksdb/blob/9a449865e3963e7cff0bc7fc7f0731d3dea459de/table/block_based/block_builder.cc#L10-L32

I'm not aware of this feature, here we just want to reduce data transfer. Sounds like this feature will reduce concatenate cost and space usage, and maybe have some impact on searching the compressed key? @kennytm

lance6716 avatar Aug 30 '19 07:08 lance6716

Actually, this feature is enabled by default.

overvenus avatar Aug 30 '19 07:08 overvenus