Skip to content

new_installer: Windows IPC support#52483

Open
johnwparent wants to merge 8 commits into
spack:developfrom
johnwparent:win/installer-ipc
Open

new_installer: Windows IPC support#52483
johnwparent wants to merge 8 commits into
spack:developfrom
johnwparent:win/installer-ipc

Conversation

@johnwparent
Copy link
Copy Markdown
Contributor

Based on #52482

Facillitates IPC on Windows with the new installer via sockets

Breaks ChildInfo down into subclasses, with the posix side untouched and the windows side output/state use socket.socketpair().
Registers socket objects and a WindowsSentinelBridge.

WindowsSentinelBridge wraps a thread that calls proc.join() and writes a byte to a socket to wake the selector when the process exits (Windows cannot register process sentinels with a selector directly).

read_from_key() abstracts reads across fds and sockets: uses recv() when the selector key's fileobj has it, os.read() otherwise. This lets _handle_child_logs/state use one invocation for both platforms.

tee() is split into _tee_posix() (same as before) and _tee_windows() (thread-based control reader using sockets).

State buffer and decoder refactored to be keyed by pid rather than fd, and _handle_child_state extracts _process_state_string() for clarity.
Output is processed to support multibyte chars

JobServer is essentially disabled on Windows (to be done in later work, likely post release unless we get this in quickly somehow)

@johnwparent johnwparent changed the title Win/installer ipc new_installer: Windows IPC support Jun 3, 2026
@johnwparent johnwparent force-pushed the win/installer-ipc branch 4 times, most recently from 864719f to 0c77060 Compare June 4, 2026 18:44
@github-actions github-actions Bot added ci Issues related to Continuous Integration style labels Jun 4, 2026
@github-actions github-actions Bot added the docs label Jun 4, 2026
@johnwparent johnwparent force-pushed the win/installer-ipc branch 2 times, most recently from ae1c104 to 6860526 Compare June 4, 2026 23:37
Comment thread lib/spack/spack/new_installer_base.py Outdated
"""Abstract base classes for new_installer: TUI terminal state, IPC channels, and job scheduling.

Kept as a leaf module (no imports from new_installer.py or the platform modules) to avoid circular
dependencies — new_installer_posix and new_installer_windows both import from here."""
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.

Can you do a scan over this yourself and remove Claudisms? We use ascii practically everywhere.

Copy link
Copy Markdown
Contributor Author

@johnwparent johnwparent Jun 5, 2026

Choose a reason for hiding this comment

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

Ah I absolutely forgot to check the module level docstrings, thanks.
Will also of course go over the rest of the changes as well.

Comment thread lib/spack/spack/new_installer.py Outdated
Comment on lines +2095 to +2098
# group conditions for readability
wake_on_jobserver = (
self.pending_builds
and self.capacity
and not blocked
or not jobserver.has_target_parallelism()
)
if wake_on_jobserver and jobserver.r not in selector.get_map():
selector.register(jobserver.r, selectors.EVENT_READ, "jobserver")
elif not wake_on_jobserver and jobserver.r in selector.get_map():
selector.unregister(jobserver.r)
self.pending_builds and self.capacity and not blocked
) or not jobserver.has_target_parallelism()
Copy link
Copy Markdown
Member

@haampie haampie Jun 5, 2026

Choose a reason for hiding this comment

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

Can you please leave out every unnecessary change in a 1000 line diff? This is not relevant to your changes, so leave it like it was. It's doesn't improve readability to me, and just takes more time in review.

Copy link
Copy Markdown
Contributor Author

@johnwparent johnwparent Jun 5, 2026

Choose a reason for hiding this comment

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

Ok, I did make this change deliberately because I thought it made it more readable but I'll revert since you're generally more right about these things

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.

Well, it's personal taste and it could've been either, for this PR it's just additional things to double-check.

Facillitates IPC on Windows with the new installer via sockets

Breaks ChildInfo down into subclasses, with the posix side untouched
and the windows side output/state use socket.socketpair().
Registers socket objects and a WindowsSentinelBridge.

WindowsSentinelBridge wraps a thread that calls proc.join() and
writes a byte to a socket to wake the selector when the process exits
(Windows cannot register process sentinels with a selector directly).

read_from_key() abstracts reads across fds and sockets: uses recv() when
the selector key's fileobj has it, os.read() otherwise. This lets
_handle_child_logs/state use one invocation for both platforms.

tee() is split into _tee_posix() (same as before) and _tee_windows()
(thread-based control reader using sockets).

State buffer and decoder refactored to be keyed by pid rather than fd, and
_handle_child_state extracts _process_state_string() for clarity.
Output is processed to support multibyte chars

JobServer is essentially disabled on Windows

Signed-off-by: John Parent <john.parent@kitware.com>
Move base classes to leaf module for per platform deriviation

Signed-off-by: John Parent <john.parent@kitware.com>
No functional changes, just code reoganization

Signed-off-by: John Parent <john.parent@kitware.com>
…dule

Subclasses shared IPC logic with windows specific implementations

Signed-off-by: John Parent <john.parent@kitware.com>
Alias classes to avoid dispatch methods
remove IS_WINDOWs usages

Signed-off-by: John Parent <john.parent@kitware.com>
Signed-off-by: John Parent <john.parent@kitware.com>
Signed-off-by: John Parent <john.parent@kitware.com>
Signed-off-by: John Parent <john.parent@kitware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Issues related to Continuous Integration docs style unit-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants