This is an automated email from the ASF dual-hosted git repository.
igodwin pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new cd6a95f GEODE-7061: Reduce conns created during high load with many
threads
cd6a95f is described below
commit cd6a95f54dad874d1075e5f3eecf073113044098
Author: Alberto Gomez <[email protected]>
AuthorDate: Tue Aug 27 18:42:46 2019 +0200
GEODE-7061: Reduce conns created during high load with many threads
- Process each TcrConnection as soon as it is evaluated
---
cppcache/src/ThinClientPoolDM.cpp | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/cppcache/src/ThinClientPoolDM.cpp
b/cppcache/src/ThinClientPoolDM.cpp
index 7f798f6..2d2fef9 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -411,11 +411,17 @@ void
ThinClientPoolDM::cleanStaleConnections(std::atomic<bool>& isRunning) {
TcrConnection* conn = nullptr;
- std::vector<TcrConnection*> savelist;
std::vector<TcrConnection*> removelist;
std::set<ServerLocation> excludeServers;
- while ((conn = getNoWait()) != nullptr && isRunning) {
+ auto availableConns = size();
+ auto savedConns = 0;
+
+ for (unsigned int i = 0; (i < availableConns) && isRunning; i++) {
+ conn = getNoWait();
+ if (conn == nullptr) {
+ break;
+ }
if (canItBeDeleted(conn)) {
removelist.push_back(conn);
} else if (conn) {
@@ -425,19 +431,15 @@ void
ThinClientPoolDM::cleanStaleConnections(std::atomic<bool>& isRunning) {
if (nextIdle > std::chrono::seconds::zero() && nextIdle < _nextIdle) {
_nextIdle = nextIdle;
}
- savelist.push_back(conn);
+ put(conn, false);
+ savedConns++;
}
}
- auto replaceCount =
- m_attrs->getMinConnections() - static_cast<int>(savelist.size());
+ auto replaceCount = m_attrs->getMinConnections() - savedConns;
- LOGDEBUG("Preserving %d connections", savelist.size());
+ LOGDEBUG("Preserving %d connections", savedConns);
- for (auto savedconn : savelist) {
- put(savedconn, false);
- }
- savelist.clear();
int count = 0;
for (std::vector<TcrConnection*>::const_iterator iter = removelist.begin();