njlg / perl-rethinkdb

A Pure Perl RethinkDB Driver
http://njlg.info/perl-rethinkdb
Artistic License 2.0
22 stars 5 forks source link

Async IO #32

Open ufobat opened 8 years ago

ufobat commented 8 years ago

Hi there,

yesterday I've implemented a Async IO interface to the rethinkdb server. I know i am breaking your test cases now, because async IO requires that one uses callbacks to get the data. I also dont know how you want to include this into your driver, if you maybe Want to have a Rethinkdb::AsyncIO and a superclass for both (sync and async) IO layers.

There is my code https://github.com/ufobat/perl-rethinkdb

Thats the beformance difference: (the numbers between >> X << is the number of reql updates per sec)

Sync (your original driver):

Fri Jul 29 09:18:24 2016 XXXXX Starting To Export itemcount=780
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:25 2016: >> 9 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:26 2016: >> 1 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:27 2016: >> 7 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:28 2016: >> 5 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:29 2016: >> 8 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:30 2016: >> 5 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:31 2016: >> 9 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:32 2016: >> 5 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:33 2016: >> 6 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:34 2016: >> 6 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:35 2016: >> 5 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:18:36 2016: >> 7 <<

Async (my branch):

Fri Jul 29 09:24:18 2016 XXXXX Starting To Export itemcount=780
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:18 2016: >> 1 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:19 2016: >> 298 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:20 2016: >> 409 <<
Fri Jul 29 09:24:20 2016 XXXXX Starting To Export itemcount=780
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:21 2016: >> 365 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:22 2016: >> 305 <<
Fri Jul 29 09:24:22 2016 XXXXX Starting To Export itemcount=780
Fri Jul 29 09:24:29 2016 XXXXX Starting To Export itemcount=780
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:29 2016: >> 183 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:30 2016: >> 163 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:31 2016: >> 292 <<
Fri Jul 29 09:24:31 2016 XXXXX Starting To Export itemcount=780
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:32 2016: >> 351 <<
XXXXXXXXXXXXXXXXX Fri Jul 29 09:24:33 2016: >> 396 <<
njlg commented 8 years ago

Good work! Yeah, I would totally include an async IO class. I like your idea: create a superclass that defaults to Async, but let's you override it with the Sync IO operations. (which I started to do once upon a time and never got very far).

Once you have something that looks good, just send a PR.

ufobat commented 8 years ago

I've got something. But I need to say am not happy with the result. I dont like the $args passing around the differnet methods and the magic thats behind the undocumented parameters for $args. I also just fixed one (probably the most important) testcase: connect.t and wrote a connect_async.t

The Async IO part itself seems to work fine. :-) but there should be done some (re)design / cleanup and some testcase fixing.

I will probably not spend much more time on further changes, it seems that we wont use rethinkdb in our project.