2
0
Эх сурвалжийг харах

Server interceptors micro optimisation (#1091)

Motivation:

In the server interceptor pipeline, the head forwards inbound events and
the tail forwards outbound events, yet we start from the index of the
head/tail, rather than the index after.

Modifications:

- start one index beyond the head/tail rather than at the head/tail

Result:

A small (0.1%) decrease in instructions executed in the
embedded_server_unary_10k_small_requests benchmark.
George Barnett 4 жил өмнө
parent
commit
22966ff4b2

+ 2 - 2
Sources/GRPC/Interceptor/ServerInterceptorPipeline.swift

@@ -134,7 +134,7 @@ internal final class ServerInterceptorPipeline<Request, Response> {
   /// - Important: This *must* to be called from the `eventLoop`.
   /// - Important: This *must* to be called from the `eventLoop`.
   @inlinable
   @inlinable
   internal func receive(_ part: GRPCServerRequestPart<Request>) {
   internal func receive(_ part: GRPCServerRequestPart<Request>) {
-    self._invokeReceive(part, onContextAtIndex: self._headIndex)
+    self.invokeReceive(part, fromContextAtIndex: self._headIndex)
   }
   }
 
 
   /// Invoke receive on the appropriate context when called from the context at the given index.
   /// Invoke receive on the appropriate context when called from the context at the given index.
@@ -193,7 +193,7 @@ internal final class ServerInterceptorPipeline<Request, Response> {
   /// - Important: This *must* to be called from the `eventLoop`.
   /// - Important: This *must* to be called from the `eventLoop`.
   @inlinable
   @inlinable
   internal func send(_ part: GRPCServerResponsePart<Response>, promise: EventLoopPromise<Void>?) {
   internal func send(_ part: GRPCServerResponsePart<Response>, promise: EventLoopPromise<Void>?) {
-    self._invokeSend(part, promise: promise, onContextAtIndex: self._tailIndex)
+    self.invokeSend(part, promise: promise, fromContextAtIndex: self._tailIndex)
   }
   }
 
 
   /// Invoke send on the appropriate context when called from the context at the given index.
   /// Invoke send on the appropriate context when called from the context at the given index.