Skip to content

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

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

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

Conversation

@maurycy

@maurycy maurycy commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

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 conn in self._connections:
self._flush_connection(conn)

def _dispatch(self, conn, command):

@maurycy maurycy May 17, 2026 •

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 / snapshot yet.

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

@maurycy maurycy May 17, 2026 •

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.

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.")

@maurycy maurycy May 17, 2026 •

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.

@pablogsal Proper communication with children would be very complex. Maybe we can just 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

maurycy commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@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.

self.close_after_write = False


class ControlServer:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR @maurycy, this looks really interesting. I think we should introduce an abstraction here to be able to implement other transport protocols. Most importantly, I think we will need named pipes on Windows, but it would also allow things like adding TCP transport later down the line.

I spoke with @pablogsal briefly about this and we agreed that ideally we'd have Windows support also included in this change. Do you think you could look into that? I can run Windows in a VM and may be able to help out, but I'm not sure when I'll be able to get around to it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 on the abstraction, it would be great to have everything here. I’d also love to see the snapshot command in this change.

@maurycy maurycy May 22, 2026 •

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.

@ivonastojanovic @lkollar Thank you for the kind words. :) These are great ideas! I will get back to it on Monday. I will try to take a stab at named pipe over the weekend

@maurycy maurycy May 31, 2026 •

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've got drowned by other things, hence the delay.

@chris-eibl Would you be willing to pair on this? :-) I can open a PR in my fork.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure thing!

I am a low on time atm, but should get better mid next week.

I think we should introduce an abstraction

Are you going to prepare the abstraction so I can concentrate on the named pipes on Windows?

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 30, 2026
@maurycy

maurycy commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the reminder, bot. I will prioritize addressing the points raised during the review.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Sep 5, 2026
@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants