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

Viewer should be able to stream in .rrd files whilst they're still being written to #4056

Closed
teh-cmc opened this issue Oct 28, 2023 · 3 comments
Assignees
Labels
🧑‍💻 dev experience developer experience (excluding CI) 📺 re_viewer affects re_viewer itself user-request This is a pressing issue for one of our users

Comments

@teh-cmc
Copy link
Member

teh-cmc commented Oct 28, 2023

We can log to files in a streaming fashion already today:

import rerun as rr
import time

rr.init("rerun_example_points3d_simple")
rr.save("/tmp/stream.rrd")

for i in range(0, 100000):
    rr.set_time_sequence("frame", i)
    rr.log("points", rr.TextLog(f"frame {i}"))
    time.sleep(0.2)

That's great, but we cannot visualize file recordings in a streaming fashion:

$ rerun /tmp/stream.rrd  # will only show what it is there _right now_
@teh-cmc teh-cmc added 🧑‍💻 dev experience developer experience (excluding CI) 📺 re_viewer affects re_viewer itself user-request This is a pressing issue for one of our users labels Oct 28, 2023
@emilk emilk changed the title Viewer should read files in a streaming fashion Viewer should be able to stream in .rrd files whilst they're still being written to Apr 24, 2024
@nikolausWest
Copy link
Member

I just tried this with Rerun 0.18.2. The viewer can read from /tmp/stream.rrd while the script logs to it, but it only reads the data that was present when the viewer opened and doesn't continue to read new data as it comes in

@emilk emilk assigned emilk and unassigned emilk Sep 19, 2024
@zehiko
Copy link
Contributor

zehiko commented Sep 20, 2024

Quick summary of the issue:

  • message Decoder that is used as an Iterator when reading the .rrd file is unaware of the fact file may still be written to, hence when it sees EoF from the reader, it concludes there's no more data and the Iterator will return None and reading and decoding stops.

Had a quick chat with Emil on the path forward and we discussed following steps:

  1. add retrying for file-based reader (we can either make Decoder aware of the file or we can create a RetryableBuffReader and pass it to the Decoder. Retrying is just dumb loop with sleep and we retry indefinitely.
  2. instead of sleep + retry, we rely on notify, so retrying is slightly smarter
  3. we add a new message header that signifies "rrd file end" and is written by the FileSink and then we make Decoder aware of the header and we retry if we get EoF from the reader, but we still haven't seen the end file marker. Once we see end of file message / marker, decoder iterator is done. Header can be all-zeros header for example. Retry strategy in this case can be:
  • stop after first time you see end of file marker message
  • block and read forever
  • try to see if there's more data after end of file marker message
    (these are useful for cases when the user concats multiple files together manually)

@zehiko zehiko self-assigned this Sep 20, 2024
zehiko added a commit that referenced this issue Sep 20, 2024
We stop streaming data from an .rrd file that is still being written
once we reach EOF. As a first simple remediation we introduce a
retryable reader that will try to read more data from the file
indefinitely.
zehiko added a commit that referenced this issue Sep 20, 2024
We stop streaming data from an .rrd file that is still being written
once we reach EOF. As a first simple remediation we introduce a
retryable reader that will try to read more data from the file
indefinitely.
zehiko added a commit that referenced this issue Sep 24, 2024
Ensure we continue streaming .rrd file in the viewer as it's being written to (#4056)

We introduce a retryable file reader that is used when reading .rrd
files that are still being written and it simply ignored the EoF
condition. We also introduce an end-of-stream message header that
ensures we stop decoding (and endlessly trying to read the file) message
stream once we see this header.

.rrd files generated with using a prior sdk version should work just
fine, the only downside is that while the viewer is running there will
be an open file handle for that file since no end-of-stream message will
exist.
@zehiko
Copy link
Contributor

zehiko commented Sep 25, 2024

Fixed as part of PR #7475.

@zehiko zehiko closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍💻 dev experience developer experience (excluding CI) 📺 re_viewer affects re_viewer itself user-request This is a pressing issue for one of our users
Projects
None yet
Development

No branches or pull requests

4 participants