lealone / Lealone

比 MySQL 和 MongoDB 快10倍的 OLTP 关系数据库和文档数据库
Other
2.47k stars 518 forks source link

为何Cpu的利用率只有30%左右 #49

Closed freemanhjr closed 11 years ago

freemanhjr commented 11 years ago

5亿行记录,5个rs,20个region,用select count统计,发现每个rs的cpu利用率只有30%左右,最后统计时间要300多秒,同样的环境,用hive也只要100多秒,发现cpu,内存,io都不算高,而hive的MR则cpu可达90%甚至100%,是否并行模型哪里有问题?

codefollower commented 11 years ago

到其中一个rs机器下面执行 jstack , 看看CommandParallle的线程跑了几个? lealone的聚合函数实现,底层也是跟org.apache.hadoop.hbase.coprocessor.AggregateImplementation一样, 使用的都是InternalScanner。

freemanhjr commented 11 years ago

应该是4个线程;

Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.6-b01 mixed mode):

"Attach Listener" daemon prio=10 tid=0x00007ff6f893a000 nid=0x64ff waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE

Locked ownable synchronizers:

"CommandParallelpool-21-thread-9" daemon prio=10 tid=0x00007ff6dc632000 nid=0x6481 runnable [0x00007ff6ba7d2000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read(BufferedInputStream.java:237)

"CommandParallelpool-21-thread-8" daemon prio=10 tid=0x00007ff6dc269000 nid=0x6480 runnable [0x00007ff6ba3ce000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read(BufferedInputStream.java:237)

"CommandParallelpool-21-thread-7" daemon prio=10 tid=0x00007ff6dc2d7000 nid=0x647f runnable [0x00007ff6ba4cf000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read(BufferedInputStream.java:237)

"CommandParallelpool-21-thread-6" daemon prio=10 tid=0x00007ff6dc22b800 nid=0x647e runnable [0x00007ff6b9c9c000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read(BufferedInputStream.java:237)

"Lealone tcp server (tcp://10.9.0.192:9092) thread-EventThread" daemon prio=10 tid=0x00007ff6dc22d000 nid=0x6462 waiting on condition [0x00007ff6ba6d1000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method)

"Lealone tcp server (SER191:2181)" daemon prio=10 tid=0x00007ff6dc22c000 nid=0x6461 runnable [0x00007ff6b9f9f000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method) at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:210) at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)

"Lealone tcp server (tcp://10.9.0.192:9092) thread-EventThread" daemon prio=10 tid=0x00007ff6dc174000 nid=0x645b waiting on condition [0x00007ff6c3467000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method)

"Lealone tcp server (SER191:2181)" daemon prio=10 tid=0x00007ff6dc26a000 nid=0x645a runnable [0x00007ff6ba1a1000] java.lang.Thread.State: RUNNABLE at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method) at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:210) at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65) at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)

codefollower commented 11 years ago

20个region / 5个rs = 每个rs有4个region,所以有4个线程也是对的