Skip to content

ignore: refactoring entity state #127

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

Draft
wants to merge 80 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
90c23be
Add entity-manager dep
rklaehn Jul 8, 2025
90db719
Remove unused dependencies
rklaehn Jul 8, 2025
24c7f2c
Merge branch 'lose-futures-buffered-dep' into entity-manager
rklaehn Jul 8, 2025
126d834
Merge branch 'main' into entity-manager
rklaehn Jul 8, 2025
264ed84
Add import
rklaehn Jul 8, 2025
a859674
Add helpers for set and update
rklaehn Jul 8, 2025
baf4d54
Make bipolar clippy happy again
rklaehn Jul 8, 2025
66f8540
Move message sending into meta
rklaehn Jul 8, 2025
9193b08
Merge branch 'remove-db-public-send' into entity-manager
rklaehn Jul 8, 2025
8cae7cd
WIP
rklaehn Jul 8, 2025
161a70b
Replace slots with EntityHandler
rklaehn Jul 8, 2025
169261a
Get rid of the weak reference
rklaehn Jul 8, 2025
6fe2e07
Inline entity manager and streamline the dispatcher code a bit
rklaehn Jul 9, 2025
fd9faab
revert a few changes to minimize the diff
rklaehn Jul 9, 2025
8ac1b78
codespell
rklaehn Jul 9, 2025
011746d
remove debug code
rklaehn Jul 9, 2025
def9abc
more comments
rklaehn Jul 9, 2025
3d603b0
remove options from BaoFileHandleInner
rklaehn Jul 9, 2025
e65bd07
Get rid of BaoFileHandleInner and all that indirection
rklaehn Jul 9, 2025
e81b1f3
change a few fns to take HashContext directly instead of 2 args
rklaehn Jul 9, 2025
27df6da
more using HashContext instead of TaskContext
rklaehn Jul 9, 2025
77fbb05
First step for removing the slot mutex
rklaehn Jul 9, 2025
ae95f28
prepare BaoFileHandle to be the full state
rklaehn Jul 9, 2025
c786a04
Flatten the state we keep per active blob
rklaehn Jul 10, 2025
94df43f
Remove debug statements
rklaehn Jul 10, 2025
48ffd48
Remove unused code
rklaehn Jul 10, 2025
a540002
Remove more debug code
rklaehn Jul 10, 2025
6e237f8
instrument the per-hash tasks as well
rklaehn Jul 10, 2025
47cab9c
Add property based tests for the entity manager
rklaehn Jul 10, 2025
00c54f3
Add a property based test that tests basic functionality of the entit…
rklaehn Jul 10, 2025
664beb8
clippy
rklaehn Jul 10, 2025
7b1b71b
Merge branch 'main' into entity-manager
rklaehn Jul 10, 2025
e584ad1
fmt
rklaehn Jul 10, 2025
4412be9
Add tests for the busy and dead cases which are hard to trigger witho…
rklaehn Jul 10, 2025
c26e555
clippy again
rklaehn Jul 10, 2025
002469a
Merge branch 'entity-manager' into slim-down-state
rklaehn Jul 11, 2025
7857e38
Merge branch 'slim-down-state' into remove-slot-mutex
rklaehn Jul 11, 2025
f559598
Move things around in preparation for introducing traits
rklaehn Jul 11, 2025
bc6bc71
Group high level fns.
rklaehn Jul 11, 2025
632131f
Introduce traits to structure the API
rklaehn Jul 11, 2025
8004115
Merge branch 'main' into entity-manager
rklaehn Jul 11, 2025
4020bd4
Merge branch 'entity-manager' into slim-down-state
rklaehn Jul 11, 2025
1665781
Merge branch 'slim-down-state' into remove-slot-mutex
rklaehn Jul 11, 2025
9a8547a
clippy
rklaehn Jul 11, 2025
c57f259
Merge branch 'main' into entity-manager
rklaehn Jul 23, 2025
331a3aa
Merge branch 'entity-manager' into slim-down-state
rklaehn Jul 23, 2025
e2b76fb
Merge branch 'slim-down-state' into remove-slot-mutex
rklaehn Jul 23, 2025
42bbbec
Merge branch 'main' into entity-manager
rklaehn Jul 24, 2025
b595923
Merge branch 'entity-manager' into slim-down-state
rklaehn Jul 24, 2025
6d39d40
Merge branch 'slim-down-state' into remove-slot-mutex
rklaehn Jul 24, 2025
d8847ea
Add wait_idle api call.
rklaehn Jul 24, 2025
dcbd83b
Use the shiny new wait_idle in another racy test.
rklaehn Jul 24, 2025
1c62546
remove stray println!
rklaehn Jul 24, 2025
c79a21e
Add more detailed logging for the entty manager proptest
rklaehn Jul 25, 2025
71bf60b
clippy
rklaehn Jul 25, 2025
3083bcd
require user to define state struct
rklaehn Jul 25, 2025
751e0d6
fix ref_count bug
rklaehn Jul 25, 2025
5d6c759
comment about reset being different to new
rklaehn Jul 25, 2025
91af79e
Merge branch 'main' into entity-manager
rklaehn Aug 5, 2025
21dc789
Merge branch 'entity-manager' into slim-down-state
rklaehn Aug 5, 2025
160cfca
Merge branch 'slim-down-state' into remove-slot-mutex
rklaehn Aug 5, 2025
00c263a
Merge branch 'remove-slot-mutex' into abstract-entity-state
rklaehn Aug 5, 2025
e028496
Merge branch 'main' into slim-down-state
rklaehn Aug 5, 2025
dba9a4c
Merge branch 'slim-down-state' into remove-slot-mutex
rklaehn Aug 5, 2025
4e369fe
Merge branch 'remove-slot-mutex' into abstract-entity-state
rklaehn Aug 5, 2025
1be113a
Update comment to remark that Drop is no longer implemented.
rklaehn Aug 5, 2025
7a9be84
Change panic! into unreachable!
rklaehn Aug 5, 2025
4a09c64
Merge branch 'slim-down-state' into remove-slot-mutex
rklaehn Aug 5, 2025
4529be6
Remove debug code
rklaehn Aug 5, 2025
1b23d64
Point to iroh main
rklaehn Aug 5, 2025
b3389b6
Some renaming
rklaehn Aug 5, 2025
74179ec
WIP try to come up with an API for the global state
rklaehn Aug 6, 2025
f0f218d
Address review comments
rklaehn Aug 6, 2025
1f42698
remove parallelism for cross tests again
rklaehn Aug 6, 2025
ee96662
Merge branch 'remove-slot-mutex' into abstract-entity-state
rklaehn Aug 6, 2025
c9e0aa2
Merge branch 'main' into remove-slot-mutex
rklaehn Aug 6, 2025
5b3953d
Use iroh main
rklaehn Aug 6, 2025
3317b8e
Merge branch 'remove-slot-mutex' into abstract-entity-state
rklaehn Aug 6, 2025
5ac0a49
give metadata actor its own tasks
rklaehn Aug 6, 2025
96e0a4a
Handle list_blobs inside the meta db
rklaehn Aug 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
- uses: taiki-e/install-action@cross

- name: test
run: cross test --all --target ${{ matrix.target }} -- --test-threads=4
run: cross test --all --target ${{ matrix.target }} -- --test-threads=1
env:
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG' }}

Expand Down
15 changes: 6 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ chrono = "0.4.39"
nested_enum_utils = "0.2.1"
ref-cast = "1.0.24"
arrayvec = "0.7.6"
iroh = "0.91"
iroh = "0.91.1"
self_cell = "1.1.0"
genawaiter = { version = "0.99.1", features = ["futures03"] }
iroh-base = "0.91"
iroh-base = "0.91.1"
reflink-copy = "0.1.24"
irpc = { version = "0.7.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false }
iroh-metrics = { version = "0.35" }
Expand All @@ -59,9 +59,13 @@ tracing-subscriber = { version = "0.3.19", features = ["fmt"] }
tracing-test = "0.2.5"
walkdir = "2.5.0"
atomic_refcell = "0.1.13"
iroh = { version = "0.91", features = ["discovery-local-network"]}
iroh = { version = "0.91.1", features = ["discovery-local-network"] }

[features]
hide-proto-docs = []
metrics = []
default = ["hide-proto-docs"]

[patch.crates-io]
iroh = { git = "https://github.com/n0-computer/iroh", branch = "main" }
iroh-base = { git = "https://github.com/n0-computer/iroh", branch = "main" }
3 changes: 3 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ name = "ring"
[[licenses.clarify.license-files]]
hash = 3171872035
path = "LICENSE"

[sources]
allow-git = ["https://github.com/n0-computer/iroh"]
18 changes: 18 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod downloader;
pub mod proto;
pub mod remote;
pub mod tags;
use crate::api::proto::WaitIdleRequest;
pub use crate::{store::util::Tag, util::temp_tag::TempTag};

pub(crate) type ApiClient = irpc::Client<proto::Request>;
Expand Down Expand Up @@ -298,6 +299,23 @@ impl Store {
Ok(())
}

/// Waits for the store to become completely idle.
///
/// This is mostly useful for tests, where you want to check that e.g. the
/// store has written all data to disk.
///
/// Note that a store is not guaranteed to become idle, if it is being
/// interacted with concurrently. So this might wait forever.
///
/// Also note that once you get the callback, the store is not guaranteed to
/// still be idle. All this tells you that there was a point in time where
/// the store was idle between the call and the response.
pub async fn wait_idle(&self) -> irpc::Result<()> {
let msg = WaitIdleRequest;
self.client.rpc(msg).await?;
Ok(())
}

pub(crate) fn from_sender(client: ApiClient) -> Self {
Self { client }
}
Expand Down
5 changes: 5 additions & 0 deletions src/api/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,16 @@ pub enum Request {
#[rpc(tx = oneshot::Sender<super::Result<()>>)]
SyncDb(SyncDbRequest),
#[rpc(tx = oneshot::Sender<()>)]
WaitIdle(WaitIdleRequest),
#[rpc(tx = oneshot::Sender<()>)]
Shutdown(ShutdownRequest),
#[rpc(tx = oneshot::Sender<super::Result<()>>)]
ClearProtected(ClearProtectedRequest),
}

#[derive(Debug, Serialize, Deserialize)]
pub struct WaitIdleRequest;

#[derive(Debug, Serialize, Deserialize)]
pub struct SyncDbRequest;

Expand Down
41 changes: 40 additions & 1 deletion src/api/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,15 @@ mod tests {
use testresult::TestResult;

use crate::{
api::blobs::Blobs,
protocol::{ChunkRangesSeq, GetRequest},
store::fs::{tests::INTERESTING_SIZES, FsStore},
store::{
fs::{
tests::{create_n0_bao, test_data, INTERESTING_SIZES},
FsStore,
},
mem::MemStore,
},
tests::{add_test_hash_seq, add_test_hash_seq_incomplete},
util::ChunkRangesExt,
};
Expand Down Expand Up @@ -1117,6 +1124,38 @@ mod tests {
Ok(())
}

async fn test_observe_partial(blobs: &Blobs) -> TestResult<()> {
let sizes = INTERESTING_SIZES;
for size in sizes {
let data = test_data(size);
let ranges = ChunkRanges::chunk(0);
let (hash, bao) = create_n0_bao(&data, &ranges)?;
blobs.import_bao_bytes(hash, ranges.clone(), bao).await?;
let bitfield = blobs.observe(hash).await?;
if size > 1024 {
assert_eq!(bitfield.ranges, ranges);
} else {
assert_eq!(bitfield.ranges, ChunkRanges::all());
}
}
Ok(())
}

#[tokio::test]
async fn test_observe_partial_mem() -> TestResult<()> {
let store = MemStore::new();
test_observe_partial(store.blobs()).await?;
Ok(())
}

#[tokio::test]
async fn test_observe_partial_fs() -> TestResult<()> {
let td = tempfile::tempdir()?;
let store = FsStore::load(td.path()).await?;
test_observe_partial(store.blobs()).await?;
Ok(())
}

#[tokio::test]
async fn test_local_info_hash_seq() -> TestResult<()> {
let sizes = INTERESTING_SIZES;
Expand Down
Loading