Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Implement log function natively #2020

Closed
wants to merge 5 commits into from
Closed

Conversation

zlin179
Copy link
Contributor

@zlin179 zlin179 commented Jan 4, 2022

Describe your changes
Add the log function similar to Graphite's log

Testing performed

  • Unit Test (pass)
  • Integration Test (pass)

I tested using mtcmptest with the following json

{
    "log()": "log(seriesByTag('name=jitter.g'))",
    "log(0.8)": "log(seriesByTag('name=jitter.g'),0.8)",
    "log(2.73)": "log(seriesByTag('name=jitter.g'),2.73)",
    "log(10)": "log(seriesByTag('name=jitter.g'),10)",
    "log(233333333)": "log(seriesByTag('name=jitter.g'),233333333)"
}

Basically they are the same except that the tag for log is {string: string} in mt & {string: float} in graphite, and very occasionally there's 1 bit precision difference.
link to the comparison result

Additional context
Benchmark

goos: darwin
goarch: amd64
pkg: github.com/grafana/metrictank/expr
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkLog10k_1NoNulls
BenchmarkLog10k_1NoNulls-12                        39400             28115 ns/op
BenchmarkLog10k_10NoNulls
BenchmarkLog10k_10NoNulls-12                        4143            300366 ns/op
BenchmarkLog10k_100NoNulls
BenchmarkLog10k_100NoNulls-12                        342           3290549 ns/op
BenchmarkLog10k_1000NoNulls
BenchmarkLog10k_1000NoNulls-12                        37          30940075 ns/op
BenchmarkLog10k_1SomeSeriesHalfNulls
BenchmarkLog10k_1SomeSeriesHalfNulls-12            43148             27560 ns/op
BenchmarkLog10k_10SomeSeriesHalfNulls
BenchmarkLog10k_10SomeSeriesHalfNulls-12            4471            293390 ns/op
BenchmarkLog10k_100SomeSeriesHalfNulls
BenchmarkLog10k_100SomeSeriesHalfNulls-12            384           3079671 ns/op
BenchmarkLog10k_1000SomeSeriesHalfNulls
BenchmarkLog10k_1000SomeSeriesHalfNulls-12            40          29678756 ns/op
BenchmarkLog10k_1AllSeriesHalfNulls
BenchmarkLog10k_1AllSeriesHalfNulls-12             42213             28313 ns/op
BenchmarkLog10k_10AllSeriesHalfNulls
BenchmarkLog10k_10AllSeriesHalfNulls-12             4590            256792 ns/op
BenchmarkLog10k_100AllSeriesHalfNulls
BenchmarkLog10k_100AllSeriesHalfNulls-12             392           3157942 ns/op
BenchmarkLog10k_1000AllSeriesHalfNulls
BenchmarkLog10k_1000AllSeriesHalfNulls-12             37          30260522 ns/op
PASS
ok      github.com/grafana/metrictank/expr      18.915s

@zlin179 zlin179 changed the title Implement linearRegression natively Implement log function natively Jan 4, 2022
@zlin179
Copy link
Contributor Author

zlin179 commented Jan 4, 2022

Closed, will submit another one from bloomberg/metricTank

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

Successfully merging this pull request may close these issues.

None yet

1 participant