New asynchronous insertion mode: 3x faster!

184 views
Skip to first unread message

Luca Garulli

unread,
Jan 11, 2012, 2:50:09 PM1/11/12
to orient-database
Hi,
the new asynchronous insertion mode against a remote server is 3x faster than default synchronous one: 1 million of inserts in 90 sec vs 270 sec! The test has been executed in local, so I expect that on real network the gain will be much bigger.

How to try it?

Get latest snapshot (from SVN trunk or Maven repository as 1.0rc8-SNAPSHOT) and append the  OPERATION_MODE.ASYNCHRONOUS mode to the save() method. Example:

ODatabaseDocumentTx database = new ODatabaseDocumentTx("remote:localhost/demo").open("admin", "admin");
ODocument record = new ODocument();
for( int i = 0; i < 1000000; ++i )
  record.reset();
  record.setClassName("Account");

  record.field("id", i);
  record.field("name", "Luca");
  record.field("surname", "Garulli");
  record.field("salary", 3000f + i);

  database.save(record, OPERATION_MODE.ASYNCHRONOUS);
}
database.close();

I've wrote the code without the IDE, so it could be not perfect. It's just an example. On my notebook the for cycle ends after 80 seconds and the close() takes 10 seconds because is enqueued after all the insert commands. After 90 seconds the entire insertion is done.

Note: by default, namely where not specified, OrientDB remains synchronous.

Lvc@

dAm2K

unread,
Jan 11, 2012, 6:13:19 PM1/11/12
to orient-...@googlegroups.com
2012/1/11 Luca Garulli <l.ga...@gmail.com>:

>
> Note: by default, namely where not specified, OrientDB remains synchronous.

Just to remember to myself and to those who have written a binary
protocol client implementation that this new cool functionality will
break binary protocol compatibility with older orientdb versions on
methods RECORD_CREATE, RECORD_UPDATE and RECORD_DELETE.
The server is expecting one more "byte" block data on the request and
the client should not expect a response from the server in case it's
using 1 (async mode).

I then noted that recently the "CONNECT" and "DB_OPEN" binary methods
changed with the server waiting more attributes on the request:
(driver-name:string)(driver-version:string)(protocol-version:short)(client-id:string)

The server's binary magic number was changed too.

HTH you orientdb binary driver developers!
Ciao, Dino Ciuffetti.

--
dAm2K, you know I'm there!

Reply all
Reply to author
Forward
0 new messages