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

vegeta plot command #317

Merged
merged 34 commits into from
Aug 14, 2018
Merged

vegeta plot command #317

merged 34 commits into from
Aug 14, 2018

Conversation

tsenart
Copy link
Owner

@tsenart tsenart commented Jul 13, 2018

This PR introduces a new vegeta plot command that is an evolution of the previous vegeta report -reporter=plot. Additionally, all plot related code has moved to its own package.

Features

  • Support for plotting very large result sets with bounded memory usage.
  • Downsampling via LTTB algorithm, used via a flag in the command.
  • Plotting multiple attacks overlaid in the same line chart.

Fixes #137

TODO

Future work

  • Real-time plotting with a web sockets / SSE / HTTP2 Push + JS integration.

This commit introduces timeseries downsampling in the plot reporter
with the aim to be performant even with very large result sets.

Fixes #137
@tsenart tsenart requested a review from xla as a code owner July 13, 2018 16:57
lib/reporters.go Outdated
points := make([]lttb.Point, 0, len(results[i]))
for _, r := range results[i] {
points = append(points, lttb.Point{
X: float64(r.Timestamp.Sub(results[i][0].Timestamp).Seconds()),

Choose a reason for hiding this comment

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

unnecessary conversion

lib/reporters.go Outdated
for _, r := range results[i] {
points = append(points, lttb.Point{
X: float64(r.Timestamp.Sub(results[i][0].Timestamp).Seconds()),
Y: float64(r.Latency.Seconds() * 1000),

Choose a reason for hiding this comment

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

unnecessary conversion

@tsenart
Copy link
Owner Author

tsenart commented Jul 13, 2018

Here's a visual representation of the effect of this change set. As for the performance effects, you can test by downloading the attached HTML files and opening each of them.

Plot Reports

Before

vegeta-plot-raw

After

vegeta-plot-downsampled

@tsenart tsenart added the WIP label Jul 14, 2018
lib/plot_test.go Outdated
// Start benchmark
b.ReportAllocs()
b.StartTimer()
for i := 0; i < b.N; i++ {
rep.Report(ioutil.Discard)
NewHTMLPlot("Vegeta Plot", 5000, rs).WriteTo(ioutil.Discard)

Choose a reason for hiding this comment

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

Error return value of (github.com/tsenart/vegeta/lib.HTMLPlot).WriteTo is not checked

@tsenart tsenart force-pushed the plot-reporter-downsampling branch from ab4f5e2 to 0aa7bbf Compare July 14, 2018 15:02
fmt.Fprintln(os.Stderr, plotUsage)
}

return command{fs, func(args []string) error {

Choose a reason for hiding this comment

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

github.com/tsenart/vegeta.command composite literal uses unkeyed fields

}

return command{fs, func(args []string) error {
fs.Parse(args)

Choose a reason for hiding this comment

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

Error return value of fs.Parse is not checked

@tsenart tsenart force-pushed the plot-reporter-downsampling branch from 0aa7bbf to d1de3bb Compare July 14, 2018 15:03
This commit introduces a new plot command that was extracted from vegeta
report so that it supports specific flags.
Along with it, `NewPlotReporter` has been refactored into an
`HTMLPlot` that knows how to `WriteTo` an `io.Writer`.
@tsenart tsenart force-pushed the plot-reporter-downsampling branch from d1de3bb to 0d2e7f7 Compare July 14, 2018 15:46
lib/plot_test.go Outdated
b.ReportAllocs()
b.StartTimer()
for i := 0; i < b.N; i++ {
NewHTMLPlot("Vegeta Plot", 5000, rs).WriteTo(ioutil.Discard)

Choose a reason for hiding this comment

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

Error return value of (github.com/tsenart/vegeta/lib.HTMLPlot).WriteTo is not checked

@tsenart tsenart force-pushed the plot-reporter-downsampling branch from 4a4e7ba to e1a4f38 Compare July 18, 2018 20:59
lib/plot.go Outdated
cw := countingWriter{w: w}
err = plotTemplate.Execute(&cw, &plotData{
Title: p.title,
HTML2CanvasJS: template.JS(asset(html2canvas)),

Choose a reason for hiding this comment

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

G203: this method will not auto-escape HTML. Verify data is well formed.

lib/plot.go Outdated
err = plotTemplate.Execute(&cw, &plotData{
Title: p.title,
HTML2CanvasJS: template.JS(asset(html2canvas)),
DygraphsJS: template.JS(asset(dygraphs)),

Choose a reason for hiding this comment

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

G203: this method will not auto-escape HTML. Verify data is well formed.

lib/plot.go Outdated
Title: p.title,
HTML2CanvasJS: template.JS(asset(html2canvas)),
DygraphsJS: template.JS(asset(dygraphs)),
Data: template.JS(data),

Choose a reason for hiding this comment

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

G203: this method will not auto-escape HTML. Verify data is well formed.

lib/lttb_test.go Outdated
// From https://raw.githubusercontent.com/sveinn-steinarsson/flot-downsample/master/demo_data.js
var points = [][]point{
{
{0, 29.357995947822218},

Choose a reason for hiding this comment

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

github.com/tsenart/vegeta/lib.point composite literal uses unkeyed fields

lib/lttb_test.go Outdated
var points = [][]point{
{
{0, 29.357995947822218},
{1, 29.40932479606209},

Choose a reason for hiding this comment

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

github.com/tsenart/vegeta/lib.point composite literal uses unkeyed fields

lib/lttb_test.go Outdated
{
{0, 29.357995947822218},
{1, 29.40932479606209},
{2, 29.28168582006162},

Choose a reason for hiding this comment

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

github.com/tsenart/vegeta/lib.point composite literal uses unkeyed fields

lib/lttb_test.go Outdated

b.Run("tsenart", func(b *testing.B) {
for i := 0; i < b.N; i++ {
lttb(len(data), 1000, newIterator(points[0]))

Choose a reason for hiding this comment

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

Error return value of lttb is not checked

@tsenart tsenart force-pushed the plot-reporter-downsampling branch 2 times, most recently from 28b2dc3 to b313306 Compare July 30, 2018 08:41
@tsenart tsenart force-pushed the plot-reporter-downsampling branch from b313306 to 05d47cf Compare August 11, 2018 16:21

b.Run("tsenart", func(b *testing.B) {
for i := 0; i < b.N; i++ {
Downsample(len(data), 1000, newIterator(points[0]))

Choose a reason for hiding this comment

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

Error return value of Downsample is not checked

@tsenart tsenart changed the title report: Downsample time series in plot reporter vegeta plot Aug 12, 2018
@tsenart tsenart changed the title vegeta plot vegeta plot command Aug 12, 2018
@tsenart tsenart added enhancement and removed WIP labels Aug 14, 2018
@tsenart tsenart removed the request for review from xla August 14, 2018 23:31
@tsenart tsenart merged commit f477673 into master Aug 14, 2018
@tsenart tsenart deleted the plot-reporter-downsampling branch August 14, 2018 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants