At runtime, the clients need to know where to look for the Redis database. Additionally, if SmartSim ensemble functionality is being used, information is needed to prevent key collisions and to retrieve the correct information from the database. In the following sections, these requirements will be described.
Setting Redis Database Location¶
The C++, C, and Fortran clients retrieve
the Redis database location from the
SSDB environment variable that is set
by the user. If the SmartSim infrastructure
library is being used, then the infrastructure
library will set the value of
SSDB for the user.
SSDB environment variable should have the format
address:port. For a cluster, the addresses
and ports should be separated by a “,” character.
Below is an example of setting
SSDB for a Redis cluster
at three different addresses using port
The Python client also relies on
SSDB to determine database
location. However, the Python
Client constructor also allows
for the database location to be set as an input parameter.
Ensemble Environment Variables¶
The clients work with SmartSim ensemble functionality through
environment variables. There are two environment variables
that are used for ensembles,
SSKEYOUT defines the prefix that is attached to
tensors, datasets, models, and scripts sent from the client
to the database. This prefixing prevents key collisions for
objects sent from the client to the database.
should be set to a single string value. If using the
SmartSim infrastructure library to launch the ensemble,
SSKEYOUT will be set by SmartSim. An example
SSKEYIN defines prefixes that can be attached to
tensors, datasets, models, and scripts when retrieving
data from the database.
SSKEYIN can have multiple,
comma separated values, however, only one of the values
can be used at a time.
SSKEYIN allows a client
in an application to retrieve data from clients
that were part of ensemble when placing data in the
database. An example value of
In the case of multiple
SSKEYIN values, the
API provides a function
to select which
SSKEYIN value is used. The
default is to use the first value of
and any value specified using
must be present in
SSKEYIN when the
Client API provides functions to activate or
deactivate the use of
These functions are split by the data type
that prefixes are applied to in order to give the
user fine control of prefixing in advanced applications.
The default is to use prefixes on tensors and datasets
SSKEYOUT are present. The default
is not to use prefixes on scripts and models.
The functions for changing this default behavior are:
void use_tensor_ensemble_prefix(bool use_prefix); void use_model_ensemble_prefix(bool use_prefix);
object prefixing for objects stored with
DataSet components added via
object prefixing for model and script data.
Model Execution Environment Variable¶
SR_MODEL_TIMEOUT environment variable defines a timeout
on the length of time SmartRedis will wait for a model to
execute. The value for this variable is measured in milliseconds,
and the default value is one minute.
Connection and Command Execution Environment Variables¶
SmartRedis allows for client connection and command execution behavior to be adjusted via environment variables.
During client initialization, the environment variables
SR_CONN_TIMEOUT are used by SmartRedis to determine
the frequency of connection attempts and the cumulative amount of time
before a timeout error is thrown, respectively. The user can set
these environment variables to adjust client connection behavior.
SR_CONN_INTERVAL should be specified in milliseconds and
SR_CONN_TIMEOUT should be specified in seconds.
The environment variables
are used are used by SmartRedis to determine
the frequency of command execution attempts and the
cumulative amount of time before a timeout error is thrown, respectively.
The user can set these environment variables to adjust command execution behavior.
SR_CMD_INTERVAL should be specified in milliseconds and
SR_CMD_TIMEOUT should be specified in seconds. Note that
SR_CMD_TIMEOUT are read during client initialization and not
before each command execution.
The environment variable
SR_THREAD_COUNT is used by SmartRedis to determine
the number of threads to initialize when building a worker pool for parallel task
execution. The default value is four. If the variable is set to zero, SmartRedis
will use a default number of threads equal to one per hardware context in the
processor on which the library is running (more specifically, SmartRedis will
use the result of a call to std::thread::hardware_concurrency() as the number
of threads to create). This default will generally give good
performance; however, if the SmartRedis library is sharing the processor hardware
with other software, it may be useful to specify a smaller number of threads for