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

Limit server memory #4636

Merged
merged 10 commits into from Jan 4, 2024
Merged

Limit server memory #4636

merged 10 commits into from Jan 4, 2024

Conversation

emilk
Copy link
Member

@emilk emilk commented Jan 2, 2024

What

Limit the amount of RAM used by the WebSocket server.

The WebSocket server will buffer all log data in memory so that late connecting viewers will get all the data.
Previously this would just eat more and more RAM until the server crashed.

There is now a limit, which default to 25% of the RAM. That is, the server will try to keep its own memory use under that limit. Note that this acts different from the viewer's --memory-limit which throws away old data when the total process memory exceeds the limit.

The memory limit is set by the new --server-memory-limit argument to rerun, or by argument to the serve functions. Note that I opted for a different argument for the server limit than for the viewer memory limit. This is partially because it should be a lot less, and partially because the limit acts differently (it is a local budget, rather than a total process limit).

While working on this I noticed we don't have a serve function in C++, so I created an issue for that: #4638

The default limit of 25% can be discussed. It leaves the other 75% for the viewer (though if the viewer is in a browser, it will likely be using much less).

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@emilk emilk added the 📉 performance Optimization, memory use, etc label Jan 2, 2024
@emilk emilk marked this pull request as ready for review January 2, 2024 15:54
@teh-cmc teh-cmc self-requested a review January 3, 2024 08:25
crates/re_memory/src/memory_limit.rs Show resolved Hide resolved
crates/re_sdk/src/recording_stream.rs Outdated Show resolved Hide resolved
crates/re_ws_comms/src/server.rs Outdated Show resolved Hide resolved
crates/re_ws_comms/src/server.rs Outdated Show resolved Hide resolved
crates/re_ws_comms/src/server.rs Outdated Show resolved Hide resolved
rerun_py/rerun_sdk/rerun/sinks.py Outdated Show resolved Hide resolved
rerun_py/src/python_bridge.rs Outdated Show resolved Hide resolved
emilk and others added 7 commits January 3, 2024 11:27
Co-authored-by: Clement Rey <cr.rey.clement@gmail.com>
Co-authored-by: Clement Rey <cr.rey.clement@gmail.com>
Co-authored-by: Clement Rey <cr.rey.clement@gmail.com>
@emilk emilk merged commit 51cbf5f into main Jan 4, 2024
40 checks passed
@emilk emilk deleted the emilk/limit-server-memory branch January 4, 2024 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 📉 performance Optimization, memory use, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants