Skip to content

Commit

Permalink
chore(influxdb): update the import path of influxdb lib to the new one
Browse files Browse the repository at this point in the history
This also upgrades it to the latest version and adds a benchmark which
shows some less allocation:

name                       old time/op    new time/op    delta
Influxdb1Second-4            3.56ms ± 0%    3.56ms ± 1%     ~
(p=0.841 n=5+5)
Influxdb2Second-4            12.1ms ± 0%    12.1ms ± 0%     ~
(p=0.095 n=5+5)
Influxdb100Milliseconds-4     341µs ± 1%     333µs ± 1%   -2.34%
(p=0.008 n=5+5)

name                       old alloc/op   new alloc/op   delta
Influxdb1Second-4            19.1kB ± 0%    16.6kB ± 0%  -13.37%
(p=0.008 n=5+5)
Influxdb2Second-4            18.8kB ± 0%    16.2kB ± 0%  -13.63%
(p=0.016 n=5+4)
Influxdb100Milliseconds-4    18.7kB ± 0%    16.1kB ± 0%  -13.72%
(p=0.008 n=5+5)

name                       old allocs/op  new allocs/op  delta
Influxdb1Second-4               291 ± 0%       231 ± 0%  -20.62%
(p=0.008 n=5+5)
Influxdb2Second-4               291 ± 0%       231 ± 0%  -20.62%
(p=0.008 n=5+5)
Influxdb100Milliseconds-4       291 ± 0%       231 ± 0%  -20.62%
(p=0.008 n=5+5)

The same test as in fce3884 gets 6909 RPS with 2.5GB of memory usage so
a considerate bump in rps for small amount of memory.
  • Loading branch information
mstoykov committed Aug 29, 2019
1 parent 7517d22 commit 04e1379
Show file tree
Hide file tree
Showing 20 changed files with 460 additions and 337 deletions.
12 changes: 6 additions & 6 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions stats/influxdb/bench_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package influxdb

import (
"io"
"io/ioutil"
"net/http"
"testing"
"time"

"github.com/loadimpact/k6/stats"
)

func benchmarkInfluxdb(b *testing.B, t time.Duration) {
testCollectorCycle(b, func(rw http.ResponseWriter, r *http.Request) {
for {
time.Sleep(t)
m, _ := io.CopyN(ioutil.Discard, r.Body, 1<<18) // read 1/4 mb a time
if m == 0 {
break
}
}
rw.WriteHeader(204)
}, func(tb testing.TB, c *Collector) {
b = tb.(*testing.B)
b.ResetTimer()

var samples = make(stats.Samples, 10)
for i := 0; i < len(samples); i++ {
samples[i] = stats.Sample{
Metric: stats.New("testGauge", stats.Gauge),
Time: time.Now(),
Tags: stats.NewSampleTags(map[string]string{
"something": "else",
"VU": "21",
"else": "something",
}),
Value: 2.0,
}
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
c.Collect([]stats.SampleContainer{samples})
time.Sleep(time.Nanosecond * 20)
}
})
}

func BenchmarkInfluxdb1Second(b *testing.B) {
benchmarkInfluxdb(b, time.Second)
}

func BenchmarkInfluxdb2Second(b *testing.B) {
benchmarkInfluxdb(b, 2*time.Second)
}

func BenchmarkInfluxdb100Milliseconds(b *testing.B) {
benchmarkInfluxdb(b, 100*time.Millisecond)
}
6 changes: 3 additions & 3 deletions stats/influxdb/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ import (
"sync"
"time"

"github.com/influxdata/influxdb/client/v2"
"github.com/sirupsen/logrus"

client "github.com/influxdata/influxdb1-client/v2"
"github.com/loadimpact/k6/lib"
"github.com/loadimpact/k6/stats"
"github.com/sirupsen/logrus"
)

// Verify that Collector implements lib.Collector
Expand Down Expand Up @@ -116,6 +115,7 @@ func (c *Collector) commit() {
<-c.semaphoreCh
}()
logrus.Debug("InfluxDB: Committing...")
logrus.WithField("samples", len(samples)).Debug("InfluxDB: Writing...")

batch, err := c.batchFromSamples(samples)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion stats/influxdb/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package influxdb
import (
"strings"

client "github.com/influxdata/influxdb/client/v2"
client "github.com/influxdata/influxdb1-client/v2"
null "gopkg.in/guregu/null.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion stats/influxdb/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package influxdb
import (
"testing"

client "github.com/influxdata/influxdb/client/v2"
client "github.com/influxdata/influxdb1-client/v2"
"github.com/stretchr/testify/assert"
null "gopkg.in/guregu/null.v3"
)
Expand Down
20 changes: 0 additions & 20 deletions vendor/github.com/influxdata/influxdb/LICENSE

This file was deleted.

62 changes: 0 additions & 62 deletions vendor/github.com/influxdata/influxdb/LICENSE_OF_DEPENDENCIES.md

This file was deleted.

48 changes: 0 additions & 48 deletions vendor/github.com/influxdata/influxdb/models/consistency.go

This file was deleted.

21 changes: 21 additions & 0 deletions vendor/github.com/influxdata/influxdb1-client/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 04e1379

Please sign in to comment.