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

Make cgroup memory pressure monitoring optional. #29

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ thiserror = "1.0.63"
tracy-client = { version = "0.17.1", optional = true }

[features]
default = ["systemd", "human-logs"]
default = ["systemd", "human-logs", "memory-pressure-monitoring"]
systemd = ["dep:sd-notify"]
human-logs = ["env_logger/default"]
trace = ["dep:tracy-client"]
memory-pressure-monitoring = []

[[bin]]
name = "ringboard-server"
Expand Down
6 changes: 5 additions & 1 deletion server/src/reactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ fn setup_uring() -> Result<IoUring, CliError> {
OwnedFd::from_raw_fd(fd)
};

#[cfg(feature="memory-pressure-monitoring")]
let low_mem_listener = {
let mut cgroup = String::with_capacity(160);
cgroup.push_str("/sys/fs/cgroup");
Expand Down Expand Up @@ -164,6 +165,7 @@ fn setup_uring() -> Result<IoUring, CliError> {
let built_ins = [
socket.as_raw_fd(),
signal_handler.as_raw_fd(),
#[cfg(feature="memory-pressure-monitoring")]
low_mem_listener.as_raw_fd(),
];
uring
Expand Down Expand Up @@ -200,6 +202,7 @@ pub fn run(allocator: &mut Allocator) -> Result<(), CliError> {
.allocate_file_index(true)
.build()
.user_data(REQ_TYPE_ACCEPT);
#[cfg(feature="memory-pressure-monitoring")]
let poll_low_mem = PollAdd::new(
Fixed(u32::from(MAX_NUM_CLIENTS) + 2),
u32::try_from(libc::POLLPRI).unwrap(),
Expand Down Expand Up @@ -283,7 +286,7 @@ pub fn run(allocator: &mut Allocator) -> Result<(), CliError> {
let mut submission = uring.submission();
unsafe {
submission
.push_multiple(&[accept.clone(), read_signals, poll_low_mem.clone()])
.push_multiple(&[accept.clone(), read_signals, #[cfg(feature="memory-pressure-monitoring")] poll_low_mem.clone()])
.unwrap();
}
}
Expand Down Expand Up @@ -526,6 +529,7 @@ pub fn run(allocator: &mut Allocator) -> Result<(), CliError> {

break 'outer;
}
#[cfg(feature="memory-pressure-monitoring")]
REQ_TYPE_LOW_MEM => {
debug!("Handling low memory completion.");
let result = result.map_io_err(|| "Failed to poll for low memory events.")?;
Expand Down