Skip to content

gh-145411: Add runtime (now: unix only) control to Tachyon#149958

Open
maurycy wants to merge 5 commits into
python:mainfrom
maurycy:tachyon-runtime-socket
Open

gh-145411: Add runtime (now: unix only) control to Tachyon#149958
maurycy wants to merge 5 commits into
python:mainfrom
maurycy:tachyon-runtime-socket

Conversation

@maurycy
Copy link
Copy Markdown
Contributor

@maurycy maurycy commented May 17, 2026

Only unix: for starters:

Control socket:
  --control URI         control socket URI (unix:<path>) (default: None)

Supported commands are enable, disable, ping, status and quit. Each command is confirmed with either ok or err.

Example session:

[1] 2026-05-17T21:18:38.400172000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % sudo -E ./python.exe -m profiling.sampling run --control unix:/tmp/tachyon.sock -r 666khz -m test test_asyncio &>/dev/null &
[1] 84494
2026-05-17T21:18:41.130015000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'ping' | sudo nc -U /tmp/tachyon.sock
ok
2026-05-17T21:18:42.759758000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'status' | sudo nc -U /tmp/tachyon.sock
ok enabled=True 
2026-05-17T21:18:44.875693000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'enable' | sudo nc -U /tmp/tachyon.sock
ok
2026-05-17T21:18:46.871140000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'disable' | sudo nc -U /tmp/tachyon.sock
ok
2026-05-17T21:18:48.756932000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'enable' | sudo nc -U /tmp/tachyon.sock
ok
2026-05-17T21:18:49.083766000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'zażółć gęślą jaźn' | sudo nc -U /tmp/tachyon.sock
err unknown_command
2026-05-17T21:18:50.670507000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (tachyon-runtime-socket ed77e71) % echo -e 'quit' | sudo nc -U /tmp/tachyon.sock
ok
[1]  + done       sudo -E ./python.exe -m profiling.sampling run --control  -r 666khz -m test 

Closes #149958

if not timeout:
return
if control_server is not None:
control_server.poll(timeout=timeout)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the trick.

if conn in self._connections:
self._flush_connection(conn)

def _dispatch(self, conn, command):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No dump yet.

if getattr(args, 'control', None) is not None:
if args.subprocesses:
parser.error("--control is incompatible with --subprocesses.")
if os.name == "nt":
Copy link
Copy Markdown
Contributor Author

@maurycy maurycy May 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I don't have access to Windows.


if getattr(args, 'control', None) is not None:
if args.subprocesses:
parser.error("--control is incompatible with --subprocesses.")
Copy link
Copy Markdown
Contributor Author

@maurycy maurycy May 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pablogsal The communication with children would be complex. Maybe we can use signals for enabling and disabling them.

from .errors import ControlError, ControlURIError


class ProfilerControl:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not want to inject this into LiveCollector but the direction is clear.

@maurycy
Copy link
Copy Markdown
Contributor Author

maurycy commented May 17, 2026

@maurycy maurycy changed the title gh-145411: Add socket control to Tachyon gh-145411: Add runtime (now: unix only) control to Tachyon May 17, 2026

with _get_child_monitor_context(args, args.pid):
server = None
with ExitStack() as stack:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping should-be-soon-to-be-added signal (SIGUSR1, SIGUSR2 for enabling or disabling?) support in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant