Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RocksDb] Tables consolidation #1466

Merged
merged 1 commit into from
Apr 29, 2024
Merged

[RocksDb] Tables consolidation #1466

merged 1 commit into from
Apr 29, 2024

Conversation

AhmedSoliman
Copy link
Contributor

@AhmedSoliman AhmedSoliman commented Apr 24, 2024

[RocksDb] Tables consolidation

This is one step in a series of changes to move to a one CF per partition-id. The change consolidates all partitions into a single CF data-unpartitioned.

Notes:

  • This introduces a fixed key prefix to partition CF to improve bloom filter lookups. This change require some subtle handling of scans that spans multiple prefixes, this is handled and is covered by existing test cases.
  • This adds the ability for a table to have multiple KeyKinds attached. Each TableKey has an associated kind, and the table (TableKind) has a set of KeyKinds associated.
  • This is designed to allow future separation of tables, or even individual key kinds to separate CFs.
  • Some values are intentionally passed but not used for (a) clarity at call site and (b) to help with follow-up refactoring.

Side note: cluster marker tests fail sporadically, this adds a flush after each temp file write in an attempt to fix them.


Stack created with Sapling. Best reviewed with ReviewStack.

Copy link

github-actions bot commented Apr 24, 2024

Test Results

 95 files  ±0   95 suites  ±0   7m 32s ⏱️ +7s
 82 tests ±0   80 ✅ ±0  2 💤 ±0  0 ❌ ±0 
212 runs  ±0  206 ✅ ±0  6 💤 ±0  0 ❌ ±0 

Results for commit dc2c8ea. ± Comparison against base commit 5a826ce.

♻️ This comment has been updated with latest results.

@AhmedSoliman AhmedSoliman force-pushed the pr1466 branch 2 times, most recently from d13598f to c61491b Compare April 25, 2024 14:05
@AhmedSoliman AhmedSoliman changed the title [WIP] Consolidate [RocksDb] Tables consolidation Apr 25, 2024
@AhmedSoliman AhmedSoliman marked this pull request as ready for review April 25, 2024 14:12
Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

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

Thanks for creating this PR @AhmedSoliman. The changes look good to me. I left a few minor comments. +1 for merging.

crates/node/src/cluster_marker.rs Show resolved Hide resolved
crates/storage-rocksdb/src/scan.rs Outdated Show resolved Hide resolved
crates/storage-rocksdb/src/scan.rs Outdated Show resolved Hide resolved
crates/storage-rocksdb/src/scan.rs Outdated Show resolved Hide resolved
crates/storage-rocksdb/src/scan.rs Outdated Show resolved Hide resolved
Comment on lines +74 to +79
// Ensures that both types have the same length, this makes it possible to
// share prefix extractor in rocksdb.
const_assert_eq!(
std::mem::size_of::<PartitionKey>(),
std::mem::size_of::<PartitionId>(),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

crates/storage-rocksdb/src/lib.rs Show resolved Hide resolved
Idempotency => IDEMPOTENCY_TABLE_NAME,
}
const fn cf_name(_kind: TableKind) -> &'static str {
PARTITION_CF
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum TableKind {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the plan for the TableKind abstraction? It seems that it does not add a lot of value right now. Maybe it could be removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or is this one of the follow-ups?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's still a useful abstraction, it's now possible to have multiple keys per table, but we might revisit this at some point and clean it up. I'd say that I wouldn't remove it prematurely and only do that when it becomes a hindrance.

crates/storage-rocksdb/src/lib.rs Outdated Show resolved Hide resolved
crates/storage-rocksdb/src/lib.rs Outdated Show resolved Hide resolved
This is one step in a series of changes to move to a one CF per partition-id. The change consolidates all partitions into a single CF `data-unpartitioned`.

Notes:
- This introduces a fixed key prefix to partition CF to improve bloom filter lookups. This change require some subtle handling of scans that spans multiple prefixes, this is handled and is covered by existing test cases.
- This adds the ability for a table to have multiple KeyKinds attached. Each TableKey has an associated kind, and the table (TableKind) has a set of KeyKinds associated.
- This is designed to allow future separation of tables, or even individual key kinds to separate CFs.
- Some values are intentionally passed but not used for (a) clarity at call site and (b) to help with follow-up refactoring.


Side note: cluster marker tests fail sporadically, this adds a flush after each temp file write in an attempt to fix them.
@AhmedSoliman AhmedSoliman merged commit f81ec58 into main Apr 29, 2024
13 checks passed
@AhmedSoliman AhmedSoliman deleted the pr1466 branch April 29, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants