I have done the following
Steps to reproduce
- Run any
container CLI command (e.g. container run ... or container system start).
- Every interaction with the daemon via
ContainerXPC creates XPCMessage or XPCServer.
- In
XPCMessage.swift, XPCServer.swift, and ProgressUpdateClient.swift, NSLock instances wrap individual accessor and lifecycle calls.
Problem description
Every individual call to xpc_dictionary_get_* / xpc_dictionary_set_* is wrapped in an NSLock.withLock. However:
- No multi-step atomic operations exist (each lock wraps exactly one accessor).
- The XPC runtime already serializes connection activity. As stated in
xpc_connection_create(3), every connection has an associated dispatch queue, and all activity (including event handler invocations) takes place on a distinct serial target queue.
- Writes target message-local dictionaries that are thread-confined before transmission. Concurrent reads are safe.
This redundant synchronization incurs unnecessary lock/unlock CPU overhead (compare-and-swap and memory fencing instructions) for every single XPC interaction.
Environment
- OS: macOS 27.0 (Build 26A5368g)
- Xcode: 26.0.1 (Build 17A400)
- Container: 0.34.0
I have done the following
Steps to reproduce
containerCLI command (e.g.container run ...orcontainer system start).ContainerXPCcreatesXPCMessageorXPCServer.XPCMessage.swift,XPCServer.swift, andProgressUpdateClient.swift,NSLockinstances wrap individual accessor and lifecycle calls.Problem description
Every individual call to
xpc_dictionary_get_*/xpc_dictionary_set_*is wrapped in anNSLock.withLock. However:xpc_connection_create(3), every connection has an associated dispatch queue, and all activity (including event handler invocations) takes place on a distinct serial target queue.This redundant synchronization incurs unnecessary lock/unlock CPU overhead (compare-and-swap and memory fencing instructions) for every single XPC interaction.
Environment