A new feature was introduced in Streams Studio V4.0, operator colocation options in Studio’s graphical editor. These make it easier to take advantage of the operator placement host colocation and partition colocation configs(also known as operator fusion).
The default behaviour for a Streams application is to assign each operator in the application to its own Processing Element (PE) at compilation. The partitionColocation placement config allows you to group operators into a single PE at compilation time. To quote from the Streams Knowledge Center: “When operators are fused into PEs, they communicate through function calls and tuples that are passed from one operator to the next using memory references, as opposed to using the transport. This process might significantly reduce the cost of communication and improve both latency and throughput.” Prior to the Streams V4 there was no simple way to see these colocations in the editor. With the Vwap sample application we will show this has been made simpler in Streams Studio.
In Streams Studio, import the Vwap sample and open the Vwap main composite in the graphical editor. Select the TradeFilter, PreVwap, and Vwap operators by clicking and dragging a box around them or using ctrl+click to select them. Right click on one of the three selected operators to bring up the right click context menu and choose ‘Assign operator partition colocation’ from the Operator Placement sub-menu as shown below.
The dialog that comes up allows the user to enter an arbitrary identifier for the colocation grouping. The drop-down is populated with any existing partition colocation identifiers in the composite for easy selection as well. Press OK and the config clause is added to the operator.
While this has made creating the config clause simpler, the main improvement is that you can now see the paritions visually in the graphical editor. A color scheme was added to color by partition colocation. From the list of color schemes to the right of the graphical editor palette, select Partition Colocation to see the groupings of operators that have been created using the placement config. The image below shows the 3 operators (purple) to indicate they are part of the same partition. If there were different partitions those would be shown with a different color. Operators not colored do not belong to a specific partition.
Along with colocation by partition, colocation by host is also supported with Studio’s graphical editor using the same right-click menu on a selection of operators in a graph. The host colocation identifiers are separate from the partition colocation identifiers and can be used to specify that a set of operators should run from the same host. This config is only useful in multi-host Streams application server setups. Like the partition colocation, there are color schemes available in the graphical editor and instance graph to see host colocation of operators.
The two colocation configs can be combined to have more complex placement of operators. In addition, there are other placement configuration options which can be added using the graphical editor properties view or the SPL editor. There are placement subconfigs to choose specific hosts for operators to be placed on using the host subconfig, and to ensure an operator doesn’t run on the same host or PE as another using the hostExlocation and partitionExlocation subconfigs.
Find out more about placement configuration in these Streams V4 Knowledge Center topics: Operator Placement Config Clause