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

feat(memory): Implement shared memory state across Relay #3821

Merged
merged 40 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
90fb599
feat(memory): Implement shared memory state across Relay
iambriccardo Jul 15, 2024
b0ca49d
feat(memory): Add a way to track memory usage
iambriccardo Jul 16, 2024
7c8d357
Fix
iambriccardo Jul 16, 2024
cc4b577
Fix
iambriccardo Jul 16, 2024
c449dfd
Fix
iambriccardo Jul 16, 2024
2dc4e13
Fix
iambriccardo Jul 16, 2024
6bfd213
Fix
iambriccardo Jul 16, 2024
584a868
Fix
iambriccardo Jul 16, 2024
e7608a8
Remove usage of floats
iambriccardo Jul 16, 2024
75a3ffc
Improve
iambriccardo Jul 16, 2024
1069847
Improve
iambriccardo Jul 16, 2024
719bea7
Improve
iambriccardo Jul 16, 2024
45b35ee
Improve
iambriccardo Jul 16, 2024
6a8be96
Improve
iambriccardo Jul 17, 2024
f4a7d39
fi
iambriccardo Jul 17, 2024
8ceac2e
Fix
iambriccardo Jul 17, 2024
cc0596d
Fix
iambriccardo Jul 18, 2024
1d3b3e8
Fix
iambriccardo Jul 18, 2024
fa67244
Fix
iambriccardo Jul 18, 2024
08a6e85
Fix
iambriccardo Jul 18, 2024
bd9e159
Fix
iambriccardo Jul 18, 2024
450311d
Fix
iambriccardo Jul 18, 2024
707cb07
Fix
iambriccardo Jul 18, 2024
8670f0d
Fix
iambriccardo Jul 18, 2024
dfc5a9b
Fix
iambriccardo Jul 18, 2024
464ca43
Fix
iambriccardo Jul 18, 2024
e2ca3d4
Merge
iambriccardo Jul 18, 2024
05b1317
Fix
iambriccardo Jul 18, 2024
6823d7d
Update relay-server/src/endpoints/common.rs
iambriccardo Jul 19, 2024
78abada
Update relay-server/src/utils/memory.rs
iambriccardo Jul 19, 2024
8755d87
Update relay-server/src/utils/memory.rs
iambriccardo Jul 19, 2024
f0f2c9f
Update relay-server/src/utils/memory.rs
iambriccardo Jul 19, 2024
aafba46
Update relay-server/src/utils/memory.rs
iambriccardo Jul 19, 2024
998fdf2
Update relay-server/src/utils/memory.rs
iambriccardo Jul 19, 2024
aa1f39e
Update relay-server/src/utils/memory.rs
iambriccardo Jul 19, 2024
735d52c
Improve
iambriccardo Jul 19, 2024
f434135
Merge
iambriccardo Jul 19, 2024
d22dfa6
Merge
iambriccardo Jul 19, 2024
9204a7f
Merge
iambriccardo Jul 19, 2024
8a70bf2
Changelog
iambriccardo Jul 19, 2024
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
Prev Previous commit
Next Next commit
Improve
  • Loading branch information
iambriccardo committed Jul 16, 2024
commit 719bea7fbc23e9e2e2a8a19b327b6b04efbff2a2
35 changes: 2 additions & 33 deletions relay-server/src/services/health_check.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use std::sync::Arc;

use relay_config::Config;
use relay_statsd::metric;
use relay_system::{Addr, AsyncResponse, Controller, FromMessage, Interface, Sender, Service};
use std::future::Future;
use sysinfo::{MemoryRefreshKind, System};
use sysinfo::System;
use tokio::sync::watch;
use tokio::time::{timeout, Instant};

use crate::services::metrics::{AcceptsMetrics, Aggregator};
use crate::services::project_cache::{ProjectCache, SpoolHealth};
use crate::services::upstream::{IsAuthenticated, UpstreamRelay};
use crate::statsd::{RelayGauges, RelayTimers};
use crate::statsd::RelayTimers;
use crate::utils::MemoryStat;

/// Checks whether Relay is alive and healthy based on its variant.
Expand Down Expand Up @@ -268,34 +267,4 @@ mod tests {
let s = [].into_iter().collect();
assert!(matches!(s, Status::Healthy));
}

#[test]
fn test_memory_used_percent_total_0() {
let memory = Memory {
used: 100,
total: 0,
rss: 0,
};
assert_eq!(memory.used_percent(), 1.0);
}

#[test]
fn test_memory_used_percent_zero() {
let memory = Memory {
used: 0,
total: 100,
rss: 0,
};
assert_eq!(memory.used_percent(), 0.0);
}

#[test]
fn test_memory_used_percent_half() {
let memory = Memory {
used: 50,
total: 100,
rss: 0,
};
assert_eq!(memory.used_percent(), 0.5);
}
}
29 changes: 28 additions & 1 deletion relay-server/src/utils/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl fmt::Debug for MemoryStat {

#[cfg(test)]
mod tests {
use crate::utils::MemoryStat;
use crate::utils::{Memory, MemoryStat};

#[test]
fn test_has_enough_memory() {
Expand All @@ -126,4 +126,31 @@ mod tests {
let memory_stat = MemoryStat::new(0.0);
assert!(!memory_stat.has_enough_memory());
}

#[test]
fn test_memory_used_percent_total_0() {
let memory = Memory {
used: 100,
total: 0,
};
assert_eq!(memory.used_percent(), 1.0);
}

#[test]
fn test_memory_used_percent_zero() {
let memory = Memory {
used: 0,
total: 100,
};
assert_eq!(memory.used_percent(), 0.0);
}

#[test]
fn test_memory_used_percent_half() {
let memory = Memory {
used: 50,
total: 100,
};
assert_eq!(memory.used_percent(), 0.5);
}
}
Loading