ice
ice copied to clipboard
Cache Swift Connection objects
Right now, we create a new Swift Connection object each time we create a new Current during dispatch.
We should consider caching this connection object so we don't have to recreate it every time.
One possibility would be to install a close callback on the C++ object which holds the Swift object in the closure.
We should also maybe measure the performance to see if it really makes a big difference.
I tried with a modified latency demo and did not find a noticeable difference with/without Swift connection caching. With this demo, there is a single client that establishes one connection and makes many ice_ping
calls to the server.
class PingI: Ice.ObjectI<PingTraits>, Ping {
override func ice_ping(current: Ice.Current) {
if _con == nil {
_con = current.con
}
}
private var _con: Ice.Connection?
}