heavydb icon indicating copy to clipboard operation
heavydb copied to clipboard

Without GPU why it took so much time???

Open fleapapa opened this issue 9 years ago • 30 comments

My host has no GPU. I've injected ~170 M NYC Taxi trip records to MapD and tested some simple queries. The queries were not fulfilled very quickly. For example, this query

$ time echo "select avg(trip_time_in_secs) from trips;" | mapdql mapd

User mapd connected to database mapd EXPR$0 811.999942 User mapd disconnected from database mapd

real 2m22.165s user 0m0.004s sys 0m0.016s

During the query, i observed ~20MB/s of data read rate. Assumed that 170M rows of 'trip_time_in_secs' values take 300MB after compression, it shouldn't take ~2.5 minutes to finish the query above.

Anything i can do to improve the performance?

fleapapa avatar Sep 08 '17 19:09 fleapapa

Is this from cold cache? What happens if you run the query again?

asuhan avatar Sep 08 '17 19:09 asuhan

Wow! Thanks for the prompt response! Yes, 2.5min was from cold cache. If not cold, the same query is finished in a second. Why does it take MapD so long to read 170M integers from disk at 20MB/s rate?

fleapapa avatar Sep 08 '17 19:09 fleapapa

I don't know, 20MB/s does sound pretty low indeed. We see much better throughput on our servers, is this a spinning disk by any chance? That being said, the assumption of the product is that the workload fits in memory, once it's warmed up queries will be fast.

asuhan avatar Sep 08 '17 19:09 asuhan

How did you load the data into the system?

Did you use a bulk load COPY FROM statement?

Could you share the logs of the DB startup plus the first query?

dwayneberry avatar Sep 08 '17 19:09 dwayneberry

@asuhan. I got your point but if i toggle between querying 2 or more different columns i always got >20s response time. That seems not practical for interactive (<3s) query purpose; for example, a web page may issue 10+ queries on different columns.

My host has 1GB available memory while i guess 170M x 2 columns should take less than that amount of memory.

fleapapa avatar Sep 08 '17 19:09 fleapapa

@dwayneberry. Yes, i used COPY FROM. It took few tens of minutes to load the data.

Here is the startup log: E0908 12:11:42.807757 13196 MapDHandler.cpp:169] This build isn't CUDA enabled, will run on CPU Thrift: Fri Sep 8 12:11:42 2017 TSocket::open() connect() <Host: localhost Port: 9093>Connection refused Thrift: Fri Sep 8 12:11:43 2017 TSocket::open() connect() <Host: localhost Port: 9093>Connection refused Thrift: Fri Sep 8 12:11:43 2017 TSocket::open() connect() <Host: localhost Port: 9093>Connection refused Thrift: Fri Sep 8 12:11:43 2017 TSocket::open() connect() <Host: localhost Port: 9093>Connection refused Thrift: Fri Sep 8 12:11:43 2017 TSocket::open() connect() <Host: localhost Port: 9093>Connection refused Thrift: Fri Sep 8 12:11:43 2017 TSocket::open() connect() <Host: localhost Port: 9093>Connection refused Thrift: Fri Sep 8 12:11:43 2017 TSocket::open() connect() <Host: localhost Port: 9093>Connection refused Thrift: Fri Sep 8 12:11:43 2017 TSocket::open() connect() <Host: localhost Port: 9093>Connection refused E0908 12:11:43.788535 13196 MapDHandler.cpp:201] No GPUs detected, falling back to CPU mode Received 1

fleapapa avatar Sep 08 '17 19:09 fleapapa

1GB is way, way too little memory. We don't optimize for that case. The columns do take less than that amount memory, but it's extremely marginal and there are other things, both on the system and in the executable, which use memory as well.

asuhan avatar Sep 08 '17 19:09 asuhan

What i mean 1GB free memory is after loading mapd-server. I would guess it is sufficient to hold 170M of two columns in memory w/o thrashing :)

My use case is simply to compare simply queries among different columnar databases like MapD and others like Clickhouse.

fleapapa avatar Sep 08 '17 19:09 fleapapa

The reason it's using more than 1GB is probably the way our pooled memory allocation works. It's fairly configurable and we could expose an option to make it work under this type of memory pressure. That doesn't mean we should, though; running on a system which has 1GB of memory left is not a goal of the project.

asuhan avatar Sep 08 '17 19:09 asuhan

Got it. Thanks!

fleapapa avatar Sep 08 '17 20:09 fleapapa

BTW. FYI. On the same host and environment, WITHOUT data cached, ClickHouse finished the same query in ~20 secs. WITH data cached, it took <1s like MapD does.

Still, MapD is doing great without index. Keep on the excellent project!

fleapapa avatar Sep 08 '17 20:09 fleapapa

My gaming desktop has a troughput in disk of 500mb/sec on a single sata ssd disk

Ottieni Outlook per iOShttps://aka.ms/o0ukef


From: Flea Papa [email protected] Sent: Friday, September 8, 2017 9:33:54 PM To: mapd/mapd-core Cc: Subscribed Subject: Re: [mapd/mapd-core] Without GPU why it took so much time??? (#68)

Wow! Thanks for the prompt response! Yes, 2.5min was from cold cache. If not cold, the same query is finished in a second. Why does it take MapD so long to read 170M integers from disk at 20MB/s rate?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/mapd/mapd-core/issues/68#issuecomment-328194508, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AdZQl9Q0X3bjwgOhdiXs43RVCezmIwiiks5sgZaigaJpZM4PRmLu.

cdessanti avatar Sep 08 '17 21:09 cdessanti

@asuhan,

The reason it's using more than 1GB is probably the way our pooled memory allocation works. It's fairly configurable and we could expose an option to make it work under this type of memory pressure. That doesn't mean we should, though; running on a system which has 1GB of memory left is not a goal of the project.

In my opinion, the issue (at least for my test case) seem more related with how MapD loads and processes cold data than with memory pressure because, after i added another 1GB memory to my (VM) host, the same query still took 2m50s. After the query, free memory is 700+MB, so memory seems still ample :)

I know my disk is slow, but my test is comparative versus another two databases, one of which is columnar and another is row based, with identical h/w environment.

Sorry to comment after this issue is closed.

fleapapa avatar Sep 09 '17 00:09 fleapapa

@fleapapa

Could you please include a compete log of the server startup including the execution of the first query. This will help us identify the delay you are experiencing.

thanks

dwayneberry avatar Sep 09 '17 00:09 dwayneberry

@dwayneberry , where can i find the complete log other than the one i posted previously? My machine is a Ubuntu 16.04 VM hosted on Virtualbox.

fleapapa avatar Sep 09 '17 00:09 fleapapa

@fleapapa That log you sent earlier is the correct one, its just only had the first few lines of the startup. Restart the server. run your query. stop the server. then send us the mapd_server.INFO log

dwayneberry avatar Sep 09 '17 00:09 dwayneberry

@dwayneberry. I did it again but the log shown on my screen looks the same as the previous one. I can't find any file named mapd_server.INFO.log on my filesystem. i started the mapd server using the following command: mapd/bin/mapd_server --data /mnt/trip/mapd/data

fleapapa avatar Sep 09 '17 00:09 fleapapa

@fleapapa The file is just mapd_server.INFO it is a symbolic link to the latest log. In your case it should be in /mnt/trip/mapd/data/mapd_log/mapd_server.INFO

dwayneberry avatar Sep 09 '17 00:09 dwayneberry

@dwayneberry, here you go: cat /mnt/trip/mapd/data/mapd_log/mapd_server.INFO Log file created at: 2017/09/08 17:22:15 Running on machine: osboxes Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg I0908 17:22:15.659196 4637 MapDServer.cpp:602] MapD started with data directory at '/mnt/trip/mapd/data' I0908 17:22:15.705051 4637 MapDServer.cpp:609] Watchdog is set to 1 I0908 17:22:15.705080 4637 MapDServer.cpp:631] cuda block size 0 I0908 17:22:15.705093 4637 MapDServer.cpp:632] cuda grid size 0 I0908 17:22:15.705106 4637 MapDServer.cpp:633] calcite JVM max memory 1024 I0908 17:22:15.705118 4637 MapDServer.cpp:634] MapD Server Port 9091 I0908 17:22:15.705132 4637 MapDServer.cpp:635] MapD Calcite Port 9093 I0908 17:22:15.705180 4637 MapDHandler.cpp:162] MapD Server 3.2.1-20170826-327e7ee E0908 17:22:15.705200 4637 MapDHandler.cpp:169] This build isn't CUDA enabled, will run on CPU I0908 17:22:15.706996 4637 DataMgr.cpp:120] cpuSlabSize is 1908.94M I0908 17:22:15.715643 4637 FileMgr.cpp:116] Read table metadata, Epoch is 0 for table data at '/mnt/trip/mapd/data/mapd_data/table_0_0/' I0908 17:22:15.716774 4637 Calcite.cpp:156] Creating Calcite Handler, Calcite Port is 9093 base data dir is /mnt/trip/mapd/data I0908 17:22:15.716797 4637 Calcite.cpp:95] Running calcite server as a daemon I0908 17:22:16.558720 4637 Calcite.cpp:124] Calcite server start took 800 ms I0908 17:22:16.558768 4637 Calcite.cpp:125] ping took 30 ms I0908 17:22:16.571445 4637 Calcite.cpp:281] [{"name":"Tan","ret":"double","args":["double"]},{"name":"Truncate__","ret":"float","args":["float","i32"]},{"name":"ln","ret":"double","args":["double"]},{"name":"Floor__2","ret":"i32","args":["i32"]},{"name":"Floor__3","ret":"i64","args":["i64"]},{"name":"rect_pixel_bin","ret":"float","args":["float","float","float","i32","i32"]},{"name":"Floor__1","ret":"i16","args":["i16"]},{"name":"degrees","ret":"double","args":["double"]},{"name":"approx_distance_in_meters","ret":"double","args":["float","float","float","float"]},{"name":"Ceil__2","ret":"i32","args":["i32"]},{"name":"Ceil__1","ret":"i16","args":["i16"]},{"name":"Ceil__3","ret":"i64","args":["i64"]},{"name":"Log10","ret":"double","args":["double"]},{"name":"Log","ret":"double","args":["double"]},{"name":"distance_in_meters","ret":"double","args":["double","double","double","double"]},{"name":"round_to_digit","ret":"double","args":["double","i32"]},{"name":"Atan2","ret":"double","args":["double","double"]},{"name":"Acos","ret":"double","args":["double"]},{"name":"Sin","ret":"double","args":["double"]},{"name":"Ceil","ret":"double","args":["double"]},{"name":"distance_in_meters__","ret":"double","args":["float","float","float","float"]},{"name":"Floor__","ret":"float","args":["float"]},{"name":"Truncate","ret":"double","args":["double","i32"]},{"name":"radians","ret":"double","args":["double"]},{"name":"Ceil__","ret":"float","args":["float"]},{"name":"ln__","ret":"double","args":["float"]},{"name":"reg_hex_vert_pixel_bin_y","ret":"float","args":["float","float","float","float","float","float","float","float","float","float","i32","i32"]},{"name":"reg_hex_vert_pixel_bin_x","ret":"float","args":["float","float","float","float","float","float","float","float","float","float","i32","i32"]},{"name":"Round","ret":"double","args":["double"]},{"name":"power","ret":"double","args":["double","double"]},{"name":"conv_4326_900913_x","ret":"double","args":["double"]},{"name":"reg_hex_horiz_pixel_bin_y","ret":"float","args":["float","float","float","float","float","float","float","float","float","float","i32","i32"]},{"name":"conv_4326_900913_y","ret":"double","args":["double"]},{"name":"Atan","ret":"double","args":["double"]},{"name":"reg_hex_horiz_pixel_bin_x","ret":"float","args":["float","float","float","float","float","float","float","float","float","float","i32","i32"]},{"name":"Floor","ret":"double","args":["double"]},{"name":"Truncate__1","ret":"i16","args":["i16","i32"]},{"name":"Truncate__2","ret":"i32","args":["i32","i32"]},{"name":"Truncate__3","ret":"i64","args":["i64","i32"]},{"name":"Cos","ret":"double","args":["double"]},{"name":"Log__","ret":"double","args":["float"]},{"name":"Log10__","ret":"double","args":["float"]},{"name":"Asin","ret":"double","args":["double"]},{"name":"Cot","ret":"double","args":["double"]},{"name":"Tan__","ret":"double","args":["float"]},{"name":"rect_pixel_bin_x","ret":"float","args":["float","float","float","float","float","i32"]},{"name":"rect_pixel_bin_y","ret":"float","args":["float","float","float","float","float","i32"]},{"name":"pi","ret":"double","args":[]},{"name":"Exp","ret":"double","args":["double"]}] E0908 17:22:16.572005 4637 MapDHandler.cpp:201] No GPUs detected, falling back to CPU mode I0908 17:22:16.572693 4637 MapDHandler.cpp:210] Started in CPU mode I0908 17:22:28.388641 4652 MapDHandler.cpp:359] User mapd connected to database mapd I0908 17:22:28.392401 4652 MapDHandler.cpp:555] sql_execute :vl1WlQUyxzSUB9t7HYzzcdzAwoB7CZ8z:query_str:select avg(trip_distance) from trips; I0908 17:22:28.393018 4652 Calcite.cpp:247] User mapd catalog mapd sql 'select avg(trip_distance) from trips;' I0908 17:22:30.168512 4654 FileMgr.cpp:116] Read table metadata, Epoch is 310 for table data at '/mnt/trip/mapd/data/mapd_data/table_1_1/' I0908 17:24:15.675556 4652 Calcite.cpp:260] Time in Thrift 14 (ms), Time in Java Calcite server 107268 (ms) I0908 17:24:15.708613 4669 BufferMgr.cpp:266] ALLOCATION slab of 3909516 pages (2001672192B) created in 0 ms CPU_MGR:0 I0908 17:25:15.353220 4652 MapDHandler.cpp:567] sql_execute-COMPLETED Total: 166960 (ms), Execution: 166956 (ms) I0908 17:25:15.354565 4652 MapDHandler.cpp:369] User mapd disconnected from database mapd

fleapapa avatar Sep 09 '17 00:09 fleapapa

@fleapapa Thanks for the log

The issue does appear to be stemming from your slow (extremely slow) disk access speeds. it is not related to your memory footprint directly (there could be knock on memory issues that slow disk processing down due to OS caching and flushing etc)

Accesses that on a regular machine that take .8 secs are taking 107 secs on your machine.

Here is an equivalent log from a machine with a 180M taxi dataset during first query of that table and column.

I0908 20:55:12.880648 32350 MapDHandler.cpp:2302] User mapd sets CPU mode.
I0908 20:55:16.445469 32350 MapDHandler.cpp:555] sql_execute :s0XKrGNswtuPTNpg9U0IWHeGnX8KTcH9:query_str:select avg(trip_distance) from nyc_taxi_nolion_2014;
I0908 20:55:16.445830 32350 Calcite.cpp:247] User mapd catalog mapd sql 'select avg(trip_distance) from nyc_taxi_nolion_2014;'
I0908 20:55:16.956212 32344 FileMgr.cpp:116] Read table metadata, Epoch is 697 for table data at '/raidStorage/prod/mapd-storage/data/mapd_data/table_1_8/'
I0908 20:55:17.293797 32350 Calcite.cpp:260] Time in Thrift 5 (ms), Time in Java Calcite server 842 (ms)
I0908 20:55:17.317417 32355 BufferMgr.cpp:266] ALLOCATION slab of 8388608 pages (4294967296B) created in 0 ms CPU_MGR:0
I0908 20:55:17.687477 32350 MapDHandler.cpp:567] sql_execute-COMPLETED Total: 1241 (ms), Execution: 1241 (ms)

the time between this line

I0908 20:55:16.956212 32344 FileMgr.cpp:116] Read table metadata, Epoch is 697 for table data at '/raidStorage/prod/mapd-storage/data/mapd_data/table_1_8/'

and this line

I0908 20:55:17.293797 32350 Calcite.cpp:260] Time in Thrift 5 (ms), Time in Java Calcite server 842 (ms)

is the time to read the metadata for the file

In a more normal case, like this it occurs first time from cold in about 800ms

In your case it is taking over 107 secs.

During this time MapD brings in all the metadata for all the columns of the table regardless of what the specific query is actually going to touch, so it is one time cost for the entire table. These can be a large number of fairly small reads, so it is worse in your bad IO situation. We have discussed options in this area in general to reduce the granularity of these reads, which would significantly improve your situation.

I can't speak to the other platforms but perhaps they amortize this across the different queries depending on how they manage their on disk representations and metadata (so perhaps the next column you touch will take another 20 secs etc).

In the second part of the process when we bring in the real data assuming the trip_distance is a decimal(14,2) there is about 170M x 8 bytes of data to load, so at 20MB/s there is about 68 seconds of transfer time to so the additional 60 seconds in you log lines up appropriately.

I0908 17:24:15.708613 4669 BufferMgr.cpp:266] ALLOCATION slab of 3909516 pages (2001672192B) created in 0 ms CPU_MGR:0
I0908 17:25:15.353220 4652 MapDHandler.cpp:567] sql_execute-COMPLETED Total: 166960 (ms), 

and basically something less than a second to do the actual query on the loaded data.

So no real mystery here other than a slow disk and a different model of when and how disk information is transfered to system I think. The positive take away with MapD is that once this one time cost on server start up occurs the rest of your queries will remain fast as we try not to touch the disk any more than we absolutely have to (a real benefit in your case).

dwayneberry avatar Sep 09 '17 07:09 dwayneberry