mirror of
https://github.com/wassname/ray.git
synced 2026-08-07 11:27:43 +08:00
Introduce local scheduler heartbeats which carry load information. (#155)
* Introduce local scheduler heartbeats which carry load information.
This commit is contained in:
committed by
Alexey Tumanov
parent
9bb9f8cb54
commit
3d697c7ed2
@@ -5,6 +5,7 @@
|
||||
#include "utlist.h"
|
||||
|
||||
#include "state/task_table.h"
|
||||
#include "state/local_scheduler_table.h"
|
||||
#include "state/object_table.h"
|
||||
#include "photon.h"
|
||||
#include "photon_scheduler.h"
|
||||
@@ -90,6 +91,14 @@ void free_scheduling_algorithm_state(
|
||||
free(algorithm_state);
|
||||
}
|
||||
|
||||
void provide_scheduler_info(local_scheduler_state *state,
|
||||
scheduling_algorithm_state *algorithm_state,
|
||||
local_scheduler_info *info) {
|
||||
task_queue_entry *elt;
|
||||
DL_COUNT(algorithm_state->task_queue, elt, info->task_queue_length);
|
||||
info->available_workers = utarray_len(algorithm_state->available_workers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if all of the remote object arguments for a task are available in the
|
||||
* local object store.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "photon.h"
|
||||
#include "common/task.h"
|
||||
#include "state/local_scheduler_table.h"
|
||||
|
||||
/* The duration that the local scheduler will wait before reinitiating a fetch
|
||||
* request for a missing task dependency. TODO(rkn): We may want this to be
|
||||
@@ -33,6 +34,13 @@ scheduling_algorithm_state *make_scheduling_algorithm_state(void);
|
||||
void free_scheduling_algorithm_state(
|
||||
scheduling_algorithm_state *algorithm_state);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void provide_scheduler_info(local_scheduler_state *state,
|
||||
scheduling_algorithm_state *algorithm_state,
|
||||
local_scheduler_info *info);
|
||||
|
||||
/**
|
||||
* This function will be called when a new task is submitted by a worker for
|
||||
* execution.
|
||||
|
||||
@@ -291,6 +291,18 @@ void handle_task_scheduled_callback(task *original_task, void *user_context) {
|
||||
task_task_spec(original_task));
|
||||
}
|
||||
|
||||
int heartbeat_handler(event_loop *loop, timer_id id, void *context) {
|
||||
local_scheduler_state *state = context;
|
||||
scheduling_algorithm_state *algorithm_state = state->algorithm_state;
|
||||
local_scheduler_info info;
|
||||
/* Ask the scheduling algorithm to fill out the scheduler info struct. */
|
||||
provide_scheduler_info(state, algorithm_state, &info);
|
||||
/* Publish the heartbeat to all subscribers of the local scheduler table. */
|
||||
local_scheduler_table_send_info(state->db, &info, NULL);
|
||||
/* Reset the timer. */
|
||||
return LOCAL_SCHEDULER_HEARTBEAT_TIMEOUT_MILLISECONDS;
|
||||
}
|
||||
|
||||
void start_server(const char *node_ip_address,
|
||||
const char *socket_name,
|
||||
const char *redis_addr,
|
||||
@@ -323,6 +335,13 @@ void start_server(const char *node_ip_address,
|
||||
TASK_STATUS_SCHEDULED, handle_task_scheduled_callback,
|
||||
NULL, &retry, NULL, NULL);
|
||||
}
|
||||
/* Create a timer for publishing information about the load on the local
|
||||
* scheduler to the local scheduler table. This message also serves as a
|
||||
* heartbeat. */
|
||||
if (g_state->db != NULL) {
|
||||
event_loop_add_timer(loop, LOCAL_SCHEDULER_HEARTBEAT_TIMEOUT_MILLISECONDS,
|
||||
heartbeat_handler, g_state);
|
||||
}
|
||||
/* Run event loop. */
|
||||
event_loop_run(loop);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "task.h"
|
||||
#include "event_loop.h"
|
||||
|
||||
/* The duration between local scheduler heartbeats. */
|
||||
#define LOCAL_SCHEDULER_HEARTBEAT_TIMEOUT_MILLISECONDS 1000
|
||||
|
||||
/**
|
||||
* Establish a connection to a new client.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user