Skip to content

Latency utils#50

Open
shaqianqian wants to merge 27 commits into
ubikloadpack:trunkfrom
shaqianqian:LatencyUtils
Open

Latency utils#50
shaqianqian wants to merge 27 commits into
ubikloadpack:trunkfrom
shaqianqian:LatencyUtils

Conversation

@shaqianqian

Copy link
Copy Markdown

Description

use LatencyUtil to calculate the mean and percentile of datas

How Has This Been Tested?

Yes

mySB.append("Max: " + this.getMax() + " ");
mySB.append("Error Rate: " + this.getErrorPercentage() + " ");
mySB.append("Sample Rate: " + this.getRate());
mySB.append("elapse: " + this.getElapsed());

Copy link
Copy Markdown
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
Copy Markdown
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 ?

*/
public class StatisticsSummaryData {

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

why 5?

Comment thread licenses/bin/HdrHistogram-2.1.8.txt Outdated
@@ -0,0 +1,27 @@
BSD License

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

Copy link
Copy Markdown

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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

agreed

Comment thread licenses/bin/LatencyUtils-2.0.3.txt Outdated
@@ -0,0 +1,27 @@
BSD License

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

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Agreed

Comment thread LICENSE
* 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
Copy Markdown

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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

agreed

@shaqianqian shaqianqian Jul 16, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment thread build.properties Outdated
# are contained in the JMeter binary release.

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

Copy link
Copy Markdown

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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

agreed

@vlsi vlsi left a comment

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Agreed

Copy link
Copy Markdown
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
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