Skip to content

Commit

Permalink
add GC stress scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Nov 8, 2023
1 parent 2873004 commit 9b0e2a1
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/python/gc_stress/many_large_many_rows_recordings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Stress test for cross-recording garbage collection.
Logs many large recordings that contain a lot of large rows.
Usage:
- Start a Rerun Viewer in release mode with 2GiB of memory limit:
`cargo r -p rerun-cli --release --no-default-features --features native_viewer -- --memory-limit 2GiB`
- Open the memory panel to see what's going on.
- Run this script.
- You should see recordings coming in and going out in a ringbuffer-like rolling fashion.
"""
from __future__ import annotations

import rerun as rr
from numpy.random import default_rng

rng = default_rng(12345)

for i in range(0, 20000000):
rr.init("rerun_example_recording_gc", recording_id=f"image-rec-{i}", spawn=True)
for j in range(0, 10000):
positions = rng.uniform(-5, 5, size=[10000000, 3])
colors = rng.uniform(0, 255, size=[10000000, 3])
radii = rng.uniform(0, 1, size=[10000000])
rr.log("points", rr.Points3D(positions, colors=colors, radii=radii))
32 changes: 32 additions & 0 deletions tests/python/gc_stress/many_large_single_row_recordings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Stress test for cross-recording garbage collection.
Logs many large recordings that contain a single large row.
Usage:
- Start a Rerun Viewer in release mode with 2GiB of memory limit:
`cargo r -p rerun-cli --release --no-default-features --features native_viewer -- --memory-limit 2GiB`
- Open the memory panel to see what's going on.
- Run this script.
- You should see recordings coming in and going out in a ringbuffer-like rolling fashion.
"""
from __future__ import annotations

import time

import rerun as rr
from numpy.random import default_rng

rng = default_rng(12345)

for i in range(0, 20000000):
rr.init("rerun_example_recording_gc", recording_id=f"recording-gc-rec-{i}", spawn=True)

positions = rng.uniform(-5, 5, size=[10000000, 3])
colors = rng.uniform(0, 255, size=[10000000, 3])
radii = rng.uniform(0, 1, size=[10000000])
rr.log("points", rr.Points3D(positions, colors=colors, radii=radii))

# Sleep because large rows will absolutely destroy the viewer.
# TODO(#4183): Investigate this.
time.sleep(1)
27 changes: 27 additions & 0 deletions tests/python/gc_stress/many_medium_sized_many_rows_recordings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Stress test for cross-recording garbage collection.
Logs many medium-sized recordings that contain a lot of small-ish rows.
Usage:
- Start a Rerun Viewer in release mode with 500MiB of memory limit:
`cargo r -p rerun-cli --release --no-default-features --features native_viewer -- --memory-limit 500MiB`
- Open the memory panel to see what's going on.
- Run this script.
- You should see recordings coming in and going out in a ringbuffer-like rolling fashion.
"""
from __future__ import annotations

import rerun as rr
from numpy.random import default_rng

rng = default_rng(12345)

for i in range(0, 20000000):
rr.init("rerun_example_recording_gc", recording_id=f"image-rec-{i}", spawn=True)
for j in range(0, 10000):
rr.set_time_sequence("frame", j)
positions = rng.uniform(-5, 5, size=[1000, 3])
colors = rng.uniform(0, 255, size=[1000, 3])
radii = rng.uniform(0, 1, size=[1000])
rr.log("points", rr.Points3D(positions, colors=colors, radii=radii))
32 changes: 32 additions & 0 deletions tests/python/gc_stress/many_medium_sized_single_row_recordings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Stress test for cross-recording garbage collection.
Logs many medium-sized recordings that contain a single medium-sized row.
Usage:
- Start a Rerun Viewer in release mode with 200MiB of memory limit:
`cargo r -p rerun-cli --release --no-default-features --features native_viewer -- --memory-limit 200MiB`
- Open the memory panel to see what's going on.
- Run this script.
- You should see recordings coming in and going out in a ringbuffer-like rolling fashion.
"""
from __future__ import annotations

import time

import rerun as rr
from numpy.random import default_rng

rng = default_rng(12345)

for i in range(0, 20000000):
rr.init("rerun_example_recording_gc", recording_id=f"recording-gc-rec-{i}", spawn=True)

positions = rng.uniform(-5, 5, size=[10000, 3])
colors = rng.uniform(0, 255, size=[10000, 3])
radii = rng.uniform(0, 1, size=[10000])
rr.log("points", rr.Points3D(positions, colors=colors, radii=radii))

# Sleep so we don't run out of TCP sockets.
# Timings might need to be adjusted depending on your hardware.
time.sleep(0.05)

0 comments on commit 9b0e2a1

Please sign in to comment.