LabVIEW NSVs: Clustering Cuts Overhead, Not Network Load

Stefan Weidner6 min read
Best PracticesIndustrial NetworkingOther Manufacturer
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

The HMI writes a value, the host network stack carries it to the deployed Shared Variable Engine (SVE), and the cRIO 9074 reads the published value into its control code; indicator data travels in the reverse direction. A type-defined cluster reduces the number of network-published shared variables (NSVs) and their per-variable processing, but every cluster update transfers and copies the complete cluster. Group values by ownership and update rate, not merely by data type.

Where does the shared-variable data path stop?

Follow the packet from the writer before changing the data model. Confirm the physical link first, then the deployed variable library, SVE availability, and application access. A disconnected cable, incorrect address, blocked service, undeployed library, or stopped component can produce the same application symptom: an NSV cannot be reached.

Path element Commissioning setting Check
HMI or host Writer for control NSVs; reader for indicator NSVs Confirm the application changes the intended library item
Physical network Active link between host and cRIO 9074 Check link state and basic IP reachability before examining LabVIEW code
Address path Configured host, target, and SVE addresses Compare runtime bindings with the deployed configuration
Service ports Ports required by the installed shared-variable configuration Read the deployment and firewall configuration; no port number is specified here
SVE and library Running engine with the correct deployed variables Inspect variables through Distributed System Manager
Application component Connected reader or writer Restart the affected component if its connection is stale, then retest without first restarting the SVE

The proof for this stage is a visible value transition at the SVE when the designated writer changes one item. If the SVE never receives that transition, remain on the host-to-engine half of the path.

Does clustering actually reduce cRIO processor load?

Potentially. Each NSV carries per-variable work such as metadata handling, a timestamp, and FIFO processing when FIFO behavior is selected. Replacing many scalar NSVs with fewer clustered NSVs can reduce that repeated overhead. The gain is material only when per-variable management represents a meaningful share of the target load.

The tradeoff occurs at every access. Reading one cluster copies the complete cluster into the caller. Publishing one changed member sends an update for the entire cluster rather than only that Boolean, floating-point value, or string. Large clusters therefore increase memory movement and network traffic when their members change at different rates.

Design Per-variable overhead Payload and copying Best fit
Many scalar NSVs Higher variable count Only the changed scalar needs an update Independent ownership or very different update rates
One large cluster NSV Lower variable count Whole cluster moves on every update Values consumed and produced as one snapshot
Several functional clusters Moderate variable count Payload limited to one functional group Related values with common ownership and timing

Measure target CPU load, network bytes, and application loop execution before and after clustering under the same workload. A lower variable count alone does not prove an improvement.

How should variables be divided into type-defined clusters?

Start with the writer. Place fields in the same cluster when one loop owns every write, the fields form one coherent state, and consumers need them at roughly the same time. Separate fields when another loop owns them, one field changes much faster, or a large string would be retransmitted whenever an unrelated Boolean changes.

Grouping criterion Keep together Split apart
Ownership One writer updates all members Multiple writers would require read-modify-write
Timing Members share an update event Fast and slow values have unrelated rates
Meaning Setpoint command and its request state Unrelated controls grouped only to reduce count
Payload Small values always consumed together Large or frequently changing members dominate traffic
Direction All controls or all indicators Host commands mixed with target status

Maintain separate control and indicator libraries. Let the HMI or host be the sole writer of control clusters, and let one target location be the sole writer of each indicator cluster. The checkpoint is a writer map showing exactly one writer for every clustered NSV.

How do clustered commands avoid race conditions?

A cluster write is useful when several members describe one command. For example, carrying a set? Boolean beside its numeric setpoint prevents the receiver from observing a new request flag with an old numeric value. The writer constructs both members locally and publishes them together.

Clustering does not make a multi-writer design safe. If two loops read the same cluster, change different members, and write it back, the later whole-cluster write can restore stale values over the earlier change. This is the classic read-modify-write race.

  1. Assign one loop as the sole writer for the cluster.
  2. Send update requests from other loops to that owner through an internal message path.
  3. Have the owner modify its local current state and publish one complete cluster.
  4. On the receiving side, process the command and update an explicit status or acknowledgement field in the return path when the application requires confirmation.

Test by issuing simultaneous internal requests for different members. The published cluster must contain both requested changes; a lost member exposes an unauthorized second writer or a stale local copy.

When should the design use another transport?

NSVs suit noncritical monitoring and supervisory controls when the application can detect disconnection, reject stale data, and recover. Intermittent cases have included variables becoming unreachable until an application component was restarted, and larger failures in which the SVE lost its values and required a restart. Treat recovery behavior as part of commissioning.

Requirement Transport decision Commissioning focus
Convenient distributed tags and monitoring NSVs can fit Deployment, connection state, stale-data handling, and restart recovery
Ordered point-to-point data stream Evaluate Network Streams Connection lifecycle, ordering, buffering, and reconnect behavior
Application-defined protocol Evaluate a TCP client/server design Message framing, ownership, reconnect logic, and diagnostics
Local current-value exchange Evaluate the Current Value Table Writer ownership and reader access

For a critical command, define what happens when communication disappears before selecting the transport. The checkpoint is a forced-disconnection test that produces a detectable fault or invalid-data state rather than silently retaining a value as though it were current.

How is the clustered design verified end to end?

  1. Record baseline cRIO processor load, loop execution behavior, and network traffic with the scalar NSV design.
  2. Deploy functional type-defined clusters without changing the test workload.
  3. Use Distributed System Manager to confirm each cluster exists, remains reachable, and changes only from its assigned writer.
  4. Exercise a single-member change and observe whether retransmitting the whole cluster creates unacceptable traffic or copying.
  5. Exercise simultaneous command requests and confirm no member is overwritten by stale read-modify-write data.
  6. Disconnect and restore the network. Confirm the application detects loss, rejects stale control data, reconnects, and resumes valid updates.
  7. Restart the affected application component and then the SVE in separate tests so each recovery path is known.
  8. Compare the new CPU and network measurements with the baseline. Retain clustering only where the reduced per-variable overhead outweighs whole-cluster transfer and copy cost.

The final pass is an HMI command observed at the deployed control cluster, consumed once by the cRIO 9074 owner loop, and reflected through the separately owned indicator cluster back to the HMI after a tested disconnect and reconnect.

FAQ

Does a type-defined cluster always improve LabVIEW NSV performance?

No. It reduces repeated per-variable handling, but each access copies and publishes the whole cluster. Compare CPU and network measurements under the same workload.

Can I put every cRIO value into one shared-variable cluster?

You can, but unrelated update rates, large members, and whole-cluster writes can increase traffic and memory copying. Use several functional clusters with one writer each.

Does one cluster prevent shared-variable race conditions?

It preserves related fields within one publication, such as set? and its setpoint, but it does not protect against multiple read-modify-write writers. Route all changes through one owner loop.

Can I verify an NSV fix without restarting the Shared Variable Engine?

Yes. First restart only the affected application component and watch the deployed value in Distributed System Manager. Finish by sending an HMI command through the control cluster and confirming its result returns through the indicator cluster.

Back to blog