Skip to content

Commit 1fdc22b

Browse files
authored
Onnx kill switch (#779)
Introduce kill switch mechanism for terminating long onnxruntime sessions * Refactor background workers * Refactor backends loading * Add load time config for MODEL_EXECUTION_TIMEOUT. Parallel tests seems not to work. * Refactor load time config * More PR fixes, add the option to get the global run sessions array from backend len (supported only for onnx now) in INFO MODULES command. * Return error if onnx is executed in a non async manner (via gears for instance). test info command with AI fields
1 parent debcf77 commit 1fdc22b

38 files changed

+1081
-899
lines changed

docs/commands.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -934,14 +934,14 @@ Because `AI.DAGRUN` provides the `PERSIST` option it is flagged as a 'write' com
934934
Refer to the Redis [`READONLY` command](https://redis.io/commands/readonly) for further information about read-only cluster replicas.
935935

936936
## AI.INFO
937-
The **`AI.INFO`** command returns general module information or information about the execution a model or a script.
937+
The **`AI.INFO`** command returns information about the execution of a model or a script.
938938

939-
Runtime information is collected each time that [`AI.MODELRUN`](#aimodelrun) or [`AI.SCRIPTRUN`](#aiscriptrun) is called. The information is stored locally by the executing RedisAI engine, so when deployed in a cluster each shard stores its own runtime information.
939+
Runtime information is collected each time that [`AI.MODELEXECUTE`](#aimodelrun) or [`AI.SCRIPTEXECUTE`](#aiscriptrun) is called. The information is stored locally by the executing RedisAI engine, so when deployed in a cluster each shard stores its own runtime information.
940940

941941
**Redis API**
942942

943943
```
944-
AI.INFO [<key>] [RESETSTAT]
944+
AI.INFO <key> [RESETSTAT]
945945
```
946946

947947
_Arguments_
@@ -951,15 +951,7 @@ _Arguments_
951951

952952
_Return_
953953

954-
For a module genernal information: An array with alternating entries that represent the following key-value pairs:
955-
956-
* **Version**: a string showing the current module version.
957-
* **Low level API Version**: a string showing the current module's low level api version.
958-
* **RDB Encoding version**: a string showing the current module's RDB encoding version.
959-
* **TensorFlow version**: a string showing the current loaded TesnorFlow backend version.
960-
* **ONNX version**: a string showing the current loaded ONNX Runtime backend version.
961-
962-
For model or script runtime information: An array with alternating entries that represent the following key-value pairs:
954+
An array with alternating entries that represent the following key-value pairs:
963955

964956
* **KEY**: a String of the name of the key storing the model or script value
965957
* **TYPE**: a String of the type of value (i.e. 'MODEL' or 'SCRIPT')

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ADD_LIBRARY(redisai_obj OBJECT
3939
execution/parsing/parse_utils.c
4040
execution/run_info.c
4141
execution/background_workers.c
42+
execution/run_queue_info.c
4243
execution/utils.c
4344
config/config.c
4445
execution/DAG/dag.c
@@ -88,6 +89,7 @@ ENDIF()
8889
IF(BUILD_ORT)
8990
ADD_LIBRARY(redisai_onnxruntime_obj OBJECT
9091
backends/onnxruntime.c
92+
backends/onnx_timeout.c
9193
${BACKEND_COMMON_SRC}
9294
)
9395
ENDIF()

src/backends/backedns_api.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
/**
6+
* @return The internal id of RedisAI current working thread.
7+
* id range is {0, ..., <threads_count>-1}. If this is called from a non
8+
* RedisAI BG thread, return -1.
9+
*/
10+
long (*RedisAI_GetThreadId)(void);
11+
12+
/**
13+
* @return The number of working threads in RedisAI. This number should be
14+
* equal to the number of threads per queue (load time config) * number of devices
15+
* registered in RedisAI (a new device is registered if a model is set to run on
16+
* this device in AI.MODELSTORE command.
17+
*/
18+
uintptr_t (*RedisAI_GetThreadsCount)(void);
19+
20+
/**
21+
* @return The number of working threads per device queue (load time config).
22+
*/
23+
long long (*RedisAI_GetNumThreadsPerQueue)(void);
24+
25+
/**
26+
* @return The maximal number of milliseconds that a model run session should run
27+
* before it is terminated forcefully (load time config).
28+
* Currently supported only fo onnxruntime backend.
29+
*/
30+
long long (*RedisAI_GetModelExecutionTimeout)(void);

0 commit comments

Comments
 (0)