Bug 40808: Change KISTSchedRunInterval range and default; add KISTSchedRunIntervalClient

This commit is contained in:
Mike Perry 2023-06-20 16:29:48 +00:00
parent 846bad3a96
commit 27a0fee882
3 changed files with 18 additions and 12 deletions

View File

@ -102,9 +102,9 @@ typedef struct scheduler_t {
*****************************************************************************/ *****************************************************************************/
/* Default interval that KIST runs (in ms). */ /* Default interval that KIST runs (in ms). */
#define KIST_SCHED_RUN_INTERVAL_DEFAULT 10 #define KIST_SCHED_RUN_INTERVAL_DEFAULT 2
/* Minimum interval that KIST runs. This value disables KIST. */ /* Minimum interval that KIST runs. */
#define KIST_SCHED_RUN_INTERVAL_MIN 0 #define KIST_SCHED_RUN_INTERVAL_MIN 2
/* Maximum interval that KIST runs (in ms). */ /* Maximum interval that KIST runs (in ms). */
#define KIST_SCHED_RUN_INTERVAL_MAX 100 #define KIST_SCHED_RUN_INTERVAL_MAX 100

View File

@ -13,6 +13,7 @@
#include "app/config/config.h" #include "app/config/config.h"
#include "core/mainloop/connection.h" #include "core/mainloop/connection.h"
#include "feature/nodelist/networkstatus.h" #include "feature/nodelist/networkstatus.h"
#include "feature/relay/routermode.h"
#define CHANNEL_OBJECT_PRIVATE #define CHANNEL_OBJECT_PRIVATE
#include "core/or/channel.h" #include "core/or/channel.h"
#include "core/or/channeltls.h" #include "core/or/channeltls.h"
@ -810,12 +811,19 @@ kist_scheduler_run_interval(void)
log_debug(LD_SCHED, "KISTSchedRunInterval=0, turning to the consensus."); log_debug(LD_SCHED, "KISTSchedRunInterval=0, turning to the consensus.");
/* Will either be the consensus value or the default. Note that 0 can be /* Clients and relays have a separate consensus parameter. Clients
* returned which means the consensus wants us to NOT use KIST. */ * need a lower KIST interval, since they have only a couple connections */
return networkstatus_get_param(NULL, "KISTSchedRunInterval", if (server_mode(get_options())) {
return networkstatus_get_param(NULL, "KISTSchedRunInterval",
KIST_SCHED_RUN_INTERVAL_DEFAULT, KIST_SCHED_RUN_INTERVAL_DEFAULT,
KIST_SCHED_RUN_INTERVAL_MIN, KIST_SCHED_RUN_INTERVAL_MIN,
KIST_SCHED_RUN_INTERVAL_MAX); KIST_SCHED_RUN_INTERVAL_MAX);
} else {
return networkstatus_get_param(NULL, "KISTSchedRunIntervalClient",
KIST_SCHED_RUN_INTERVAL_DEFAULT,
KIST_SCHED_RUN_INTERVAL_MIN,
KIST_SCHED_RUN_INTERVAL_MAX);
}
} }
/* Set KISTLite mode that is KIST without kernel support. */ /* Set KISTLite mode that is KIST without kernel support. */

View File

@ -81,8 +81,7 @@ mock_vanilla_networkstatus_get_param(
(void)default_val; (void)default_val;
(void)min_val; (void)min_val;
(void)max_val; (void)max_val;
// only support KISTSchedRunInterval right now (void)param_name;
tor_assert(strcmp(param_name, "KISTSchedRunInterval")==0);
return 0; return 0;
} }
@ -95,8 +94,7 @@ mock_kist_networkstatus_get_param(
(void)default_val; (void)default_val;
(void)min_val; (void)min_val;
(void)max_val; (void)max_val;
// only support KISTSchedRunInterval right now (void)param_name;
tor_assert(strcmp(param_name, "KISTSchedRunInterval")==0);
return 12; return 12;
} }
@ -863,7 +861,7 @@ test_scheduler_initfree(void *arg)
/* We have specified nothing in the torrc and there's no consensus so the /* We have specified nothing in the torrc and there's no consensus so the
* KIST scheduler is what should be in use */ * KIST scheduler is what should be in use */
tt_ptr_op(the_scheduler, OP_EQ, get_kist_scheduler()); tt_ptr_op(the_scheduler, OP_EQ, get_kist_scheduler());
tt_int_op(sched_run_interval, OP_EQ, 10); tt_int_op(sched_run_interval, OP_EQ, KIST_SCHED_RUN_INTERVAL_DEFAULT);
scheduler_free_all(); scheduler_free_all();
@ -906,7 +904,7 @@ test_scheduler_can_use_kist(void *arg)
#else /* HAVE_KIST_SUPPORT */ #else /* HAVE_KIST_SUPPORT */
tt_int_op(res_should, OP_EQ, 0); tt_int_op(res_should, OP_EQ, 0);
#endif /* HAVE_KIST_SUPPORT */ #endif /* HAVE_KIST_SUPPORT */
tt_int_op(res_freq, OP_EQ, 10); tt_int_op(res_freq, OP_EQ, KIST_SCHED_RUN_INTERVAL_DEFAULT);
/* Test defer to consensus, and kist consensus available */ /* Test defer to consensus, and kist consensus available */
MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param); MOCK(networkstatus_get_param, mock_kist_networkstatus_get_param);