influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

[tsm1] Is query performance expected to be slower than 0.9.4.2?

Open gerrickw opened this issue 11 years ago • 25 comments

I noticed a fairly dramatic difference in query performance when performing a simple query between master and 0.9.4.2. Is this expected? While looking at cpu and io while performing the query, I am not seeing a huge increase so I am unsure of the limiting factor. Currently have 40 cores and 4 ssds raid 0.

I have a reproduction case using the tool I gave in a previous bug, although requires loading the data for a while, although can see a difference in an hour that will slowly get worst when looking at an expanded time. Let me know if there are some queries against _internal that would be useful. Useful to compare between a machine with master and 0.9.4.2 to see query differences.

Pre-loaded some of the data with: (Just incase it matters) 2015/10/07 15:15:42 InfluxDB starting, version 0.9.5-nightly-6f80d69, branch master, commit 6f80d690dd9001cce860ce4a2f625a97d70587ed, built '2015-10-07T04:00:42+0000'

Later updated to: (same issue) 2015/10/12 14:30:29 InfluxDB starting, version 0.9.5-nightly-f1e0c59, branch master, commit f1e0c5938f4cbb009e4b5ba3160a1bd281c2f003, built '2015-10-12T04:00:41+0000'

https://gist.github.com/gerrickw/f83fb4d4d69aef2dfd37

Initial setup:

CREATE DATABASE "test_db"
CREATE USER "test_db" WITH PASSWORD 'test_db'
GRANT all ON test_db TO test_db

$ screen
Perform the below three commands in different screens
  $ python simple_influx_writer.py --coloa
  $ python simple_influx_writer.py --colob
  $ python simple_influx_writer.py --coloc

(Wait an hour)
SELECT mean("value") AS "value" FROM "a" WHERE "colo" = 'coloa' AND "pool" = 'hhh_ooo' AND time > now() - 60m GROUP BY time(10s), "x"
SELECT mean("value") AS "value" FROM "a" WHERE "colo" = 'coloa' AND "pool" = 'hhh_ooo' AND time > now() - 60m GROUP BY time(10s), "y"

After 3 or 6 hours, notice time difference between the builds.

After a few days of data I will get timed out responses from grafana for a 6 hour window.

Let me know if more information is needed, such as _internal. Not quite sure if there are a few useful queries to see some helpful info.

Thanks, Gerrick W

gerrickw avatar Oct 13 '15 21:10 gerrickw

Thanks for the report @gerrickw

The best thing to do is to get your data into the system, then enable CPU profiling. Run the query, and then render the SVG file. Then paste it here. Are you familiar with profiling Go programs?

otoolep avatar Oct 13 '15 22:10 otoolep

Have never done Go profiling. If there is a doc to read and some commands I can get something going.

gerrickw avatar Oct 13 '15 22:10 gerrickw

Check this out:

https://github.com/influxdb/influxdb/blob/master/CONTRIBUTING.md#profiling

otoolep avatar Oct 13 '15 22:10 otoolep

Basically a dupe https://github.com/influxdb/influxdb/issues/4367, but different data set.

otoolep avatar Oct 13 '15 23:10 otoolep

Thanks. Have it running the tests now. I'll submit the SVG file once some data gets loaded. It might be tomorrow morning due to meetings. >_< But will see what I can do.

gerrickw avatar Oct 13 '15 23:10 gerrickw

Great, thanks for your help.

otoolep avatar Oct 13 '15 23:10 otoolep

Hmm, ran it for an hour and shutdown and now getting influxd does not exist. Probably a simple mistake, but not seeing the issue. Within the log I see "[run] 2015/10/13 16:57:51 time limit reached, initializing hard shutdown", which possibly could be the issue. Although I see a 34mb influxd.prof on disk. For now I'll kick off another run for overnight.

Steps I did:

  • sudo vim /etc/init.d/influxdb
  • INFLUXD_OPTS="-cpuprofile /storage/influxdb_data/influxd.prof"
  • sudo service influxdb start
  • Able to see a 0 byte influxd.prof
  • Ran the script for an hour
  • sudo service influxdb stop
  • log shown:
[run] 2015/10/13 16:57:21 Signal received, initializing clean shutdown...
[run] 2015/10/13 16:57:21 Waiting for clean shutdown...
2015/10/13 16:57:21 CPU profile stopped
[copier] 2015/10/13 16:57:21 copier listener closed
[tcp] 2015/10/13 16:57:21 cluster service accept error: network connection closed
[shard-precreation] 2015/10/13 16:57:21 Precreation service terminating
[snapshot] 2015/10/13 16:57:21 snapshot listener closed
[continuous_querier] 2015/10/13 16:57:21 continuous query service terminating
[retention] 2015/10/13 16:57:21 retention policy enforcement terminating
[monitor] 2015/10/13 16:57:21 shutting down monitor system
[monitor] 2015/10/13 16:57:21 terminating storage of statistics
[tsm1wal] 2015/10/13 16:57:21 /storage/influxdb_data/data/test_db/default/10 flush to index took 12.082960277s
[run] 2015/10/13 16:57:51 time limit reached, initializing hard shutdown
  • cd /storage/influxdb_data/
  • go tool pprof influxd /storage/influxdb_data/influxd.prof
  • influxd does not exist.

gerrickw avatar Oct 14 '15 00:10 gerrickw

Having the same issue with the day run. I am curious if it is related to the hard shutdown. Is there a way to stop this from occurring?

Or a possible mistake or different way I can go around this issue?

gerrickw avatar Oct 14 '15 23:10 gerrickw

@gerrickw, I've not done profiling either so this is just a guess, but do you need the full path to influxd? go tool pprof /opt/influxdb/influxd /storage/influxdb_data/influxd.prof or cd /opt/influxdb go tool pprof influxd /storage/influxdb_data/influxd.prof

The CONTRIBUTING document doesn't clearly specify the path.

jhofeditz avatar Oct 16 '15 13:10 jhofeditz

Yes, you do need to specify the full path.

I will make this clear in the docs -- thanks @jhofeditz

otoolep avatar Oct 16 '15 14:10 otoolep

Our internal testing also shows that query performance is significantly slower with tsm1 with some data sets relative to bz1, even after https://github.com/influxdb/influxdb/pull/4531 is part of the test. However it's faster with other data sets.

We need to continue analysis in this area.

otoolep avatar Oct 21 '15 19:10 otoolep

#4531 and #4553 improved query performance in some cases. There is still in-progress work to improve queries further.

jwilder avatar Oct 28 '15 16:10 jwilder

I also noticed the slow query performance with tsm1. It seems to use more memory, too.

I ran some quick tests with an EC2 t2.small instance (2GB RAM, debian, amd64, hvm, EBS General Purpose SSD) and the stress test data (all data was inserted without errors): go run influx_stress.go -test examples/5M_STD.toml

Query: SELECT first(value) FROM cpu WHERE time > '2006-01-02' and time < '2006-01-02 00:01:00' GROUP BY time(10s)

Results:

Timespan GROUP BY timespan tsm1 bz1
1min 10s ~16s ~6s
2min 20s ~18s ~8s
2min 10s out of memory ~12s

All tests using the current nightly and restarting between using different engines. On this data it's 2-3 times slower, testing on real world data was even worse (up to 20 times slower). Inserting was fine with both engines, and the used storage was amazingly small with tsm1 :-).

2015/11/15 13:51:46 InfluxDB starting, version 0.9.6-nightly-43a4201, branch master, commit 43a4201a33054488b89c3eff01945a237405103d, built 2015-11-15T05:00:45+0000
2015/11/15 13:51:46 Go version go1.4.2, GOMAXPROCS set to 1
2015/11/15 13:51:46 Using configuration at: /etc/influxdb/influxdb.conf

xiic avatar Nov 15 '15 22:11 xiic

Thanks for these numbers. I presume you are re-writing the data completely between tests, since simply changing the engine in the config file and restarting has no effect on existing data. You realize that, correct?

In any event we are actively refactoring the query engine at the moment and you can expect query performance improvements across the board when that refactor completes.

otoolep avatar Nov 15 '15 22:11 otoolep

Yes, I was using two databases (one created while tsm1 was set and one while bz1). Hence the different numbers. I'm looking forward for the improvements!

xiic avatar Nov 16 '15 08:11 xiic

Sorry for the long delay for feedback. Was traveling and appears my last comment and attachment of the prof failed. Is a prof still desired? Seems like a variety of tickets related to performance are getting fixed.

gerrickw avatar Dec 18 '15 01:12 gerrickw

The query engine is undergoing major refactor right now, so you should expect significant improvements in performance over the next few weeks. Keep an eye out.

otoolep avatar Dec 18 '15 16:12 otoolep

Thanks otoolep, looking forward to the improvements. :-D

gerrickw avatar Dec 21 '15 21:12 gerrickw

I think I am seeing some query performance issues with TSM, although inserting is amazingly fast (20K inserts/second). And I am querying only on keys. Should we expect to see huge query performance improvements with TSM in 0.10.0?

skynet avatar Jan 05 '16 01:01 skynet

#5463 should improve queries until query engine work lands.

jwilder avatar Jan 27 '16 20:01 jwilder