当前位置:网站首页>Flink--Chain的条件源码分析
Flink--Chain的条件源码分析
2022-07-03 09:32:00 【Samooyou】
flink为了提高执行效率,会将部分算子进行合并,合并后组成operator chain,这样整个operator chain作为一个JobVertex被调度到一个slot上去执行,避免了上下游算子发送数据时带来的网络开销以及数据序列化反序列化的性能损耗。
flink如何判断算子能组成一个operate chain呢?答案在源码StreamingJobGraphGenerator.java中:
public static boolean isChainable(StreamEdge edge, StreamGraph streamGraph) {
StreamNode upStreamVertex = streamGraph.getSourceVertex(edge);
StreamNode downStreamVertex = streamGraph.getTargetVertex(edge);
StreamOperatorFactory<?> headOperator = upStreamVertex.getOperatorFactory();
StreamOperatorFactory<?> outOperator = downStreamVertex.getOperatorFactory();
return downStreamVertex.getInEdges().size() == 1
&& outOperator != null
&& headOperator != null
&& upStreamVertex.isSameSlotSharingGroup(downStreamVertex)
&& outOperator.getChainingStrategy() == ChainingStrategy.ALWAYS
&& (headOperator.getChainingStrategy() == ChainingStrategy.HEAD ||
headOperator.getChainingStrategy() == ChainingStrategy.ALWAYS)
&& (edge.getPartitioner() instanceof ForwardPartitioner)
&& edge.getShuffleMode() != ShuffleMode.BATCH
&& upStreamVertex.getParallelism() == downStreamVertex.getParallelism()
&& streamGraph.isChainingEnabled();
}
downStreamVertex.getInEdges().size() == 1
:下游算子的入边必须为1,下游算子不能是connect,union,join,这些算子入边都是大于1,因为他需要接入两个流upStreamVertex.isSameSlotSharingGroup(downStreamVertex)
:上游算子和下游算子都在同一个SlotSharingGroup:每个算子都可以通过.slotSharingGroup()来指定该算子的SlotSharingGroup,默认不指定都是Default,如果想要上下游算子组成operater chain,上下游的SlotSharingGroup必须相同,要么都不指定,要么设置为相同的值outOperator.getChainingStrategy() == ChainingStrategy.ALWAYS && (headOperator.getChainingStrategy() == ChainingStrategy.HEAD || headOperator.getChainingStrategy() == ChainingStrategy.ALWAYS)
:下游算子的ChainingStrategy策略必须是ALWAYS,上游算子的ChainingStrategy策略必须是ALWAYS或者HEAD:如果算子调用了disableChaining()的话,该算子的ChainingStrategy会变成NEVER,不能与上下游任何算子组成operator chain;如果算子调用了startNewChain(),那么这个算子的ChainingStrategy就变成HEAD;不能与上游算子组成chain,只能与下游算子组成chain。Source算子默认是HEAD,其他算子默认都是ALWAYSedge.getPartitioner() instanceof ForwardPartitioner
:上下游算子之间的数据分区方式是ForwardPartitioner:数据分区有几种分区方式:shuffle,rebalance,rescale,broadcast,keyedgroup,forward等。如果上下游算子之间没有显示调用其他分区模式(keyby,shuffle,rebalance,rescale,broadcast)并且上下游算子并发度相同的情况下,默认都是ForwardPartitioner模式edge.getShuffleMode() != ShuffleMode.BATCH
:如果没有指定默认都是PIPELINEDupStreamVertex.getParallelism() == downStreamVertex.getParallelism()
:上下游算子的并发度必须相同streamGraph.isChainingEnabled()
:job没有调用disableChaining()
边栏推荐
- 【SQL】一篇带你掌握SQL数据库的查询与修改相关操作
- MySQL报错“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”解决方法
- Codeup: word replacement
- MySQL reports an error "expression 1 of select list is not in group by claim and contains nonaggre" solution
- Hands on deep learning pytorch version exercise solution - 2.4 calculus
- The imitation of jd.com e-commerce project is coming
- Numpy quick start (V) -- Linear Algebra
- Leetcode skimming ---1
- Numpy realizes the classification of iris by perceptron
- 权重衰退(PyTorch)
猜你喜欢
Hands on deep learning pytorch version exercise solution -- implementation of 3-2 linear regression from scratch
A complete mall system
[ultra detailed] implement soft and hard interval SVM based on sklearn
Yolov5 creates and trains its own data set to realize mask wearing detection
【吐槽&脑洞】关于逛B站时偶然体验的弹幕互动游戏魏蜀吴三国争霸游戏的一些思考
Ind kwf first week
权重衰退(PyTorch)
Hands on deep learning pytorch version exercise solution - 2.3 linear algebra
The story of a 30-year-old tester struggling, even lying flat is extravagant
High imitation Netease cloud music
随机推荐
Numpy quick start (III) -- array advanced operation
Leetcode skimming ---852
丢弃法Dropout(Pytorch)
Hands on deep learning pytorch version exercise answer - 2.2 preliminary knowledge / data preprocessing
Out of the box high color background system
Leetcode skimming ---977
Model selection for neural network introduction (pytorch)
Hands on deep learning pytorch version exercise solution -- implementation of 3-2 linear regression from scratch
MySQL报错“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”解决方法
Leetcode刷题---852
一个30岁的测试员无比挣扎的故事,连躺平都是奢望
User recommendation preference model based on attention enhanced knowledge perception
[combinatorial mathematics] pigeon's nest principle (simple form of pigeon's nest principle | simple form examples of pigeon's nest principle 1, 2, 3)
Leetcode刷题---283
Numpy realizes the classification of iris by perceptron
6、 Data definition language of MySQL (1)
Raspberry pie 4B deploys lnmp+tor and builds a website on dark web
Pytoch has been installed, but vs code still displays no module named 'torch‘
Linear regression of introduction to deep learning (pytorch)
A complete answer sheet recognition system