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

Changed spawn() and the rerun script to call into rerun_bindings (12x startup time improvement) #4053

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion rerun_py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ homepage = "https://www.rerun.io"
repository = "https://github.com/rerun-io/rerun"

[project.scripts]
rerun = "rerun.__main__:main"
rerun = "rerun_bindings:main"

[tool.ruff]
# https://beta.ruff.rs/docs/configuration/
Expand Down
8 changes: 5 additions & 3 deletions rerun_py/rerun_sdk/rerun/__main__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
"""See `python3 -m rerun --help`."""
from __future__ import annotations

import sys
import rerun_bindings as bindings

from rerun import bindings, unregister_shutdown
from rerun import unregister_shutdown


def main() -> None:
# We don't need to call shutdown in this case. Rust should be handling everything
# TODO(ab): we only do that because __init__.py was loaded and register_shutdown() was called.
# Ideally, nothing should be loaded at all but `rerun_bindings` when we run `python3 -m rerun`.
unregister_shutdown()
exit(bindings.main(sys.argv))
exit(bindings.main())
abey79 marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion rerun_py/rerun_sdk/rerun_demo/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def run_structure_from_motion(args):
print(f"No demo file found at {rrd_file}. Package was built without demo support", file=sys.stderr)
exit(1)
else:
exit(bindings.main([sys.argv[0], str(rrd_file)] + serve_opts))
sys.argv = [sys.argv[0], str(rrd_file)] + serve_opts
exit(bindings.main())


def main() -> None:
Expand Down
5 changes: 4 additions & 1 deletion rerun_py/src/python_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ fn global_web_viewer_server(
}

#[pyfunction]
fn main(py: Python<'_>, argv: Vec<String>) -> PyResult<u8> {
fn main(py: Python<'_>) -> PyResult<u8> {
let sys = py.import("sys")?;
let argv: Vec<String> = sys.getattr("argv")?.extract()?;
abey79 marked this conversation as resolved.
Show resolved Hide resolved

let build_info = re_build_info::build_info!();
let call_src = rerun::CallSource::Python(python_version(py));
tokio::runtime::Builder::new_multi_thread()
Expand Down
Loading