From: Eric Bollengier Date: Wed, 10 Mar 2021 14:55:34 +0000 (+0100) Subject: Add some auto-tuning to the SDPacketCheck feature X-Git-Tag: Release-11.3.2~626 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e2d096ebb6ceb81f65ed712ee42b968826a8342;p=thirdparty%2Fbacula.git Add some auto-tuning to the SDPacketCheck feature --- diff --git a/bacula/src/filed/filed.h b/bacula/src/filed/filed.h index 6f4305db9..34a20b3c1 100644 --- a/bacula/src/filed/filed.h +++ b/bacula/src/filed/filed.h @@ -94,8 +94,10 @@ private: int32_t m_check_done; /* small state machine to sync the two threads */ int32_t m_count; /* Current value, at 0 we send the POLL */ - int32_t m_check; /* configuration file value */ - + int32_t m_check; /* Configuration file value */ + btime_t m_last_call; /* Adjust settings dynanically if needed */ + uint64_t m_sent; /* Bytes sent since the last call */ + public: bnet_poll_manager(int32_t val); ~bnet_poll_manager(); diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 51c4d1754..3b48318b9 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -3510,9 +3510,11 @@ bnet_poll_manager::bnet_poll_manager(int32_t val) /* Call one time per job in blast_data_to_storage_daemon() */ void bnet_poll_manager::init(int32_t val) { + m_sent = 0; /* Amount of data sent */ m_check = val; /* Value of the config file */ m_count = val; /* Current value */ m_check_done = 0; /* small state machine to sync the two threads */ + m_last_call = time(NULL); } bnet_poll_manager::~bnet_poll_manager() @@ -3532,12 +3534,29 @@ void bnet_poll_manager::send(JCR *jcr, BSOCK *sd) int32_t val = m_count; if (val == 0) { - Dmsg1(DT_NETWORK|10, "Request a POLL after %d packets...\n", m_check); + char ed1[50]; + Dmsg2(DT_NETWORK|10, "Request a POLL after %d packets %sB...\n", m_check, + edit_uint64_with_suffix(m_sent, ed1)); + + /* We need to monitor the time we spend in this function and the time + * between two checks. If it is less than few secs we should be able to + * increase the count. We stop the automatic tuning if more than 500MB are + * sent between two points. + */ + btime_t now = time(NULL); + if (m_sent < 500*1024*1024L && (now - m_last_call) < 3) { + m_check = m_check * 2; + Dmsg1(DT_NETWORK|10, "Adjust the number of packet sent before a POLL to %d\n", m_check); + } + m_last_call = now; + m_check_done = 1; /* We sent the request */ sd->signal(BNET_POLL); + /* Now we wait for the SD to answer, the packet will arrive in the + * Heartbeat thread + */ struct timespec t; - P(m_mutex); do { t.tv_sec = time(NULL) + 5; @@ -3556,8 +3575,10 @@ void bnet_poll_manager::send(JCR *jcr, BSOCK *sd) if (val < 0) { /* Initialization or loop found */ val = m_check; + m_sent = 0; } + m_sent += (sd->msglen > 0) ? sd->msglen : 0; m_count = val; }