Click or drag to resize

Understanding State Caching

State caching is a feature of IVI drivers that can improve performance by minimizing the number of I/O calls to an instrument. For instance, if a driver property value is set and the driver sends the programmed value to the instrument, subsequent calls to the same property need not communicate with the instrument if the value being set is the same as the previous value. Correspondingly, reading a driver property need not result in instrument communication if the driver can somehow "remember" the last value that was sent to the instrument. When a client application invokes a driver property, the driver caches the value specified in memory so that subsequently the driver can simply retrieve the value from the driver's cache when the property is read or avoid making a redundant call to the instrument when the property is written. In this way, the instrument I/O traffic is minimized and the overall client application performance can be improved.

Understanding Cache Couplings

When a driver caches the value of a property, it should ideally return the cached value when the property is later read, rather than incurring the performance hit of querying the instrument for the property value. This will work so long as nothing takes place within the instrument that would invalidate the value cached in the driver. If, after caching the value of a property, the driver performs a different instrument operation that directly or indirectly changes the value of the property within the instrument, then the driver's cache and the "real" setting in the instrument are inconsistent. This is one form of what is termed a cache coherency problem.

If setting some driver property or executing a driver method produces a change in an instrument setting represented by another property, the properties or methods are said to be coupled. For state caching to work properly, these cache couplings must be programmed into the driver, so that the driver knows when to invalidate specific cached values. For instance, if the driver is caching a Frequency property, then setting the Bandwidth property may also change the frequency setting within the instrument. This means that the driver must know to invalidate the cached value for the Frequency property whenever the Bandwidth is set.

State Caching Features in Nimbus

The automatic state caching feature of Nimbus is the simplest to use and will suffice in most circumstances. With this technique, Nimbus automatically creates and manages a cache entry for every driver property for which state caching has been enabled. The State Caching Editor is used to turn state caching on and off on a property-by-property basis. The other bit of information that the driver developer must provide via the State Caching Editor is the list of properties to which the cached property is coupled. In other words, the driver developer must specify which driver properties are invalidated when the current property's value is changed.

When To Enable State Caching

State caching is a feature that certainly must be used with care. Cache coherency problems can easily arise if the driver developer is not keenly aware of the details of the instrument behavior and/or does not accurately and thorougly represent instrument couplings in the driver. Thus, in general, it is advisable to consider enabling state caching for those properties that have the following characteristics:

  1. They require considerable time to execute (and, hence, stand to improve performance the most when cached).

  2. They have a modest and easily expressed set of couplings to other properties.

Enabling state caching broadly across all properties in a driver is almost never feasible, as correctly implementing the driver code would involve effectively replicating much of the instrument firmware logic itself. Consequently, Nimbus disables state caching by default for all properties.

Download a complete CHM version of this documentation here.