Hi Lou I guess executing the loop consumes the cpu time.
I assume your client + namenode + datanodes are connected by TCP. So when you execute a tight loop I think it is normal to consume 100%. Thanks Adrian On 2/27/20 15:08, Lou DeGenaro wrote: > I have a simple loop in my Crail java client to fetch the contents of a 1GB > file like so: > > private CrailBuffer buf = null; > int bufsize = 1024*1024; > int filesize = 1024*1024*1024; > ... > buf = OffHeapBuffer.wrap(ByteBuffer.allocateDirect(bufsize)); > long sumbytes = 0; > while (sumbytes < filesize) { > buf.clear(); > CrailResult cr = directStream.read(buf).get(); > long ret = cr.getLen(); > sumbytes = sumbytes + ret; > } > > The namenode, datanode, and my java client are all running in the same > cloud VM. When running, 100% (and more) CPU is consumed by my java app. I > was expecting something close to zero. Why so much CPU? A consequence of > running in a VM or am I doing something wrong? > > Lou. > -- Adrian Schüpbach, Dr. sc. ETH Zürich