-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modification: It can be helpful to track the state of the connection pool as a whole over time to understand how heavily utilised it is. This is awkward to do at the moment because delegate functions are called on connection state changes. There's also no insight into how many RPCs are queued waiting for a stream. Modifications: - Add a 'GRPCSubPoolStats' type capturing stats from each subpool. This includes: - counts of connections in each state - streams in use - streams which are free to use - number of rpcs waiting for a stream - Add a delegate method which is passed an array of subpool stats (one per subpool) and add a no-op default implementation. - Add configuration to determine how frequently stats are collected Result: More insight into pool stats
- Loading branch information
Showing
12 changed files
with
303 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2024, gRPC Authors All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Atomics | ||
|
||
enum RawID { | ||
private static let source = ManagedAtomic(0) | ||
|
||
static func next() -> Int { | ||
self.source.loadThenWrappingIncrement(ordering: .relaxed) | ||
} | ||
} | ||
|
||
/// The ID of a connection pool. | ||
public struct GRPCConnectionPoolID: Hashable, Sendable, CustomStringConvertible { | ||
private var rawValue: Int | ||
|
||
private init(rawValue: Int) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
public static func next() -> Self { | ||
return Self(rawValue: RawID.next()) | ||
} | ||
|
||
public var description: String { | ||
"ConnectionPool(\(self.rawValue))" | ||
} | ||
} | ||
|
||
/// The ID of a sub-pool in a connection pool. | ||
public struct GRPCSubPoolID: Hashable, Sendable, CustomStringConvertible { | ||
private var rawValue: Int | ||
|
||
private init(rawValue: Int) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
public static func next() -> Self { | ||
return Self(rawValue: RawID.next()) | ||
} | ||
|
||
public var description: String { | ||
"SubPool(\(self.rawValue))" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.