Reduce Scheduler Overhead using Lightweight Policy
The Flow Graph API allows you to apply
lightweight policy
for computational nodes such as function node, multifunction node, continue node, and async node. Enabling the lightweight policy helps reduce scheduling overhead. It can limit parallel execution of tasks, so apply this policy on a per-node basis after careful evaluation.
The lightweight policy indicates that the body of a node contains a small amount of work and, if possible, should be executed without the overhead of scheduling a task. By default, the async node has the lightweight policy enabled because it has small computation weight. All other computational nodes do not have the lightweight policy enabled when they are dragged and dropped into the canvas.
Use the lightweight policy in the following cases:
- Node weight is less than 1 microsecond when no trace information is available.
- Node average time is less than 1 microsecond if the graph is loaded into context with trace data.
When validating a graph, the graph rule check automatically identifies nodes that can use the lightweight policy. If the above conditions are not met but the lightweight policy is set, the graph rule check recommends removing the lightweight policy for the corresponding node.
To display recommendations for applying the lightweight policy:
- Click the graph rule check icon on the toolbar to run the check.
- Go to theAnalytics Reporttab to see the results.
- Based on the results, set or disable the lightweight policy for certain nodes.
- To set or disable the lightweight execution policy for asinglenode:
- Click the node to display the node properties on the right pane.
- Set theExecution policyproperty tononeto disable lightweight policy or tolightweightto enable lightweight policy.
- To set or disable the lightweight execution policy forallthe nodes listed by graph rule check:
- Multi-select the report lines that sayConsider enabling lightweight policy for small computational or async nodeorConsider disabling lightweight policy for small computational or async nodeto highlight all nodes in the canvas and display the common properties for all the selected nodes.
- Set theExecution policyproperty tononeto disable lightweight policy or tolightweightto enable lightweight policy.
For example, to enable the lightweight policy for multiple nodes:
Another important attribute related to node execution policy is a
buffer policy
:
- If you set the buffer policy toqueueingwhen lightweight policy is enabled, the Flow Graph Analyzer addsqueueing_lightweightto the policy parameter of the node declaration during C++ code generation.
- If you set buffer policy torejecting, the Flow Graph Analyzer addsrejecting_lightweightto the policy parameter of the node declaration during C++ code generation.
For example, by default, the async node is set to
queueing_lightweight
, and the Flow Graph Analyzer does not add any policy during code generation for async node. Setting buffer policy to
rejecting
for the async node adds
rejecting_lightweight
to the policy parameter of async node declaration during code generations.