-
Notifications
You must be signed in to change notification settings - Fork 92
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
Conversation
b7decf2
to
05b1317
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few nits, but looks good overall! Let's maybe wait until Monday before we deploy :)
relay-server/src/utils/memory.rs
Outdated
use sysinfo::{MemoryRefreshKind, System}; | ||
|
||
/// Count after which the [`MemoryStat`] data will be refreshed. | ||
const UPDATE_TIME_THRESHOLD_MS: u64 = 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do that, I could put it under the health key.
Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
@@ -220,7 +222,7 @@ impl ServiceState { | |||
); | |||
ProjectCacheService::new( | |||
config.clone(), | |||
buffer_guard.clone(), | |||
MemoryChecker::new(memory_stat.clone(), config.clone()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating new memory checkers, we could just clone a single one and pass that around and internally create the MemoryStat
in the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also do that yes, we will likely not use MemoryStat
in isolation, so it's fair to implement it this way.
This PR implements a new shared memory state
MemoryStat
which allows polling memory usage from multiple threads.This new mechanism is implemented in place of the old
BufferGuard
which was statically maxing out the number of possible envelopes that go through Relay.Thanks to the new mechanism, the following code was removed:
BufferGuard
and all related codeSemaphore
and all related codeSome tests that tested permits were also removed. We are planning a new implementation of the spooler, in which we will figure out a way to properly test memory limits.
Closes: https://github.com/getsentry/team-ingest/issues/367