|
SObjectizer
5.8
|
There are some places in the SObjectizer where there is no "one right implementation" which will give the best possible results for all scenarios. Version 5.5.3 introduces an approach for tuning agents and underlying data structures/algorithm for user-specific scenarios. The first step is support for various type of subscription storages.
Subscription storage is a data structure for storing and manipulating information about an agent's subscriptions. Every agent has its own private subscription storage. When an agent creates subscription like:
this subscription is stored in the agent's subscription storage. When agent receives a messages the handler for that message will be searched in this storage.
The problem is selection of the appropriate data structure for that storage.
When an agent uses small amount of subscription (like one or two subscriptions) then a very simple vector-based implementation will be the most efficient. When an agent uses several dozens subscriptions then vector-based implementation becomes inefficient and map-based storage will be more appropriate. But when an agent uses several hundreds or even thousands of subscriptions then hash-table-based implementation will be more efficient.
Since v.5.5.3 a user can specify which subscription storage should be used for an agent.
Do do so it is necessary to specify tuning_options-object to constructor of base class:
The new static method so_5::rt::agent_t::tuning_options() creates an so_5::rt::agent_tuning_options_t object with default values. This values can be changed by calling so_5::rt::agent_tuning_options_t's methods.
For example to change type of subscription storage it is necessary to call so_5::rt::agent_tuning_options_t::subscription_storage_factory() method:
There are several implementations of subscription storage:
By default all agents use adaptive subscription storage. It means that if an agent creates very few subscriptions it will use very small and very fast vector-based storage. But if count of subscription grows then agent will switch to more expensive but more appropriate for big amount of subscriptions map-based storage.
But if user knows what count of subscriptions an actor will use then an appropriate storage can be created once and never switches from one implementation to another.