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

[ISSUE #357]⚡️Replace Arc<parking_lot::Mutex<u64>> with AtomicU64 of MappedFileQueue property #358

Merged
merged 1 commit into from
May 14, 2024
Merged
Changes from all commits
Commits
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
[ISSUE #357]⚡️Replace Arc<parking_lot::Mutex<u64>> with AtomicU64 of …
…MappedFileQueue property
mxsm committed May 14, 2024
commit a833682993f571fef6f069a4d98a776d3e9b5404
23 changes: 14 additions & 9 deletions rocketmq-store/src/consume_queue/mapped_file_queue.rs
Original file line number Diff line number Diff line change
@@ -18,7 +18,10 @@
use std::{
fs,
path::{Path, PathBuf},
sync::Arc,
sync::{
atomic::{AtomicU64, Ordering},
Arc,
},
};

use log::warn;
@@ -42,11 +45,11 @@ pub struct MappedFileQueue {
// pub(crate) mapped_files: Vec<LocalMappedFile>,
pub(crate) allocate_mapped_file_service: Option<AllocateMappedFileService>,

pub(crate) flushed_where: Arc<parking_lot::Mutex<u64>>,
pub(crate) flushed_where: Arc<AtomicU64>,

pub(crate) committed_where: Arc<parking_lot::Mutex<u64>>,
pub(crate) committed_where: Arc<AtomicU64>,

pub(crate) store_timestamp: Arc<parking_lot::Mutex<u64>>,
pub(crate) store_timestamp: Arc<AtomicU64>,
}

/*impl Swappable for MappedFileQueue {
@@ -75,9 +78,9 @@ impl MappedFileQueue {
mapped_file_size,
mapped_files: Vec::new(),
allocate_mapped_file_service,
flushed_where: Arc::new(parking_lot::Mutex::new(0)),
committed_where: Arc::new(parking_lot::Mutex::new(0)),
store_timestamp: Arc::new(parking_lot::Mutex::new(0)),
flushed_where: Arc::new(AtomicU64::new(0)),
committed_where: Arc::new(AtomicU64::new(0)),
store_timestamp: Arc::new(AtomicU64::new(0)),
}
}

@@ -225,11 +228,13 @@ impl MappedFileQueue {
}

pub fn set_flushed_where(&mut self, flushed_where: i64) {
*self.flushed_where.lock() = flushed_where as u64;
self.flushed_where
.store(flushed_where as u64, Ordering::SeqCst);
}

pub fn set_committed_where(&mut self, committed_where: i64) {
*self.committed_where.lock() = committed_where as u64;
self.committed_where
.store(committed_where as u64, Ordering::SeqCst);
}

pub fn truncate_dirty_files(&mut self, offset: i64) {}