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

[Bifrost] Read stream support multi-segment logs #1744

Merged
merged 3 commits into from
Jul 26, 2024
Merged

[Bifrost] Read stream support multi-segment logs #1744

merged 3 commits into from
Jul 26, 2024

Conversation

AhmedSoliman
Copy link
Contributor

@AhmedSoliman AhmedSoliman commented Jul 24, 2024

[Bifrost] Read stream support multi-segment logs

This introduces a new read stream implementation that operates under a multi-segment bifrost world. Notable features include:

  • Support for reading from multiple segments seamlessly
  • Reading unsealed segments while watching the tail state to determine the safe boundaries with minimal efficiency loss
  • Handling of on-going reconfiguration, the stream waits for the loglet to be sealed.
  • Handles prefix trims on metadata-level when detected (partial support, more on that in follow up PRs)

Running bifrost-benchpress read-to-write latency tests show that the new read-stream doesn't introduce any meaningful regression in latency in the the unsealed close-to-tail case (note that P100 should be discarded due to shutdown-related noise)

Write-to-read latency:

New                                  Old
Total records read: 98317            Total records read: 97871
P50: 67.455µs                        P50: 67.519µs
P90: 77.951µs                        P90: 77.183µs
P99: 96.447µs                        P99: 94.143µs
P999: 129.215µs                      P999: 122.815µs

Stack created with Sapling. Best reviewed with ReviewStack.

@AhmedSoliman AhmedSoliman force-pushed the pr1744 branch 2 times, most recently from cae8f5f to 23d9220 Compare July 24, 2024 10:24
@AhmedSoliman AhmedSoliman marked this pull request as ready for review July 24, 2024 10:24
Copy link

github-actions bot commented Jul 24, 2024

Test Results

102 files  ±0  102 suites  ±0   22m 33s ⏱️ -49s
 84 tests ±0   84 ✅ ±0  0 💤 ±0  0 ❌ ±0 
217 runs  ±0  217 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 86a3ff5. ± Comparison against base commit 357c317.

♻️ This comment has been updated with latest results.

@AhmedSoliman
Copy link
Contributor Author

Pulling it back from the review queue until e2e is fixed.

@AhmedSoliman
Copy link
Contributor Author

This is now ready to review

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.

Great piece of work @AhmedSoliman 🚀 Really liking how easy it is to follow the elaborate logic of the LogletReadStream by having the explicit state machine spelled out :-) LGTM. +1 for merging.

crates/bifrost/src/read_stream.rs Show resolved Hide resolved
crates/bifrost/src/read_stream.rs Show resolved Hide resolved
// BifrostInner is dropped last, we can safely lift it's lifetime to 'static as
// long as we don't leak this externally. External users should not see any `'static`
// lifetime as a result.
let bifrost_inner = unsafe { &*Arc::as_ptr(&self.bifrost_inner) };
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to save the atomic increment operation on the Arc if we used instead Arc::clone(&self.bifrost_inner)?

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'm on the fence, but let's keep it this way because I suspect we will need to use it a little more and I don't want to arc::clone on the critical path of polls.

crates/bifrost/src/read_stream.rs Outdated Show resolved Hide resolved
crates/bifrost/src/read_stream.rs Show resolved Hide resolved
crates/bifrost/src/read_stream.rs Outdated Show resolved Hide resolved
this.state.set(State::Terminated);
return Poll::Ready(Some(Err(ShutdownError.into())));
}
Some(TailState::Open(tail)) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

A loglet will only return Open for a given lsn if it knows that this was safely committed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. that's the contract.

crates/bifrost/src/read_stream.rs Show resolved Hide resolved
Loglet wrapper now limits reads if the loglet sealed tail is known
This introduces a new read stream implementation that operates under a multi-segment bifrost world. Notable features include:
- Support for reading from multiple segments seamlessly
- Reading unsealed segments while watching the tail state to determine the safe boundaries with minimal efficiency loss
- Handling of on-going reconfiguration, the stream waits for the loglet to be sealed.
- Handles prefix trims on metadata-level when detected (partial support, more on that in follow up PRs)

Running bifrost-benchpress read-to-write latency tests show that the new read-stream doesn't introduce any meaningful regression in latency in the the unsealed close-to-tail case (note that P100 should be discarded due to shutdown-related noise)

Write-to-read latency:
```
New                                  Old
Total records read: 98317            Total records read: 97871
P50: 67.455µs                        P50: 67.519µs
P90: 77.951µs                        P90: 77.183µs
P99: 96.447µs                        P99: 94.143µs
P999: 129.215µs                      P999: 122.815µs
```
@AhmedSoliman AhmedSoliman merged commit 86a3ff5 into main Jul 26, 2024
13 checks passed
@AhmedSoliman AhmedSoliman deleted the pr1744 branch July 26, 2024 11:14
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