Next: , Up: Statistics Storage   [Contents][Index]


3.1 Storage Types

QSMM supports two types of statistics storage: flat and map. You specify the type of statistics storage of an actor using the field use_flat_storage of qsmm_actor_desc_s structure when creating the actor by the function qsmm_actor_create.

Flat Storage

Flat storage uses preallocated arrays and does not perform memory allocation on writing statistics to the storage. Therefore, the flat storage is fast but may require a huge amount of working memory. To reduce the amount of memory occupied by the flat storage of an actor, specify allowed ranges of signal identifiers in the field range_sig_p of qsmm_actor_desc_s structure as precisely as possible when creating the actor by the function qsmm_actor_create.

Map Storage

Map storage uses binary trees to hold statistics and dynamically allocates working memory when needed. When map storage does not hold probability profiles, it contains information on action choice states and cycle types registered at least once throughout event history. In this case, at the beginning of actor operation the storage occupies a small amount of memory. This amount of memory gradually increases as the actor registers more action choice states and cycle types the first time throughout the event history.

Map storage has two shortcomings. The first is that map storage is slower compared to flat storage. The second is that when map storage holds statistics on all possible action choice states and cycle types, it occupies much more memory than the flat storage would occupy. The second shortcoming is not a hindrance, because not all possible action choice states and cycle types usually occur in the event history, and because the actor usually operates shorter time than it is necessary for a large number of action choice states and cycle types to occur the first time in the event history.

Storage Handle

A storage handle refers to flat or map storage.

Data type: qsmm_storage_t

This is a type for a storage handle. It is a pointer, so variables of this type can be NULL. The function qsmm_get_actor_storage returns the storage handle of an actor. You can pass a returned handle to API functions taking an argument of qsmm_storage_t type until destroying the actor.

Use the following function to query the number of spur types supported by storage referred to by a storage handle.

Function: int qsmm_get_storage_nspur (qsmm_storage_t storage)

This function returns the number of spur types supported by storage. The storage can hold statistics for that number of spur types equal to the number of spur types supported by an actor owning the storage. A returned value is always non-negative.


Next: , Up: Statistics Storage   [Contents][Index]