You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/02/02 10:07:28 UTC
[GitHub] [skywalking] mrproliu opened a new pull request #4308: provide
thread stack analyzes
mrproliu opened a new pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308
Please answer these questions before submitting pull request
- Why submit this pull request?
- [ ] Bug fix
- [x] New feature provided
- [ ] Improve performance
- Related issues
#4104
### New feature or improvement
- provide thread analyzes to the stack tree.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] mrproliu commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
mrproliu commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374458728
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // add detected stack
+ this.detectedBy(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int depth = 1; depth < stackList.size(); depth++) {
+ String elementCodeSignature = stackList.get(depth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSignature)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // add detected stack
+ childElement.detectedBy(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = newNode();
+ childNode.codeSignature = elementCodeSignature;
+ childNode.detectedBy(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineDetectedStacks(node);
+
+ // merge tree using LDR to traversal tree node
+ // using stack to avoid recursion
+ // merge key.children <- value.children
+ LinkedList<Pair<ProfileStackNode, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, ProfileStackNode> needCombineNode = stack.pop();
+
+ // merge value children to key
+ // add to stack if need to keep traversal
+ combineChildrenNodes(needCombineNode.key, needCombineNode.value, stack::add);
+ }
+
+ return this;
+ }
+
+ /**
+ * merge all children nodes to appoint node
+ * @param targetNode
+ * @param beingMergedNode
+ * @param continueChildrenMerging
+ */
+ private void combineChildrenNodes(ProfileStackNode targetNode, ProfileStackNode beingMergedNode, Consumer<Pair<ProfileStackNode, ProfileStackNode>> continueChildrenMerging) {
+ if (beingMergedNode.children.isEmpty()) {
+ return;
+ }
+
+ for (ProfileStackNode childrenNode : targetNode.children) {
+ // find node from being merged node children
+ for (ListIterator<ProfileStackNode> it = beingMergedNode.children.listIterator(); it.hasNext();) {
+ ProfileStackNode node = it.next();
+ if (node != null && node.matches(childrenNode)) {
+ childrenNode.combineDetectedStacks(node);
+ continueChildrenMerging.accept(new Pair<>(childrenNode, node));
+
+ it.set(null);
+ break;
+ }
+ }
+ }
+
+ for (ProfileStackNode node : beingMergedNode.children) {
+ if (node != null) {
+ targetNode.children.add(node);
+ }
+ }
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to single-level list (such as flat), work for parallel calculating
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> nodeMapping = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ nodeMapping.add(new Pair<>(root, this));
+
+ // same with combine logic
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, ProfileStackNode> mergingPair = stack.pop();
+ ProfileStackElement respElement = mergingPair.key;
+
+ // generate children node and add to stack and all node mapping
+ respElement.setChildren(mergingPair.value.children.stream().map(c -> {
+ ProfileStackElement element = c.buildElement();
+ Pair<ProfileStackElement, ProfileStackNode> pair = new Pair<>(element, c);
+ stack.add(pair);
+ nodeMapping.add(pair);
+
+ return element;
+ }).collect(Collectors.toList()));
+ }
+
+ // calculate durations
+ nodeMapping.parallelStream().forEach(t -> t.value.calculateDuration(t.key));
+ nodeMapping.parallelStream().forEach(t -> t.value.calculateDurationExcludeChild(t.key));
+
+ return root;
+ }
+
+ private void detectedBy(ProfileStack stack) {
+ this.detectedStacks.add(stack);
+ }
+
+ private void combineDetectedStacks(ProfileStackNode node) {
+ this.detectedStacks.addAll(node.detectedStacks);
+ }
+
+ private ProfileStackElement buildElement() {
+ ProfileStackElement element = new ProfileStackElement();
+ element.setCodeSignature(this.codeSignature);
+ element.setChildren(new LinkedList<>());
+ element.setCount(this.detectedStacks.size());
+ return element;
+ }
+
+ /**
+ * calculate duration to {@link ProfileStackElement#getDuration()}
+ */
+ private void calculateDuration(ProfileStackElement element) {
+ if (this.detectedStacks.size() <= 1) {
+ element.setDuration(0);
+ return;
+ }
+
+ // sort owners
Review comment:
Ok, I understand. I will delete this comment
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@a89ab30`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `78.78%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
========================================
Coverage ? 26.8%
========================================
Files ? 1174
Lines ? 25595
Branches ? 3641
========================================
Hits ? 6861
Misses ? 18125
Partials ? 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../oap/server/core/profile/analyze/ProfileStack.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFjay5qYXZh) | `8.33% <0%> (ø)` | |
| [...p/server/core/profile/analyze/ProfileAnalyzer.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplci5qYXZh) | `77.77% <100%> (ø)` | |
| [...pache/skywalking/apm/agent/core/base64/Base64.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvYmFzZTY0L0Jhc2U2NC5qYXZh) | `100% <100%> (ø)` | |
| [.../core/profile/analyze/ProfileAnalyzeCollector.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplQ29sbGVjdG9yLmphdmE=) | `100% <100%> (ø)` | |
| [...walking/apm/agent/core/context/ContextCarrier.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9Db250ZXh0Q2Fycmllci5qYXZh) | `70% <57.14%> (ø)` | |
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `83.33% <87.87%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [a89ab30...baf98d7](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374457988
##########
File path: docs/en/guides/backend-profile.md
##########
@@ -0,0 +1,44 @@
+# Thread dump merging mechanism
+The performance profile is an enhancement feature in the APM system. We are using the thread dump to estimate the method execution time, rather than adding many local spans. In this way, the resource cost would be much less than using distributed tracing to locate slow method. This feature is suitable in the production environment. This document introduces how thread dumps are merged into the final report as a stack tree(s).
+
+## Thread analyst
+### Read data and transform
+Read data from the database and convert it to a data structure in gRPC.
+```
+st=>start: Start
+e=>end: End
+op1=>operation: Load data using paging
+op2=>operation: Transform data using parallel
+
+st(right)->op1(right)->op2
+op2(right)->e
Review comment:
I'd prefer to generate an image and put that image here, the source codes seems not that straightforward, same as others below
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@a89ab30`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `72.72%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
Coverage ? 26.82%
=========================================
Files ? 1174
Lines ? 25603
Branches ? 3645
=========================================
Hits ? 6869
Misses ? 18125
Partials ? 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `84.84% <100%> (ø)` | |
| [...pache/skywalking/apm/agent/core/base64/Base64.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvYmFzZTY0L0Jhc2U2NC5qYXZh) | `100% <100%> (ø)` | |
| [...p/server/core/profile/analyze/ProfileAnalyzer.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplci5qYXZh) | `75% <100%> (ø)` | |
| [.../core/profile/analyze/ProfileAnalyzeCollector.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplQ29sbGVjdG9yLmphdmE=) | `100% <100%> (ø)` | |
| [...walking/apm/agent/core/context/ContextCarrier.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9Db250ZXh0Q2Fycmllci5qYXZh) | `70% <57.14%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [a89ab30...d978bdd](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373908103
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
Review comment:
Fix comment too.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373834816
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ *
+ * @author MrPro
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> childes;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.childes = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.childes) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.childes.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node.childes));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackNode combineTo = needCombineNode.key;
+
+ // merge node
+ for (ProfileStackNode needCombineChildren : needCombineNode.value) {
+ boolean sameReference = false;
+ // find node
+ ProfileStackNode combinedNode = null;
+ for (ProfileStackNode combineNodeChildren : combineTo.childes) {
+ // same code signature
+ if (Objects.equal(needCombineChildren.codeSignature, combineNodeChildren.codeSignature)) {
+ // if same reference, dont need to combine anymore
+ if (needCombineChildren == combineNodeChildren) {
+ sameReference = true;
+ } else {
+ combineNodeChildren.combineThisNode(needCombineChildren);
+ }
+ combinedNode = combineNodeChildren;
+ break;
+ }
+ }
+
+ if (combinedNode == null) {
+ combineTo.childes.add(needCombineChildren);
+ combinedNode = needCombineChildren;
+ }
+
+ if (!sameReference) {
+ stack.add(new Pair(combinedNode, needCombineChildren.childes));
+ }
+ }
Review comment:
too many nested blocks, better to refactor/extract some short methods
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/4070afa008349e605faf6fd47bad8ea70c1fda81?src=pr&el=desc) will **increase** coverage by `0.18%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
+ Coverage 26.92% 27.1% +0.18%
=========================================
Files 1174 1174
Lines 25606 25606
Branches 3645 3645
=========================================
+ Hits 6894 6941 +47
+ Misses 18108 18059 -49
- Partials 604 606 +2
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `90.09% <ø> (ø)` | :arrow_up: |
| [...king/apm/agent/core/remote/GRPCChannelManager.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsTWFuYWdlci5qYXZh) | `70.51% <0%> (+1.28%)` | :arrow_up: |
| [.../agent/core/context/trace/AbstractTracingSpan.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC90cmFjZS9BYnN0cmFjdFRyYWNpbmdTcGFuLmphdmE=) | `64.6% <0%> (+3.53%)` | :arrow_up: |
| [.../skywalking/apm/agent/core/remote/GRPCChannel.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsLmphdmE=) | `87.5% <0%> (+6.25%)` | :arrow_up: |
| [.../agent/core/profile/ProfileTaskChannelService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcHJvZmlsZS9Qcm9maWxlVGFza0NoYW5uZWxTZXJ2aWNlLmphdmE=) | `44.82% <0%> (+8.04%)` | :arrow_up: |
| [.../core/remote/ServiceAndEndpointRegisterClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1NlcnZpY2VBbmRFbmRwb2ludFJlZ2lzdGVyQ2xpZW50LmphdmE=) | `44.94% <0%> (+13.48%)` | :arrow_up: |
| [...ache/skywalking/apm/agent/core/jvm/JVMService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL0pWTVNlcnZpY2UuamF2YQ==) | `80.32% <0%> (+16.39%)` | :arrow_up: |
| [...alking/apm/agent/core/remote/AgentIDDecorator.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0FnZW50SUREZWNvcmF0b3IuamF2YQ==) | `85.71% <0%> (+17.85%)` | :arrow_up: |
| [...apm/agent/core/remote/GRPCStreamServiceStatus.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENTdHJlYW1TZXJ2aWNlU3RhdHVzLmphdmE=) | `54.16% <0%> (+25%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [4070afa...14af0f2](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374458744
##########
File path: docs/en/guides/backend-profile.md
##########
@@ -0,0 +1,44 @@
+# Thread dump merging mechanism
+The performance profile is an enhancement feature in the APM system. We are using the thread dump to estimate the method execution time, rather than adding many local spans. In this way, the resource cost would be much less than using distributed tracing to locate slow method. This feature is suitable in the production environment. This document introduces how thread dumps are merged into the final report as a stack tree(s).
+
+## Thread analyst
+### Read data and transform
+Read data from the database and convert it to a data structure in gRPC.
+```
+st=>start: Start
+e=>end: End
+op1=>operation: Load data using paging
+op2=>operation: Transform data using parallel
+
+st(right)->op1(right)->op2
+op2(right)->e
Review comment:
Don't put the image in the source codes. It will increase the payload of source download and release. All documents keep in texts as much as possible. All images must be hosted at the website repo, and only links here. For these comments, we could make it better, but I still think, visualizing on 3rd party system is better.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373835723
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzeCollector.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.stream.Collector;
+
+/**
+ * @author MrPro
+ */
+public class ProfileAnalyzeCollector implements Collector<ProfileStack, ProfileStackNode, ProfileStackElement> {
+ @Override
+ public Supplier<ProfileStackNode> supplier() {
+ return ProfileStackNode::createEmptyNode;
+ }
+
+ @Override
+ public BiConsumer<ProfileStackNode, ProfileStack> accumulator() {
+ return (node, stack) -> node.accumulateFrom(stack);
+ }
+
+ @Override
+ public BinaryOperator<ProfileStackNode> combiner() {
+ return (node1, node2) -> node1.combine(node2);
Review comment:
Lambda can be replaced with method reference
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/4070afa008349e605faf6fd47bad8ea70c1fda81?src=pr&el=desc) will **increase** coverage by `0.18%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
+ Coverage 26.92% 27.1% +0.18%
=========================================
Files 1174 1174
Lines 25606 25606
Branches 3645 3645
=========================================
+ Hits 6894 6941 +47
+ Misses 18108 18059 -49
- Partials 604 606 +2
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `90.09% <ø> (ø)` | :arrow_up: |
| [...king/apm/agent/core/remote/GRPCChannelManager.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsTWFuYWdlci5qYXZh) | `70.51% <0%> (+1.28%)` | :arrow_up: |
| [.../agent/core/context/trace/AbstractTracingSpan.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC90cmFjZS9BYnN0cmFjdFRyYWNpbmdTcGFuLmphdmE=) | `64.6% <0%> (+3.53%)` | :arrow_up: |
| [.../skywalking/apm/agent/core/remote/GRPCChannel.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsLmphdmE=) | `87.5% <0%> (+6.25%)` | :arrow_up: |
| [.../agent/core/profile/ProfileTaskChannelService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcHJvZmlsZS9Qcm9maWxlVGFza0NoYW5uZWxTZXJ2aWNlLmphdmE=) | `44.82% <0%> (+8.04%)` | :arrow_up: |
| [.../core/remote/ServiceAndEndpointRegisterClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1NlcnZpY2VBbmRFbmRwb2ludFJlZ2lzdGVyQ2xpZW50LmphdmE=) | `44.94% <0%> (+13.48%)` | :arrow_up: |
| [...ache/skywalking/apm/agent/core/jvm/JVMService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL0pWTVNlcnZpY2UuamF2YQ==) | `80.32% <0%> (+16.39%)` | :arrow_up: |
| [...alking/apm/agent/core/remote/AgentIDDecorator.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0FnZW50SUREZWNvcmF0b3IuamF2YQ==) | `85.71% <0%> (+17.85%)` | :arrow_up: |
| [...apm/agent/core/remote/GRPCStreamServiceStatus.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENTdHJlYW1TZXJ2aWNlU3RhdHVzLmphdmE=) | `54.16% <0%> (+25%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [4070afa...e139fe0](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] mrproliu commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
mrproliu commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373905496
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
Review comment:
Q1: Using LDR to traversal tree node, and merge children nodes to the parent node.
Q2: Yes. If the stack has large tree stack depth, It will throw StackOverflowError.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373938102
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // add detected stack
+ this.detectedBy(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int depth = 1; depth < stackList.size(); depth++) {
+ String elementCodeSignature = stackList.get(depth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSignature)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // add detected stack
+ childElement.detectedBy(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = newNode();
+ childNode.codeSignature = elementCodeSignature;
+ childNode.detectedBy(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineDetectedStacks(node);
+
+ // merge tree using LDR to traversal tree node
+ // using stack to avoid recursion
+ // merge key.children <- value.children
+ LinkedList<Pair<ProfileStackNode, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, ProfileStackNode> needCombineNode = stack.pop();
+
+ // merge value children to key
+ // add to stack if need to keep traversal
+ combineChildrenNodes(needCombineNode.key, needCombineNode.value, stack::add);
+ }
+
+ return this;
+ }
+
+ /**
+ * merge all children nodes to appoint node
+ * @param mergeTo
+ * @param combineNode
+ * @param needKeepEach if keep traversal, need report
+ */
+ private void combineChildrenNodes(ProfileStackNode mergeTo, ProfileStackNode combineNode, Consumer<Pair<ProfileStackNode, ProfileStackNode>> needKeepEach) {
Review comment:
`needKeepEach` -> `continueChildrenMerging`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373845639
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
Review comment:
Use ArrayList to replace LinkedList as you are doing iteration, array is faster.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373850506
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node.children));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackNode combineTo = needCombineNode.key;
+
+ // merge node
+ for (ProfileStackNode needCombineChildren : needCombineNode.value) {
+ boolean sameReference = false;
+ // find node
+ ProfileStackNode combinedNode = combineTo.children.stream().filter(n -> needCombineChildren.matches(n)).findFirst().orElse(null);
+
+ if (combinedNode == null) {
+ combineTo.children.add(needCombineChildren);
+ combinedNode = needCombineChildren;
+ } else if (needCombineChildren != combinedNode) {
+ combinedNode.combineThisNode(needCombineChildren);
+ } else {
+ // if same reference, dont need to combine anymore
+ sameReference = true;
Review comment:
Why same reference happens?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373939512
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // add detected stack
+ this.detectedBy(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int depth = 1; depth < stackList.size(); depth++) {
+ String elementCodeSignature = stackList.get(depth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSignature)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // add detected stack
+ childElement.detectedBy(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = newNode();
+ childNode.codeSignature = elementCodeSignature;
+ childNode.detectedBy(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineDetectedStacks(node);
+
+ // merge tree using LDR to traversal tree node
+ // using stack to avoid recursion
+ // merge key.children <- value.children
+ LinkedList<Pair<ProfileStackNode, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, ProfileStackNode> needCombineNode = stack.pop();
+
+ // merge value children to key
+ // add to stack if need to keep traversal
+ combineChildrenNodes(needCombineNode.key, needCombineNode.value, stack::add);
+ }
+
+ return this;
+ }
+
+ /**
+ * merge all children nodes to appoint node
+ * @param mergeTo
+ * @param combineNode
+ * @param needKeepEach if keep traversal, need report
+ */
+ private void combineChildrenNodes(ProfileStackNode mergeTo, ProfileStackNode combineNode, Consumer<Pair<ProfileStackNode, ProfileStackNode>> needKeepEach) {
+ for (ProfileStackNode childrenNode : combineNode.children) {
+ // find node from mergeTo children
+ ProfileStackNode combinedNode = mergeTo.children.stream().filter(n -> childrenNode.matches(n)).findFirst().orElse(null);
+
+ if (combinedNode == null) {
+ mergeTo.children.add(childrenNode);
+ } else {
+ combinedNode.combineDetectedStacks(childrenNode);
+ needKeepEach.accept(new Pair<>(combinedNode, childrenNode));
+ }
Review comment:
You are iterating `combineNode` and process found or not, but
1. Once it is found, it has not been removed from `mergeTo`, then all elements all been process multiple times.
1. You seem missing node left in `mergeTo#children`, if some of them are not included in `combineNode`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/baf98d7149d16e439fc144b82548f613addf4357?src=pr&el=desc) will **increase** coverage by `0.02%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
==========================================
+ Coverage 26.88% 26.91% +0.02%
==========================================
Files 1174 1174
Lines 25595 25597 +2
Branches 3641 3641
==========================================
+ Hits 6881 6889 +8
+ Misses 18105 18101 -4
+ Partials 609 607 -2
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `90.21% <100%> (+6.88%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [baf98d7...f7fa324](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373849860
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
Review comment:
- Q1. Which algorithm are you using for tree merging?
- Q2. Are you using the stack to avoid `recursion`? The codes seem understandable, but not very clear.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] mrproliu commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
mrproliu commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373839459
##########
File path: docs/en/setup/backend/backend-profile.md
##########
@@ -0,0 +1,22 @@
+# Profile
Review comment:
has linked to code.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373834686
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ *
+ * @author MrPro
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> childes;
Review comment:
`childes` -> `children`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374144816
##########
File path: oap-server/server-core/src/test/resources/thread-snapshot.yml
##########
@@ -0,0 +1,175 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# verify: read to analyze stack info
+# limit: per stack snapshot dump limit
+# stack: per data means one snapshot, stack elements split by "-"
+# expected: need verify data analyze result
+# info: follow this pattern: codeSignature(duration:durationExcludeChild)
+# children: all children nodes
+
+list:
+ # case 1
Review comment:
This format is much better than the prev one. Let's add one more case
- Case 5
```
A-B-C
A-B
D-E
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/4070afa008349e605faf6fd47bad8ea70c1fda81?src=pr&el=desc) will **increase** coverage by `0.18%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
+ Coverage 26.92% 27.1% +0.18%
=========================================
Files 1174 1174
Lines 25606 25606
Branches 3645 3645
=========================================
+ Hits 6894 6941 +47
+ Misses 18108 18059 -49
- Partials 604 606 +2
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `90.09% <ø> (ø)` | :arrow_up: |
| [...king/apm/agent/core/remote/GRPCChannelManager.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsTWFuYWdlci5qYXZh) | `70.51% <0%> (+1.28%)` | :arrow_up: |
| [.../agent/core/context/trace/AbstractTracingSpan.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC90cmFjZS9BYnN0cmFjdFRyYWNpbmdTcGFuLmphdmE=) | `64.6% <0%> (+3.53%)` | :arrow_up: |
| [.../skywalking/apm/agent/core/remote/GRPCChannel.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsLmphdmE=) | `87.5% <0%> (+6.25%)` | :arrow_up: |
| [.../agent/core/profile/ProfileTaskChannelService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcHJvZmlsZS9Qcm9maWxlVGFza0NoYW5uZWxTZXJ2aWNlLmphdmE=) | `44.82% <0%> (+8.04%)` | :arrow_up: |
| [.../core/remote/ServiceAndEndpointRegisterClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1NlcnZpY2VBbmRFbmRwb2ludFJlZ2lzdGVyQ2xpZW50LmphdmE=) | `44.94% <0%> (+13.48%)` | :arrow_up: |
| [...ache/skywalking/apm/agent/core/jvm/JVMService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL0pWTVNlcnZpY2UuamF2YQ==) | `80.32% <0%> (+16.39%)` | :arrow_up: |
| [...alking/apm/agent/core/remote/AgentIDDecorator.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0FnZW50SUREZWNvcmF0b3IuamF2YQ==) | `85.71% <0%> (+17.85%)` | :arrow_up: |
| [...apm/agent/core/remote/GRPCStreamServiceStatus.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENTdHJlYW1TZXJ2aWNlU3RhdHVzLmphdmE=) | `54.16% <0%> (+25%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [4070afa...e139fe0](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373835767
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzer.java
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import org.apache.skywalking.oap.server.core.query.entity.ProfileAnalyzation;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+import org.apache.skywalking.oap.server.library.util.CollectionUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Analyze {@link ProfileStack} data to {@link ProfileAnalyzation}
+ *
+ * @author MrPro
+ */
+public class ProfileAnalyzer {
+
+ /**
+ * Analyze records
+ * @param stacks
+ * @return
+ */
+ public static ProfileAnalyzation analyze(List<ProfileStack> stacks) {
+ if (CollectionUtils.isEmpty(stacks)) {
+ return null;
+ }
+
+ // using parallel stream
+ Map<String, ProfileStackElement> stackTrees = stacks.parallelStream()
+ // stack list cannot be empty
+ .filter(s -> CollectionUtils.isNotEmpty(s.getStack()))
+ .collect(Collectors.groupingBy(s -> s.getStack().get(0), new ProfileAnalyzeCollector()));
Review comment:
no need to create a new `ProfileAnalyzeCollector` every time, just extract it as a field, or constant
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373835316
##########
File path: docs/en/setup/backend/backend-profile.md
##########
@@ -0,0 +1,22 @@
+# Profile
Review comment:
There is no entrance to this documentation, please link to this file somewhere
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373835719
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileAnalyzeCollector.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.function.BiConsumer;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.stream.Collector;
+
+/**
+ * @author MrPro
+ */
+public class ProfileAnalyzeCollector implements Collector<ProfileStack, ProfileStackNode, ProfileStackElement> {
+ @Override
+ public Supplier<ProfileStackNode> supplier() {
+ return ProfileStackNode::createEmptyNode;
+ }
+
+ @Override
+ public BiConsumer<ProfileStackNode, ProfileStack> accumulator() {
+ return (node, stack) -> node.accumulateFrom(stack);
Review comment:
Lambda can be replaced with method reference
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374096723
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // add detected stack
+ this.detectedBy(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int depth = 1; depth < stackList.size(); depth++) {
+ String elementCodeSignature = stackList.get(depth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSignature)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // add detected stack
+ childElement.detectedBy(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = newNode();
+ childNode.codeSignature = elementCodeSignature;
+ childNode.detectedBy(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineDetectedStacks(node);
+
+ // merge tree using LDR to traversal tree node
+ // using stack to avoid recursion
+ // merge key.children <- value.children
+ LinkedList<Pair<ProfileStackNode, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, ProfileStackNode> needCombineNode = stack.pop();
+
+ // merge value children to key
+ // add to stack if need to keep traversal
+ combineChildrenNodes(needCombineNode.key, needCombineNode.value, stack::add);
+ }
+
+ return this;
+ }
+
+ /**
+ * merge all children nodes to appoint node
+ * @param targetNode
+ * @param beingMergedNode
+ * @param continueChildrenMerging
+ */
+ private void combineChildrenNodes(ProfileStackNode targetNode, ProfileStackNode beingMergedNode, Consumer<Pair<ProfileStackNode, ProfileStackNode>> continueChildrenMerging) {
+ if (beingMergedNode.children.isEmpty()) {
+ return;
+ }
+
+ for (ProfileStackNode childrenNode : targetNode.children) {
+ // find node from being merged node children
+ for (ListIterator<ProfileStackNode> it = beingMergedNode.children.listIterator(); it.hasNext();) {
+ ProfileStackNode node = it.next();
+ if (node != null && node.matches(childrenNode)) {
+ childrenNode.combineDetectedStacks(node);
+ continueChildrenMerging.accept(new Pair<>(childrenNode, node));
+
+ it.set(null);
+ break;
+ }
+ }
+ }
+
+ // targetNode.children add to beingMergedNode.children, merge children to single list
+ int searchingIndex = 0;
+ int beingMergeChildrenCount = beingMergedNode.children.size();
+ for (int nodeInx = 0; nodeInx < targetNode.children.size(); ) {
+ if (searchingIndex >= beingMergeChildrenCount) {
+ beingMergedNode.children.addAll(targetNode.children.subList(nodeInx, targetNode.children.size()));
+ break;
+ }
+ for (; searchingIndex < beingMergeChildrenCount; searchingIndex++) {
+ if (beingMergedNode.children.get(searchingIndex) == null) {
+ beingMergedNode.children.set(searchingIndex, targetNode.children.get(nodeInx));
+ nodeInx++;
+ break;
+ }
+ }
+ }
+ targetNode.children = beingMergedNode.children;
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to single-level list (such as flat), work for parallel calculating
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> nodeMapping = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ nodeMapping.add(new Pair<>(root, this));
+
+ // same with combine logic
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, ProfileStackNode> needCombineNode = stack.pop();
+ ProfileStackElement combineTo = needCombineNode.key;
+
+ // generate children node and add to stack and all node mapping
+ combineTo.setChilds(needCombineNode.value.children.stream().map(c -> {
+ ProfileStackElement element = c.buildElement();
+ Pair<ProfileStackElement, ProfileStackNode> pair = new Pair<>(element, c);
+ stack.add(pair);
+ nodeMapping.add(pair);
+
+ return element;
+ }).collect(Collectors.toList()));
+ }
+
+ // calculate durations
+ nodeMapping.parallelStream().forEach(t -> t.value.calculateDuration(t.key));
+ nodeMapping.parallelStream().forEach(t -> t.value.calculateDurationExcludeChild(t.key));
Review comment:
Why run `parallelStream` twice? Calculating two kinds of duration should be faster.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/4070afa008349e605faf6fd47bad8ea70c1fda81?src=pr&el=desc) will **increase** coverage by `0.19%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
==========================================
+ Coverage 26.92% 27.12% +0.19%
==========================================
Files 1174 1174
Lines 25606 25606
Branches 3645 3645
==========================================
+ Hits 6894 6945 +51
+ Misses 18108 18058 -50
+ Partials 604 603 -1
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../agent/core/context/trace/AbstractTracingSpan.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC90cmFjZS9BYnN0cmFjdFRyYWNpbmdTcGFuLmphdmE=) | `64.6% <0%> (+3.53%)` | :arrow_up: |
| [.../skywalking/apm/agent/core/remote/GRPCChannel.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsLmphdmE=) | `87.5% <0%> (+6.25%)` | :arrow_up: |
| [...king/apm/agent/core/remote/GRPCChannelManager.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsTWFuYWdlci5qYXZh) | `75.64% <0%> (+6.41%)` | :arrow_up: |
| [.../agent/core/profile/ProfileTaskChannelService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcHJvZmlsZS9Qcm9maWxlVGFza0NoYW5uZWxTZXJ2aWNlLmphdmE=) | `44.82% <0%> (+8.04%)` | :arrow_up: |
| [.../core/remote/ServiceAndEndpointRegisterClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1NlcnZpY2VBbmRFbmRwb2ludFJlZ2lzdGVyQ2xpZW50LmphdmE=) | `44.94% <0%> (+13.48%)` | :arrow_up: |
| [...ache/skywalking/apm/agent/core/jvm/JVMService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL0pWTVNlcnZpY2UuamF2YQ==) | `80.32% <0%> (+16.39%)` | :arrow_up: |
| [...alking/apm/agent/core/remote/AgentIDDecorator.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0FnZW50SUREZWNvcmF0b3IuamF2YQ==) | `85.71% <0%> (+17.85%)` | :arrow_up: |
| [...apm/agent/core/remote/GRPCStreamServiceStatus.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENTdHJlYW1TZXJ2aWNlU3RhdHVzLmphdmE=) | `54.16% <0%> (+25%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [4070afa...c3ab10f](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/baf98d7149d16e439fc144b82548f613addf4357?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
==========================================
- Coverage 26.88% 26.88% -0.01%
==========================================
Files 1174 1174
Lines 25595 25614 +19
Branches 3641 3647 +6
==========================================
+ Hits 6881 6886 +5
- Misses 18105 18121 +16
+ Partials 609 607 -2
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `91.74% <100%> (+8.4%)` | :arrow_up: |
| [...ache/skywalking/apm/agent/core/jvm/JVMService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL0pWTVNlcnZpY2UuamF2YQ==) | `59.01% <0%> (-18.04%)` | :arrow_down: |
| [...alking/apm/agent/core/remote/AgentIDDecorator.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0FnZW50SUREZWNvcmF0b3IuamF2YQ==) | `67.85% <0%> (-17.86%)` | :arrow_down: |
| [.../core/remote/ServiceAndEndpointRegisterClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1NlcnZpY2VBbmRFbmRwb2ludFJlZ2lzdGVyQ2xpZW50LmphdmE=) | `28.08% <0%> (-3.38%)` | :arrow_down: |
| [...m/agent/core/remote/TraceSegmentServiceClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1RyYWNlU2VnbWVudFNlcnZpY2VDbGllbnQuamF2YQ==) | `80.88% <0%> (-1.48%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [baf98d7...7f2e5b7](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373845903
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node.children));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackNode combineTo = needCombineNode.key;
+
+ // merge node
+ for (ProfileStackNode needCombineChildren : needCombineNode.value) {
+ boolean sameReference = false;
+ // find node
+ ProfileStackNode combinedNode = combineTo.children.stream().filter(n -> needCombineChildren.matches(n)).findFirst().orElse(null);
+
+ if (combinedNode == null) {
+ combineTo.children.add(needCombineChildren);
+ combinedNode = needCombineChildren;
+ } else if (needCombineChildren != combinedNode) {
+ combinedNode.combineThisNode(needCombineChildren);
+ } else {
+ // if same reference, dont need to combine anymore
+ sameReference = true;
+ }
+
+ if (!sameReference) {
+ stack.add(new Pair<>(combinedNode, needCombineChildren.children));
+ }
+ }
+ }
+
+ return this;
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to one list, work for parallel calculating
+ LinkedList<Pair<ProfileStackNode, ProfileStackElement>> allNodes = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ allNodes.add(new Pair<>(this, root));
+
+ // using pre order, build element tree
+ LinkedList<Pair<ProfileStackElement, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this.children));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackElement combineTo = needCombineNode.key;
+
+ combineTo.setChilds(needCombineNode.value.stream().map(c -> {
+ ProfileStackElement element = c.buildElement();
+ stack.add(new Pair<>(element, c.children));
+
+ allNodes.add(new Pair<>(c, element));
+
+ return element;
+ }).collect(Collectors.toList()));
+ }
+
+ // calculate durations
+ allNodes.parallelStream().forEach(t -> t.key.calculateDuration(t.value));
+ allNodes.parallelStream().forEach(t -> t.key.calculateDurationExcludeChild(t.value));
+
+ return root;
+ }
+
+ private void increase(ProfileStack stack) {
+ this.owners.add(stack);
+ }
+
+ private void combineThisNode(ProfileStackNode node) {
Review comment:
`combineThisNode` -> `combineDetectedStacks`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374093684
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // add detected stack
+ this.detectedBy(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int depth = 1; depth < stackList.size(); depth++) {
+ String elementCodeSignature = stackList.get(depth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSignature)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // add detected stack
+ childElement.detectedBy(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = newNode();
+ childNode.codeSignature = elementCodeSignature;
+ childNode.detectedBy(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineDetectedStacks(node);
+
+ // merge tree using LDR to traversal tree node
+ // using stack to avoid recursion
+ // merge key.children <- value.children
+ LinkedList<Pair<ProfileStackNode, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, ProfileStackNode> needCombineNode = stack.pop();
+
+ // merge value children to key
+ // add to stack if need to keep traversal
+ combineChildrenNodes(needCombineNode.key, needCombineNode.value, stack::add);
+ }
+
+ return this;
+ }
+
+ /**
+ * merge all children nodes to appoint node
+ * @param targetNode
+ * @param beingMergedNode
+ * @param continueChildrenMerging
+ */
+ private void combineChildrenNodes(ProfileStackNode targetNode, ProfileStackNode beingMergedNode, Consumer<Pair<ProfileStackNode, ProfileStackNode>> continueChildrenMerging) {
+ if (beingMergedNode.children.isEmpty()) {
+ return;
+ }
+
+ for (ProfileStackNode childrenNode : targetNode.children) {
+ // find node from being merged node children
+ for (ListIterator<ProfileStackNode> it = beingMergedNode.children.listIterator(); it.hasNext();) {
+ ProfileStackNode node = it.next();
+ if (node != null && node.matches(childrenNode)) {
+ childrenNode.combineDetectedStacks(node);
+ continueChildrenMerging.accept(new Pair<>(childrenNode, node));
+
+ it.set(null);
+ break;
+ }
+ }
+ }
+
+ // targetNode.children add to beingMergedNode.children, merge children to single list
+ int searchingIndex = 0;
+ int beingMergeChildrenCount = beingMergedNode.children.size();
+ for (int nodeInx = 0; nodeInx < targetNode.children.size(); ) {
+ if (searchingIndex >= beingMergeChildrenCount) {
+ beingMergedNode.children.addAll(targetNode.children.subList(nodeInx, targetNode.children.size()));
+ break;
+ }
+ for (; searchingIndex < beingMergeChildrenCount; searchingIndex++) {
+ if (beingMergedNode.children.get(searchingIndex) == null) {
+ beingMergedNode.children.set(searchingIndex, targetNode.children.get(nodeInx));
+ nodeInx++;
+ break;
+ }
+ }
+ }
+ targetNode.children = beingMergedNode.children;
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to single-level list (such as flat), work for parallel calculating
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> nodeMapping = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ nodeMapping.add(new Pair<>(root, this));
+
+ // same with combine logic
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, ProfileStackNode> needCombineNode = stack.pop();
+ ProfileStackElement combineTo = needCombineNode.key;
Review comment:
`combineTo` -> `respElement`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373835447
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ *
+ * @author MrPro
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> childes;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.childes = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.childes) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.childes.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node.childes));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackNode combineTo = needCombineNode.key;
+
+ // merge node
+ for (ProfileStackNode needCombineChildren : needCombineNode.value) {
+ boolean sameReference = false;
+ // find node
+ ProfileStackNode combinedNode = null;
+ for (ProfileStackNode combineNodeChildren : combineTo.childes) {
+ // same code signature
+ if (Objects.equal(needCombineChildren.codeSignature, combineNodeChildren.codeSignature)) {
+ // if same reference, dont need to combine anymore
+ if (needCombineChildren == combineNodeChildren) {
+ sameReference = true;
+ } else {
+ combineNodeChildren.combineThisNode(needCombineChildren);
+ }
+ combinedNode = combineNodeChildren;
+ break;
+ }
+ }
+
+ if (combinedNode == null) {
+ combineTo.childes.add(needCombineChildren);
+ combinedNode = needCombineChildren;
+ }
+
+ if (!sameReference) {
+ stack.add(new Pair(combinedNode, needCombineChildren.childes));
+ }
+ }
+ }
+
+ return this;
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to one list, work for parallel calculating
+ LinkedList<Pair<ProfileStackNode, ProfileStackElement>> allNodes = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ allNodes.add(new Pair<>(this, root));
+
+ // using pre order, build element tree
+ LinkedList<Pair<ProfileStackElement, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this.childes));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackElement combineTo = needCombineNode.key;
+
+ combineTo.setChilds(needCombineNode.value.stream().map((c) -> {
+ ProfileStackElement element = c.buildElement();
+ stack.add(new Pair<>(element, c.childes));
+
+ allNodes.add(new Pair<>(c, element));
+
+ return element;
+ }).collect(Collectors.toList()));
+ }
+
+ // calculate durations
+ allNodes.parallelStream().forEach(t -> t.key.calculateDuration(t.value));
+ allNodes.parallelStream().forEach(t -> t.key.calculateDurationExcludeChild(t.value));
+
+ return root;
+ }
+
+ private void increase(ProfileStack stack) {
+ this.owners.add(stack);
+ }
+
+ private void combineThisNode(ProfileStackNode node) {
+ this.owners.addAll(node.owners);
+ }
+
+ private ProfileStackElement buildElement() {
+ ProfileStackElement element = new ProfileStackElement();
+ element.setCodeSignature(this.codeSignature);
+ element.setChilds(new LinkedList<>());
+ element.setCount(this.owners.size());
+ return element;
+ }
+
+ /**
+ * calculate duration to {@link ProfileStackElement#getDuration()}
+ */
+ private void calculateDuration(ProfileStackElement element) {
+ if (this.owners.size() <= 1) {
+ element.setDuration(0);
+ return;
+ }
+
+ // sort owners
+ Collections.sort(this.owners);
+
+ // calculate time windows duration
+ ProfileStack currentTimeWindowStartStack = owners.get(0);
+ ProfileStack currentTimeWindowEndTack = owners.get(0);
+ long duration = 0;
+ for (ListIterator<ProfileStack> it = owners.listIterator(1); it.hasNext(); ) {
+ ProfileStack currentStack = it.next();
+
+ // is continuity
+ if (currentTimeWindowEndTack.getSequence() + 1 != currentStack.getSequence()) {
+ duration += currentTimeWindowEndTack.getDumpTime() - currentTimeWindowStartStack.getDumpTime();
+ currentTimeWindowStartStack = currentTimeWindowEndTack;
+ }
+
+ currentTimeWindowEndTack = currentStack;
+ }
+
+ // calculate last one time windows
+ duration += currentTimeWindowEndTack.getDumpTime() - currentTimeWindowStartStack.getDumpTime();
+
+ this.duration = Math.toIntExact(duration);
+ element.setDuration(this.duration);
+ }
+
+ /**
+ * calculate duration to {@link ProfileStackElement#getDurationChildExcluded()}, expends on {@link #calculateDuration(ProfileStackElement)}
+ * @param element
+ */
+ private void calculateDurationExcludeChild(ProfileStackElement element) {
+ element.setDurationChildExcluded(element.getDuration() - childes.stream().mapToInt(t->t.duration).sum());
+ }
+
+ private class Pair<K, V> {
Review comment:
Inner class 'Pair' may be 'static'
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] mrproliu commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
mrproliu commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373901774
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node.children));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackNode combineTo = needCombineNode.key;
+
+ // merge node
+ for (ProfileStackNode needCombineChildren : needCombineNode.value) {
+ boolean sameReference = false;
+ // find node
+ ProfileStackNode combinedNode = combineTo.children.stream().filter(n -> needCombineChildren.matches(n)).findFirst().orElse(null);
+
+ if (combinedNode == null) {
+ combineTo.children.add(needCombineChildren);
+ combinedNode = needCombineChildren;
+ } else if (needCombineChildren != combinedNode) {
+ combinedNode.combineThisNode(needCombineChildren);
+ } else {
+ // if same reference, dont need to combine anymore
+ sameReference = true;
Review comment:
It's a bug, has fixed. If combine node from B -> A, A node not found, just need to add children node, don't need to keep merge child.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] mrproliu commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
mrproliu commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373901868
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
Review comment:
change `children` field to ArrayList.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on issue #4308: provide thread
stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581792828
FYI @kezhenxu94 The whole profile should work for CLI too. We should add an issue to track.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@a89ab30`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `78%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
Coverage ? 26.89%
=========================================
Files ? 1174
Lines ? 25600
Branches ? 3643
=========================================
Hits ? 6886
Misses ? 18105
Partials ? 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../oap/server/core/profile/analyze/ProfileStack.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFjay5qYXZh) | `8.33% <0%> (ø)` | |
| [...p/server/core/profile/analyze/ProfileAnalyzer.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplci5qYXZh) | `77.77% <100%> (ø)` | |
| [...pache/skywalking/apm/agent/core/base64/Base64.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvYmFzZTY0L0Jhc2U2NC5qYXZh) | `100% <100%> (ø)` | |
| [.../core/profile/analyze/ProfileAnalyzeCollector.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplQ29sbGVjdG9yLmphdmE=) | `100% <100%> (ø)` | |
| [...walking/apm/agent/core/context/ContextCarrier.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9Db250ZXh0Q2Fycmllci5qYXZh) | `70% <57.14%> (ø)` | |
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `84.21% <94.11%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [a89ab30...7e52d1a](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373850898
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node.children));
Review comment:
Why don't you use the same depth of key and value? In the following codes, you always use `combineTo.children`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374457681
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // add detected stack
+ this.detectedBy(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int depth = 1; depth < stackList.size(); depth++) {
+ String elementCodeSignature = stackList.get(depth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSignature)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // add detected stack
+ childElement.detectedBy(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = newNode();
+ childNode.codeSignature = elementCodeSignature;
+ childNode.detectedBy(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineDetectedStacks(node);
+
+ // merge tree using LDR to traversal tree node
+ // using stack to avoid recursion
+ // merge key.children <- value.children
+ LinkedList<Pair<ProfileStackNode, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, ProfileStackNode> needCombineNode = stack.pop();
+
+ // merge value children to key
+ // add to stack if need to keep traversal
+ combineChildrenNodes(needCombineNode.key, needCombineNode.value, stack::add);
+ }
+
+ return this;
+ }
+
+ /**
+ * merge all children nodes to appoint node
+ * @param targetNode
+ * @param beingMergedNode
+ * @param continueChildrenMerging
+ */
+ private void combineChildrenNodes(ProfileStackNode targetNode, ProfileStackNode beingMergedNode, Consumer<Pair<ProfileStackNode, ProfileStackNode>> continueChildrenMerging) {
+ if (beingMergedNode.children.isEmpty()) {
+ return;
+ }
+
+ for (ProfileStackNode childrenNode : targetNode.children) {
+ // find node from being merged node children
+ for (ListIterator<ProfileStackNode> it = beingMergedNode.children.listIterator(); it.hasNext();) {
+ ProfileStackNode node = it.next();
+ if (node != null && node.matches(childrenNode)) {
+ childrenNode.combineDetectedStacks(node);
+ continueChildrenMerging.accept(new Pair<>(childrenNode, node));
+
+ it.set(null);
+ break;
+ }
+ }
+ }
+
+ for (ProfileStackNode node : beingMergedNode.children) {
+ if (node != null) {
+ targetNode.children.add(node);
+ }
+ }
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to single-level list (such as flat), work for parallel calculating
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> nodeMapping = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ nodeMapping.add(new Pair<>(root, this));
+
+ // same with combine logic
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, ProfileStackNode> mergingPair = stack.pop();
+ ProfileStackElement respElement = mergingPair.key;
+
+ // generate children node and add to stack and all node mapping
+ respElement.setChildren(mergingPair.value.children.stream().map(c -> {
+ ProfileStackElement element = c.buildElement();
+ Pair<ProfileStackElement, ProfileStackNode> pair = new Pair<>(element, c);
+ stack.add(pair);
+ nodeMapping.add(pair);
+
+ return element;
+ }).collect(Collectors.toList()));
+ }
+
+ // calculate durations
+ nodeMapping.parallelStream().forEach(t -> t.value.calculateDuration(t.key));
+ nodeMapping.parallelStream().forEach(t -> t.value.calculateDurationExcludeChild(t.key));
+
+ return root;
+ }
+
+ private void detectedBy(ProfileStack stack) {
+ this.detectedStacks.add(stack);
+ }
+
+ private void combineDetectedStacks(ProfileStackNode node) {
+ this.detectedStacks.addAll(node.detectedStacks);
+ }
+
+ private ProfileStackElement buildElement() {
+ ProfileStackElement element = new ProfileStackElement();
+ element.setCodeSignature(this.codeSignature);
+ element.setChildren(new LinkedList<>());
+ element.setCount(this.detectedStacks.size());
+ return element;
+ }
+
+ /**
+ * calculate duration to {@link ProfileStackElement#getDuration()}
+ */
+ private void calculateDuration(ProfileStackElement element) {
+ if (this.detectedStacks.size() <= 1) {
+ element.setDuration(0);
+ return;
+ }
+
+ // sort owners
Review comment:
`owners` -> `detectedStacks`, but I think the code itself is documentation already
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io commented on issue #4308: provide thread
stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@a89ab30`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `72.72%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
Coverage ? 26.93%
=========================================
Files ? 1174
Lines ? 25603
Branches ? 3645
=========================================
Hits ? 6896
Misses ? 18098
Partials ? 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `84.84% <100%> (ø)` | |
| [...pache/skywalking/apm/agent/core/base64/Base64.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvYmFzZTY0L0Jhc2U2NC5qYXZh) | `100% <100%> (ø)` | |
| [...p/server/core/profile/analyze/ProfileAnalyzer.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplci5qYXZh) | `75% <100%> (ø)` | |
| [.../core/profile/analyze/ProfileAnalyzeCollector.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplQ29sbGVjdG9yLmphdmE=) | `100% <100%> (ø)` | |
| [...walking/apm/agent/core/context/ContextCarrier.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9Db250ZXh0Q2Fycmllci5qYXZh) | `70% <57.14%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [a89ab30...50c9875](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374093528
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // add detected stack
+ this.detectedBy(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int depth = 1; depth < stackList.size(); depth++) {
+ String elementCodeSignature = stackList.get(depth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSignature)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // add detected stack
+ childElement.detectedBy(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = newNode();
+ childNode.codeSignature = elementCodeSignature;
+ childNode.detectedBy(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineDetectedStacks(node);
+
+ // merge tree using LDR to traversal tree node
+ // using stack to avoid recursion
+ // merge key.children <- value.children
+ LinkedList<Pair<ProfileStackNode, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, ProfileStackNode> needCombineNode = stack.pop();
+
+ // merge value children to key
+ // add to stack if need to keep traversal
+ combineChildrenNodes(needCombineNode.key, needCombineNode.value, stack::add);
+ }
+
+ return this;
+ }
+
+ /**
+ * merge all children nodes to appoint node
+ * @param targetNode
+ * @param beingMergedNode
+ * @param continueChildrenMerging
+ */
+ private void combineChildrenNodes(ProfileStackNode targetNode, ProfileStackNode beingMergedNode, Consumer<Pair<ProfileStackNode, ProfileStackNode>> continueChildrenMerging) {
+ if (beingMergedNode.children.isEmpty()) {
+ return;
+ }
+
+ for (ProfileStackNode childrenNode : targetNode.children) {
+ // find node from being merged node children
+ for (ListIterator<ProfileStackNode> it = beingMergedNode.children.listIterator(); it.hasNext();) {
+ ProfileStackNode node = it.next();
+ if (node != null && node.matches(childrenNode)) {
+ childrenNode.combineDetectedStacks(node);
+ continueChildrenMerging.accept(new Pair<>(childrenNode, node));
+
+ it.set(null);
+ break;
+ }
+ }
+ }
+
+ // targetNode.children add to beingMergedNode.children, merge children to single list
+ int searchingIndex = 0;
+ int beingMergeChildrenCount = beingMergedNode.children.size();
+ for (int nodeInx = 0; nodeInx < targetNode.children.size(); ) {
+ if (searchingIndex >= beingMergeChildrenCount) {
+ beingMergedNode.children.addAll(targetNode.children.subList(nodeInx, targetNode.children.size()));
+ break;
+ }
+ for (; searchingIndex < beingMergeChildrenCount; searchingIndex++) {
+ if (beingMergedNode.children.get(searchingIndex) == null) {
+ beingMergedNode.children.set(searchingIndex, targetNode.children.get(nodeInx));
+ nodeInx++;
+ break;
+ }
+ }
+ }
+ targetNode.children = beingMergedNode.children;
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to single-level list (such as flat), work for parallel calculating
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> nodeMapping = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ nodeMapping.add(new Pair<>(root, this));
+
+ // same with combine logic
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, ProfileStackNode> needCombineNode = stack.pop();
Review comment:
`needCombineNode` -> `MergingPair`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@a89ab30`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `78%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
Coverage ? 26.92%
=========================================
Files ? 1174
Lines ? 25600
Branches ? 3643
=========================================
Hits ? 6893
Misses ? 18098
Partials ? 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../oap/server/core/profile/analyze/ProfileStack.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFjay5qYXZh) | `8.33% <0%> (ø)` | |
| [...p/server/core/profile/analyze/ProfileAnalyzer.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplci5qYXZh) | `77.77% <100%> (ø)` | |
| [...pache/skywalking/apm/agent/core/base64/Base64.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvYmFzZTY0L0Jhc2U2NC5qYXZh) | `100% <100%> (ø)` | |
| [.../core/profile/analyze/ProfileAnalyzeCollector.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplQ29sbGVjdG9yLmphdmE=) | `100% <100%> (ø)` | |
| [...walking/apm/agent/core/context/ContextCarrier.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9Db250ZXh0Q2Fycmllci5qYXZh) | `70% <57.14%> (ø)` | |
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `84.21% <94.11%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [a89ab30...c7e2c4d](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373845784
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
Review comment:
`childDepth` -> `depth`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/baf98d7149d16e439fc144b82548f613addf4357?src=pr&el=desc) will **decrease** coverage by `0.07%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
- Coverage 26.88% 26.8% -0.08%
=========================================
Files 1174 1174
Lines 25595 25595
Branches 3641 3641
=========================================
- Hits 6881 6861 -20
- Misses 18105 18125 +20
Partials 609 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...ache/skywalking/apm/agent/core/jvm/JVMService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL0pWTVNlcnZpY2UuamF2YQ==) | `59.01% <0%> (-18.04%)` | :arrow_down: |
| [...alking/apm/agent/core/remote/AgentIDDecorator.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0FnZW50SUREZWNvcmF0b3IuamF2YQ==) | `67.85% <0%> (-17.86%)` | :arrow_down: |
| [.../core/remote/ServiceAndEndpointRegisterClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1NlcnZpY2VBbmRFbmRwb2ludFJlZ2lzdGVyQ2xpZW50LmphdmE=) | `28.08% <0%> (-3.38%)` | :arrow_down: |
| [...m/agent/core/remote/TraceSegmentServiceClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1RyYWNlU2VnbWVudFNlcnZpY2VDbGllbnQuamF2YQ==) | `80.88% <0%> (-1.48%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [baf98d7...987a995](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373845769
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
Review comment:
`elementCodeSign` -> `elementCodeSignature `
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng merged pull request #4308: provide thread
stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng merged pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@a89ab30`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `72.72%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
========================================
Coverage ? 26.9%
========================================
Files ? 1174
Lines ? 25603
Branches ? 3645
========================================
Hits ? 6889
Misses ? 18105
Partials ? 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `84.84% <100%> (ø)` | |
| [...pache/skywalking/apm/agent/core/base64/Base64.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvYmFzZTY0L0Jhc2U2NC5qYXZh) | `100% <100%> (ø)` | |
| [...p/server/core/profile/analyze/ProfileAnalyzer.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplci5qYXZh) | `75% <100%> (ø)` | |
| [.../core/profile/analyze/ProfileAnalyzeCollector.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplQ29sbGVjdG9yLmphdmE=) | `100% <100%> (ø)` | |
| [...walking/apm/agent/core/context/ContextCarrier.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9Db250ZXh0Q2Fycmllci5qYXZh) | `70% <57.14%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [a89ab30...a289b9e](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/baf98d7149d16e439fc144b82548f613addf4357?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=======================================
Coverage 26.88% 26.88%
=======================================
Files 1174 1174
Lines 25595 25595
Branches 3641 3641
=======================================
Hits 6881 6881
Misses 18105 18105
Partials 609 609
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [baf98d7...987a995](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/4070afa008349e605faf6fd47bad8ea70c1fda81?src=pr&el=desc) will **increase** coverage by `0.18%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
+ Coverage 26.92% 27.1% +0.18%
=========================================
Files 1174 1174
Lines 25606 25606
Branches 3645 3645
=========================================
+ Hits 6894 6941 +47
+ Misses 18108 18059 -49
- Partials 604 606 +2
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `90.09% <ø> (ø)` | :arrow_up: |
| [...king/apm/agent/core/remote/GRPCChannelManager.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsTWFuYWdlci5qYXZh) | `70.51% <0%> (+1.28%)` | :arrow_up: |
| [.../agent/core/context/trace/AbstractTracingSpan.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC90cmFjZS9BYnN0cmFjdFRyYWNpbmdTcGFuLmphdmE=) | `64.6% <0%> (+3.53%)` | :arrow_up: |
| [.../skywalking/apm/agent/core/remote/GRPCChannel.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENDaGFubmVsLmphdmE=) | `87.5% <0%> (+6.25%)` | :arrow_up: |
| [.../agent/core/profile/ProfileTaskChannelService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcHJvZmlsZS9Qcm9maWxlVGFza0NoYW5uZWxTZXJ2aWNlLmphdmE=) | `44.82% <0%> (+8.04%)` | :arrow_up: |
| [.../core/remote/ServiceAndEndpointRegisterClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1NlcnZpY2VBbmRFbmRwb2ludFJlZ2lzdGVyQ2xpZW50LmphdmE=) | `44.94% <0%> (+13.48%)` | :arrow_up: |
| [...ache/skywalking/apm/agent/core/jvm/JVMService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL0pWTVNlcnZpY2UuamF2YQ==) | `80.32% <0%> (+16.39%)` | :arrow_up: |
| [...alking/apm/agent/core/remote/AgentIDDecorator.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0FnZW50SUREZWNvcmF0b3IuamF2YQ==) | `85.71% <0%> (+17.85%)` | :arrow_up: |
| [...apm/agent/core/remote/GRPCStreamServiceStatus.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0dSUENTdHJlYW1TZXJ2aWNlU3RhdHVzLmphdmE=) | `54.16% <0%> (+25%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [4070afa...fd6d945](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373845609
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
Review comment:
Rename `owners` -> `detectedStacks`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373845685
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.children = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node.children));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackNode combineTo = needCombineNode.key;
+
+ // merge node
+ for (ProfileStackNode needCombineChildren : needCombineNode.value) {
+ boolean sameReference = false;
+ // find node
+ ProfileStackNode combinedNode = combineTo.children.stream().filter(n -> needCombineChildren.matches(n)).findFirst().orElse(null);
+
+ if (combinedNode == null) {
+ combineTo.children.add(needCombineChildren);
+ combinedNode = needCombineChildren;
+ } else if (needCombineChildren != combinedNode) {
+ combinedNode.combineThisNode(needCombineChildren);
+ } else {
+ // if same reference, dont need to combine anymore
+ sameReference = true;
+ }
+
+ if (!sameReference) {
+ stack.add(new Pair<>(combinedNode, needCombineChildren.children));
+ }
+ }
+ }
+
+ return this;
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to one list, work for parallel calculating
+ LinkedList<Pair<ProfileStackNode, ProfileStackElement>> allNodes = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ allNodes.add(new Pair<>(this, root));
+
+ // using pre order, build element tree
+ LinkedList<Pair<ProfileStackElement, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this.children));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackElement combineTo = needCombineNode.key;
+
+ combineTo.setChilds(needCombineNode.value.stream().map(c -> {
+ ProfileStackElement element = c.buildElement();
+ stack.add(new Pair<>(element, c.children));
+
+ allNodes.add(new Pair<>(c, element));
+
+ return element;
+ }).collect(Collectors.toList()));
+ }
+
+ // calculate durations
+ allNodes.parallelStream().forEach(t -> t.key.calculateDuration(t.value));
+ allNodes.parallelStream().forEach(t -> t.key.calculateDurationExcludeChild(t.value));
+
+ return root;
+ }
+
+ private void increase(ProfileStack stack) {
Review comment:
`increase` -> `detectedBy`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374096475
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ private String codeSignature;
+ private List<ProfileStack> detectedStacks;
+ private List<ProfileStackNode> children;
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode newNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.detectedStacks = new LinkedList<>();
+ emptyNode.children = new ArrayList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // add detected stack
+ this.detectedBy(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int depth = 1; depth < stackList.size(); depth++) {
+ String elementCodeSignature = stackList.get(depth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.children) {
+ if (Objects.equal(child.codeSignature, elementCodeSignature)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // add detected stack
+ childElement.detectedBy(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = newNode();
+ childNode.codeSignature = elementCodeSignature;
+ childNode.detectedBy(stack);
+
+ parent.children.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineDetectedStacks(node);
+
+ // merge tree using LDR to traversal tree node
+ // using stack to avoid recursion
+ // merge key.children <- value.children
+ LinkedList<Pair<ProfileStackNode, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, ProfileStackNode> needCombineNode = stack.pop();
+
+ // merge value children to key
+ // add to stack if need to keep traversal
+ combineChildrenNodes(needCombineNode.key, needCombineNode.value, stack::add);
+ }
+
+ return this;
+ }
+
+ /**
+ * merge all children nodes to appoint node
+ * @param targetNode
+ * @param beingMergedNode
+ * @param continueChildrenMerging
+ */
+ private void combineChildrenNodes(ProfileStackNode targetNode, ProfileStackNode beingMergedNode, Consumer<Pair<ProfileStackNode, ProfileStackNode>> continueChildrenMerging) {
+ if (beingMergedNode.children.isEmpty()) {
+ return;
+ }
+
+ for (ProfileStackNode childrenNode : targetNode.children) {
+ // find node from being merged node children
+ for (ListIterator<ProfileStackNode> it = beingMergedNode.children.listIterator(); it.hasNext();) {
+ ProfileStackNode node = it.next();
+ if (node != null && node.matches(childrenNode)) {
+ childrenNode.combineDetectedStacks(node);
+ continueChildrenMerging.accept(new Pair<>(childrenNode, node));
+
+ it.set(null);
+ break;
+ }
+ }
+ }
+
+ // targetNode.children add to beingMergedNode.children, merge children to single list
+ int searchingIndex = 0;
+ int beingMergeChildrenCount = beingMergedNode.children.size();
+ for (int nodeInx = 0; nodeInx < targetNode.children.size(); ) {
+ if (searchingIndex >= beingMergeChildrenCount) {
+ beingMergedNode.children.addAll(targetNode.children.subList(nodeInx, targetNode.children.size()));
+ break;
+ }
+ for (; searchingIndex < beingMergeChildrenCount; searchingIndex++) {
+ if (beingMergedNode.children.get(searchingIndex) == null) {
+ beingMergedNode.children.set(searchingIndex, targetNode.children.get(nodeInx));
+ nodeInx++;
+ break;
+ }
+ }
+ }
+ targetNode.children = beingMergedNode.children;
+ }
+
+ /**
+ * build GraphQL result, calculate duration and count data using parallels
+ * @return
+ */
+ public ProfileStackElement buildAnalyzeResult() {
+ // all nodes add to single-level list (such as flat), work for parallel calculating
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> nodeMapping = new LinkedList<>();
+ ProfileStackElement root = buildElement();
+ nodeMapping.add(new Pair<>(root, this));
+
+ // same with combine logic
+ LinkedList<Pair<ProfileStackElement, ProfileStackNode>> stack = new LinkedList<>();
+ stack.add(new Pair<>(root, this));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackElement, ProfileStackNode> needCombineNode = stack.pop();
+ ProfileStackElement combineTo = needCombineNode.key;
+
+ // generate children node and add to stack and all node mapping
+ combineTo.setChilds(needCombineNode.value.children.stream().map(c -> {
+ ProfileStackElement element = c.buildElement();
+ Pair<ProfileStackElement, ProfileStackNode> pair = new Pair<>(element, c);
+ stack.add(pair);
+ nodeMapping.add(pair);
+
+ return element;
+ }).collect(Collectors.toList()));
+ }
+
+ // calculate durations
+ nodeMapping.parallelStream().forEach(t -> t.value.calculateDuration(t.key));
Review comment:
Why require `ProfileStackNode`(t.value) to calculate duration? Using List<ProfileStackElement> should be enough
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373834506
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStack.java
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.primitives.Ints;
+import com.google.protobuf.InvalidProtocolBufferException;
+import lombok.Data;
+import org.apache.skywalking.apm.network.language.profile.ThreadStack;
+import org.apache.skywalking.oap.server.core.profile.ProfileTaskSegmentSnapshotRecord;
+
+import java.util.List;
+
+/**
+ * Deserialize from {@link ProfileTaskSegmentSnapshotRecord}
+ *
+ * @author MrPro
+ */
+@Data
+public class ProfileStack implements Comparable<ProfileStack> {
+
+ private int sequence;
+ private long dumpTime;
+ private List<String> stack;
+
+ public static ProfileStack deserialize(ProfileTaskSegmentSnapshotRecord record) {
+ ThreadStack threadStack = null;
+ try {
+ threadStack = ThreadStack.parseFrom(record.getStackBinary());
+ } catch (InvalidProtocolBufferException e) {
+ new IllegalArgumentException("wrong stack data");
Review comment:
```suggestion
throw new IllegalArgumentException("wrong stack data");
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373845731
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> children;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
Review comment:
`createEmptyNode` -> `newNode`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/4070afa008349e605faf6fd47bad8ea70c1fda81?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=======================================
Coverage 26.92% 26.92%
=======================================
Files 1174 1174
Lines 25606 25606
Branches 3645 3645
=======================================
Hits 6894 6894
Misses 18108 18108
Partials 604 604
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [4070afa...c3ab10f](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/baf98d7149d16e439fc144b82548f613addf4357?src=pr&el=desc) will **increase** coverage by `0.03%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
==========================================
+ Coverage 26.88% 26.91% +0.03%
==========================================
Files 1174 1174
Lines 25595 25597 +2
Branches 3641 3641
==========================================
+ Hits 6881 6890 +9
+ Misses 18105 18098 -7
Partials 609 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `83.69% <100%> (+0.36%)` | :arrow_up: |
| [.../agent/core/profile/ProfileTaskChannelService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcHJvZmlsZS9Qcm9maWxlVGFza0NoYW5uZWxTZXJ2aWNlLmphdmE=) | `36.78% <0%> (+8.04%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [baf98d7...2a1cfc3](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] mrproliu commented on issue #4308: provide thread
stack analyzes
Posted by GitBox <gi...@apache.org>.
mrproliu commented on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581128001
> And we plan to remove all the `@author` tags since it's an ASF project, better to remove those in newly-added files
Sure, removed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request
#4308: provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r373835463
##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profile/analyze/ProfileStackNode.java
##########
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.core.profile.analyze;
+
+import com.google.common.base.Objects;
+import org.apache.skywalking.oap.server.core.query.entity.ProfileStackElement;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.stream.Collectors;
+
+/**
+ * Work for profiling stacks, intermediate state of the {@link ProfileStackElement} and {@link ProfileStack}
+ *
+ * @author MrPro
+ */
+public class ProfileStackNode {
+
+ // stack code signature
+ private String codeSignature;
+ // owner list
+ private List<ProfileStack> owners;
+ // children nodes
+ private List<ProfileStackNode> childes;
+ // include the execution time of children
+ private int duration;
+
+ /**
+ * create new empty, un-init node
+ * @return
+ */
+ public static ProfileStackNode createEmptyNode() {
+ ProfileStackNode emptyNode = new ProfileStackNode();
+ emptyNode.owners = new LinkedList<>();
+ emptyNode.childes = new LinkedList<>();
+ return emptyNode;
+ }
+
+ /**
+ * accumulate {@link ProfileStack} to this tree, it will invoke on the tree root node
+ * @param stack
+ */
+ public void accumulateFrom(ProfileStack stack) {
+ List<String> stackList = stack.getStack();
+ if (codeSignature == null) {
+ codeSignature = stackList.get(0);
+ }
+ // increase self
+ this.increase(stack);
+
+ // handle stack children
+ ProfileStackNode parent = this;
+ for (int childDepth = 1; childDepth < stackList.size(); childDepth++) {
+ String elementCodeSign = stackList.get(childDepth);
+
+ // find same code signature children
+ ProfileStackNode childElement = null;
+ for (ProfileStackNode child : parent.childes) {
+ if (Objects.equal(child.codeSignature, elementCodeSign)) {
+ childElement = child;
+ break;
+ }
+ }
+
+ if (childElement != null) {
+ // increase child node
+ childElement.increase(stack);
+ parent = childElement;
+ } else {
+ // add children
+ ProfileStackNode childNode = createEmptyNode();
+ childNode.codeSignature = elementCodeSign;
+ childNode.increase(stack);
+
+ parent.childes.add(childNode);
+ parent = childNode;
+ }
+ }
+ }
+
+ /**
+ * combine from other {@link ProfileStackNode}
+ * @param node
+ * @return
+ */
+ public ProfileStackNode combine(ProfileStackNode node) {
+ // combine this node
+ this.combineThisNode(node);
+
+ // merge tree using pre order
+ LinkedList<Pair<ProfileStackNode, List<ProfileStackNode>>> stack = new LinkedList<>();
+ stack.add(new Pair<>(this, node.childes));
+ while (!stack.isEmpty()) {
+ Pair<ProfileStackNode, List<ProfileStackNode>> needCombineNode = stack.pop();
+ ProfileStackNode combineTo = needCombineNode.key;
+
+ // merge node
+ for (ProfileStackNode needCombineChildren : needCombineNode.value) {
+ boolean sameReference = false;
+ // find node
+ ProfileStackNode combinedNode = null;
+ for (ProfileStackNode combineNodeChildren : combineTo.childes) {
+ // same code signature
+ if (Objects.equal(needCombineChildren.codeSignature, combineNodeChildren.codeSignature)) {
+ // if same reference, dont need to combine anymore
+ if (needCombineChildren == combineNodeChildren) {
+ sameReference = true;
+ } else {
+ combineNodeChildren.combineThisNode(needCombineChildren);
+ }
+ combinedNode = combineNodeChildren;
+ break;
+ }
+ }
+
+ if (combinedNode == null) {
+ combineTo.childes.add(needCombineChildren);
+ combinedNode = needCombineChildren;
+ }
+
+ if (!sameReference) {
+ stack.add(new Pair(combinedNode, needCombineChildren.childes));
Review comment:
Raw use of parameterized class 'Pair'
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] wu-sheng commented on a change in pull request #4308:
provide thread stack analyzes
Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#discussion_r374459154
##########
File path: docs/en/guides/backend-profile.md
##########
@@ -0,0 +1,44 @@
+# Thread dump merging mechanism
+The performance profile is an enhancement feature in the APM system. We are using the thread dump to estimate the method execution time, rather than adding many local spans. In this way, the resource cost would be much less than using distributed tracing to locate slow method. This feature is suitable in the production environment. This document introduces how thread dumps are merged into the final report as a stack tree(s).
+
+## Thread analyst
+### Read data and transform
+Read data from the database and convert it to a data structure in gRPC.
+```
+st=>start: Start
+e=>end: End
+op1=>operation: Load data using paging
+op2=>operation: Transform data using parallel
+
+st(right)->op1(right)->op2
+op2(right)->e
Review comment:
For this graph, @mrproliu , I think we should describe the logic of each step doing, rather than stream API concept.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@a89ab30`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `78%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
=========================================
Coverage ? 26.82%
=========================================
Files ? 1174
Lines ? 25600
Branches ? 3643
=========================================
Hits ? 6866
Misses ? 18125
Partials ? 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../oap/server/core/profile/analyze/ProfileStack.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFjay5qYXZh) | `8.33% <0%> (ø)` | |
| [...p/server/core/profile/analyze/ProfileAnalyzer.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplci5qYXZh) | `77.77% <100%> (ø)` | |
| [...pache/skywalking/apm/agent/core/base64/Base64.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvYmFzZTY0L0Jhc2U2NC5qYXZh) | `100% <100%> (ø)` | |
| [.../core/profile/analyze/ProfileAnalyzeCollector.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVBbmFseXplQ29sbGVjdG9yLmphdmE=) | `100% <100%> (ø)` | |
| [...walking/apm/agent/core/context/ContextCarrier.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvY29udGV4dC9Db250ZXh0Q2Fycmllci5qYXZh) | `70% <57.14%> (ø)` | |
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `84.21% <94.11%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [a89ab30...c7e2c4d](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/baf98d7149d16e439fc144b82548f613addf4357?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
==========================================
- Coverage 26.88% 26.88% -0.01%
==========================================
Files 1174 1174
Lines 25595 25614 +19
Branches 3641 3647 +6
==========================================
+ Hits 6881 6886 +5
- Misses 18105 18121 +16
+ Partials 609 607 -2
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `91.74% <100%> (+8.4%)` | :arrow_up: |
| [...ache/skywalking/apm/agent/core/jvm/JVMService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvanZtL0pWTVNlcnZpY2UuamF2YQ==) | `59.01% <0%> (-18.04%)` | :arrow_down: |
| [...alking/apm/agent/core/remote/AgentIDDecorator.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL0FnZW50SUREZWNvcmF0b3IuamF2YQ==) | `67.85% <0%> (-17.86%)` | :arrow_down: |
| [.../core/remote/ServiceAndEndpointRegisterClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1NlcnZpY2VBbmRFbmRwb2ludFJlZ2lzdGVyQ2xpZW50LmphdmE=) | `28.08% <0%> (-3.38%)` | :arrow_down: |
| [...m/agent/core/remote/TraceSegmentServiceClient.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcmVtb3RlL1RyYWNlU2VnbWVudFNlcnZpY2VDbGllbnQuamF2YQ==) | `80.88% <0%> (-1.48%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [baf98d7...268edc3](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [skywalking] codecov-io edited a comment on issue #4308: provide
thread stack analyzes
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #4308: provide thread stack analyzes
URL: https://github.com/apache/skywalking/pull/4308#issuecomment-581126026
# [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=h1) Report
> Merging [#4308](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=desc) into [master](https://codecov.io/gh/apache/skywalking/commit/baf98d7149d16e439fc144b82548f613addf4357?src=pr&el=desc) will **increase** coverage by `0.03%`.
> The diff coverage is `100%`.
[](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #4308 +/- ##
==========================================
+ Coverage 26.88% 26.91% +0.03%
==========================================
Files 1174 1174
Lines 25595 25597 +2
Branches 3641 3641
==========================================
+ Hits 6881 6890 +9
+ Misses 18105 18098 -7
Partials 609 609
```
| [Impacted Files](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [.../server/core/profile/analyze/ProfileStackNode.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-b2FwLXNlcnZlci9zZXJ2ZXItY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2t5d2Fsa2luZy9vYXAvc2VydmVyL2NvcmUvcHJvZmlsZS9hbmFseXplL1Byb2ZpbGVTdGFja05vZGUuamF2YQ==) | `83.69% <100%> (+0.36%)` | :arrow_up: |
| [.../agent/core/profile/ProfileTaskChannelService.java](https://codecov.io/gh/apache/skywalking/pull/4308/diff?src=pr&el=tree#diff-YXBtLXNuaWZmZXIvYXBtLWFnZW50LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NreXdhbGtpbmcvYXBtL2FnZW50L2NvcmUvcHJvZmlsZS9Qcm9maWxlVGFza0NoYW5uZWxTZXJ2aWNlLmphdmE=) | `36.78% <0%> (+8.04%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=footer). Last update [baf98d7...2a1cfc3](https://codecov.io/gh/apache/skywalking/pull/4308?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services