Skip to content

Reduce thread contention for StickSequence #21

@cscherrer

Description

@cscherrer

Current StickSequence looks like this:

pub struct _Inner {
    #[cfg_attr(feature = "serde1", serde(skip, default = "default_rng"))]
    rng: Xoshiro256Plus,
    ccdf: Vec<f64>,
}

pub struct StickSequence {
    breaker: UnitPowerLaw,
    inner: Arc<RwLock<_Inner>>,
}

Here the ccdf is extended on demand. This is deterministic, so in principle there's no need for writing the nth value to affect another thread trying to read some k < nth value. But the current implementation doesn't encode this independence, and we're forced to choose between one writer or multiple readers.

One possibility for improving this is to switch to lazy_list. Let's try this. If it's not an exact fit we may need to implement something custom, but it would be better to just plug in an existing crate.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions