Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latency utils #50

Open
wants to merge 27 commits into
base: trunk
Choose a base branch
from
Open

Conversation

shaqianqian
Copy link

Description

use LatencyUtil to calculate the mean and percentile of datas

How Has This Been Tested?

Yes

@@ -266,6 +267,7 @@ public String toString() {
mySB.append("Max: " + this.getMax() + " ");
mySB.append("Error Rate: " + this.getErrorPercentage() + " ");
mySB.append("Sample Rate: " + this.getRate());
mySB.append("elapse: " + this.getElapsed());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modify 'elapse:' to 'elapsed:'

}

@Override
public void clear() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you be clearing/resetting latencyStats ? and also call stop on object to make threads stop ?

@@ -25,17 +28,14 @@
*
*/
public class StatisticsSummaryData {

LatencyStats latencyStats = new LatencyStats(1,3600000000000L,2,1024,10000000000L,null);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why is PauseDetector null ? We want this feature
  2. Is the window 1024 big enough ? What is the logic behind ? Make it a configurable property
  3. intervalEstimatorWindowLength is 10000000000L, What is the logic behind ?


void addAll(IStatCalculator<T> calc);

T getMedian();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document all interface methods

@Override
public Map<Number, Number[]> getDistribution() {
Map<Number, Number[]> result = new HashMap<>();
histogram.percentiles(5).forEach(p -> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 5?

@@ -0,0 +1,27 @@
BSD License

Copyright (c) 2000-2015 www.hamcrest.org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure HdrHistogram is copyrighted by hamcrest.org?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@@ -0,0 +1,27 @@
BSD License

Copyright (c) 2000-2015 www.hamcrest.org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure LatencyUtils is copyrighted by hamcrest?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed


private LatencyStats latencyStats = LatencyStats.Builder.create().build();
Histogram intervalHistogram = latencyStats.getIntervalHistogram();
private Histogram histogram = new Histogram(intervalHistogram);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the precision of the resulting histogram?
What's the memory consumption?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is work in progress. See question asked on dev list also

min = Math.min(val, min);
updateValueCount(val,1);
}
private void updateValueCount(Long actualValue, long sampleCount) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sad. Is it really required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a method for calculating distribution, so I try to record the value when it is added . Can you give another idea? Thanks

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of valuesMap?
Histogram / LatencyStats should track the distribution.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact in the old code, the distribution value comes from this method :

public Map<Number, Number[]> getDistribution() {
        Map<Number, Number[]> items = new HashMap<>();

        for (Entry<T, MutableLong> entry : valuesMap.entrySet()) {
            Number[] dis = new Number[2];
            dis[0] = entry.getKey();
            dis[1] = entry.getValue();
            items.put(entry.getKey(), dis);
        }
        return items;
    }

I don't think the LatencyStats can track this distribution

histogram.recordValue(l*1000000L);
}
// test max/min
assertTrue(10 == statisticsSummaryData.getMax());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid writing tests like that.
It would be hard to analyze especially at Travis/Jenkins CI.

Please use something like assertEquals(Arrays.toString(values) + ".getMax()", 10, statisticsSummaryData.getMax())

General rule: assertTrue and assertFalse are almost always bad.

import org.junit.Before;
import org.junit.Test;

public class TestHisStatCalculator {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid use his / her wording

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

his => Histogram
But better use TestHistogramStatCalculator

calc1.addValue(l);
}
calc.addAll(calc1);
assertTrue(23 == calc.getMax());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid assertTrue

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@@ -268,6 +268,8 @@ For details, please see the files under: licenses/bin
* asm-7.0.jar (BSD)
* dnsjava-2.1.8.jar (BSD)
* hamcrest-core-1.3.jar (BSD)
* LatencyUtils-2.0.3.jar (BSD)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BSD is an invalid (too broad) license reference. Please use SPDX license ID when possible: https://spdx.org/licenses/

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

Copy link
Author

@shaqianqian shaqianqian Jul 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build.properties Outdated
@@ -41,6 +41,7 @@
# are contained in the JMeter binary release.

maven2.repo = https://repo1.maven.org/maven2
maven.repo = https://repo.maven.apache.org/maven2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, LatencyUtils is available in Maven Central. Why do you add maven.repo?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

Copy link

@vlsi vlsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think methods like addSentBytes, addBytes, getTotalBytes, getTotalSentBytes do not belong to a generic IStatCalculator interface, and the methods should be removed from the interface.

*
* @param newValue number of newly sent bytes
*/
void addSentBytes(long newValue);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a violation of "single responsibility principle".
How getStandardDeviation is related to addSentBytes?

I think methods like addSentBytes, addBytes, getTotalBytes, getTotalSentBytes do not belong to a generic IStatCalculator interface.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "getStandardDeviation" related to sentBytes? In my view the standardDeviation is for the response time of Http Request, and "sent bytes" is for the amount of data used for transmission

percentile3 = new PercentileAggregator(percentileIndex3);
mean = new MeanAggregator();
public final long getPercentile(double percent) {
return histogram.getValueAtPercentile(percent)/1000000;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only answer in thie question doesn't give us enough information.
So don't we need to muliple and divide by 1,000,000 each time?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the number of Thread is a big number like 1000 -10000, the maximum is bigger than percentile 99%. And IntcountHistogram can also give a correct result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants