Skip to content

Commit 2a480d0

Browse files
eDO Teammobile-devx-github-bot
authored andcommitted
Update QoS of eDO socket handler queue to USER_INITIATED.
This prevents priority inversion issues enforced by the thread performance checker. PiperOrigin-RevId: 888796062
1 parent 9710c4e commit 2a480d0

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

Channel/Sources/EDOSocketChannel.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,16 @@ - (instancetype)initWithHandlerQueue:(dispatch_queue_t)handlerQueue {
6767
if (self) {
6868
// For internal IO and event handlers, it is equivalent to creating it as a serial queue as they
6969
// are not reentrant and only one block will be scheduled by dispatch io and dispatch source.
70-
_handlerQueue =
71-
handlerQueue
72-
?: dispatch_queue_create("com.google.edo.socketChannel.handler", DISPATCH_QUEUE_SERIAL);
70+
if (handlerQueue) {
71+
_handlerQueue = handlerQueue;
72+
} else {
73+
// Use QOS_CLASS_USER_INITIATED as the default because eDO communication is often in the
74+
// critical path of user-driven test execution, and using a lower QoS can lead to priority
75+
// inversion issues.
76+
dispatch_queue_attr_t attributes = dispatch_queue_attr_make_with_qos_class(
77+
DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, 0);
78+
_handlerQueue = dispatch_queue_create("com.google.edo.socketChannel.handler", attributes);
79+
}
7380
}
7481
return self;
7582
}

Service/Tests/FunctionalTests/EDOServiceUIBlockTest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ - (void)testBlockResolveToLocalAddress {
156156

157157
// Sending block to remote process through background eDO host.
158158
dispatch_sync(backgroundQueue, ^{
159-
pthread_set_qos_class_self_np(QOS_CLASS_DEFAULT, 0);
159+
pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0);
160160
remoteDummy.block = localBlock;
161161
});
162162

Service/Tests/FunctionalTests/EDOServiceUITest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ - (void)testTemporaryServiceHandlesRecursiveCall {
226226
EDOTestDummy *remoteDummy = [EDOClientService rootObjectWithPort:EDOTEST_APP_SERVICE_PORT];
227227
// Align QoS with eDO internal threads to avoid priority inversion.
228228
dispatch_queue_attr_t attr =
229-
dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0);
229+
dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, 0);
230230
dispatch_queue_t testQueue = dispatch_queue_create("com.google.edotest", attr);
231231

232232
XCTestExpectation *expectation = [self expectationWithDescription:@"recursive call completes."];

0 commit comments

Comments
 (0)