Skip to content

Add foreground eviction#28

Merged
2a46m4 merged 11 commits intomainfrom
john/evictionchannelled
Jul 30, 2025
Merged

Add foreground eviction#28
2a46m4 merged 11 commits intomainfrom
john/evictionchannelled

Conversation

@johnramsden
Copy link
Copy Markdown
Owner

Use a channel mechanism for either eviction on a interval, or immediately when triggered through a channel request.

When eviction is triggered it drains the channel and informs all that eviction occurred.


WIP, currently Deadlocks at:

pub async fn remove_zones(&self, zone_indices: &[usize]) -> tokio::io::Result<()> {
let mut map_guard = self.buckets.write().await; // DEADLOCK
let mut reverse_mapping_guard = self.zone_to_entry.lock().await;

Deadlocks at:

    pub async fn remove_zones(&self, zone_indices: &[usize]) -> tokio::io::Result<()> {
        let mut map_guard = self.buckets.write().await; // DEADLOCK
@johnramsden johnramsden requested a review from 2a46m4 July 26, 2025 03:20
@johnramsden
Copy link
Copy Markdown
Owner Author

I'm not sure I like this but this is what we have for now. It kind of busy waits. we might need to adjust

let zone_index = loop {
match self.get_free_zone() {
Ok(res) => break res,
Err(err) => {
eprintln!("[append] Failed to get free zone: {}", err);
}
};
let (resp_tx, resp_rx) = flume::bounded(1);
if let Err(e) = self.eviction_channel.send(EvictorMessage {
sender: resp_tx,
}) {
eprintln!("[append] Failed to send eviction message: {}", e);
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Failed to send eviction message",
));
};
if let Err(e) = resp_rx.recv() {
eprintln!("[append] Failed to receive eviction message: {}", e);
}
};

Copy link
Copy Markdown
Collaborator

@2a46m4 2a46m4 left a comment

Choose a reason for hiding this comment

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

It looks good to me!

Comment thread oxcache.zip Outdated
Comment thread oxcache/src/device.rs Outdated
Comment thread oxcache/src/eviction.rs
@2a46m4 2a46m4 merged commit e797f99 into main Jul 30, 2025
1 check passed
@johnramsden johnramsden deleted the john/evictionchannelled branch August 17, 2025 22:49
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