Skip to content

Add an experimental mixed io mode. #61

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

Merged
merged 7 commits into from
Mar 7, 2025
Merged

Add an experimental mixed io mode. #61

merged 7 commits into from
Mar 7, 2025

Conversation

rklaehn
Copy link
Collaborator

@rklaehn rklaehn commented Mar 7, 2025

The mixed IO mode is using a tokio mpsc queue to communicate with an external source/sink of data, but blocking IO for the local file io.

It is used by the big blob store refactor, where I create a dedicated tokio runtime for IO and do blocking IO on that, similar to the solution that @Frando and me have come up with for database interactions.

The feature is called experimental-mixed so that people don't expect stability. It will get a better and less scary name once it is stable.

@@ -1,7 +1,8 @@
use std::{io::Write, path::PathBuf};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

@@ -1,3 +1,5 @@
use std::io;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

@@ -1,3 +1,5 @@
use std::io;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

use std::{fmt, io};

use crate::{ChunkNum, TreeNode};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

use iroh_io::{AsyncStreamReader, AsyncStreamWriter};
use smallvec::SmallVec;

pub use super::BaoContentItem;
use super::{combine_hash_pair, DecodeError};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

pub struct Leaf {
/// The byte offset of the leaf in the file.
pub offset: u64,
/// The data of the leaf.
pub data: Bytes,
}

impl std::fmt::Debug for Leaf {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nicer debug instance for leaf, unrelated change

use std::io;

use crate::{blake3, BaoTree, BlockSize, TreeNode};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

data: D,
outboard: O,
ranges: &ChunkRangesRef,
encoded: W,
) -> result::Result<(), EncodeError> {
if ranges.is_empty() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

properly handle the case where ranges are empty

@@ -658,13 +661,12 @@ mod validate {
use genawaiter::sync::{Co, Gen};
use positioned_io::ReadAt;

use super::Outboard;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

@@ -74,6 +74,8 @@
//! ## Simple end to end example
//!
//! ```no_run
//! use std::io;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

@@ -439,13 +436,15 @@ mod test_support {
(res, hash)
}

/// Check that l and r of a 2-tuple are equal
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt and doc strings

@@ -8,6 +8,16 @@ use bytes::Bytes;
use proptest::prelude::*;
use range_collections::RangeSet2;

use super::{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

@@ -80,6 +80,19 @@ impl BlockSize {
}

impl ChunkNum {
/// Start (inclusive) of the chunk group that this chunk is in
pub const fn chunk_group_start(start: ChunkNum, block_size: BlockSize) -> ChunkNum {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new fns to round up a set of ranges to chunk groups, needed for the new store

@@ -6,31 +6,34 @@
//! There is a proptest called <testname>_proptest that calls the test multiple times with random data.
//! There is a test called <testname>_cases that calls the test with a few hardcoded values, either
//! handcrafted or from a previous failure of a proptest.
use std::ops::Range;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fmt

@n0bot n0bot bot added this to iroh Mar 7, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Mar 7, 2025
@rklaehn rklaehn merged commit 82100a9 into main Mar 7, 2025
26 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Mar 7, 2025
@rklaehn rklaehn deleted the baocontentitem branch March 7, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant