Commit Graph

337 Commits

Author SHA1 Message Date
Eric Wong
8bfbfa2708 fix signal handling when waiting on queries
This reverts the single-threaded select() optimization from
commits 9a63a587c0 and
0190457dbd.

Under Ruby 1.9, the reverted optimization caused signal handlers
to be delayed until the socket became readable.

Under Ruby 1.8, matters are worse as receiving a signal during
select() causes Errno::EINTR to be raised.

There is now a (somewhat fragile) spec for testing signal
handling during a "SELECT sleep(2)" query.

Furthermore, the performance difference I measured on
benchmark/thread_alone.rb was negligible (over 1000 iterations)
between the two:

Ruby 1.8.7-p249
  Rehearsal ----------------------------------------------------
  select             0.040000   0.020000   0.060000 (  0.119448)
  rb_thread_select   0.050000   0.020000   0.070000 (  0.132091)
  ------------------------------------------- total: 0.130000sec

                         user     system      total        real
  select             0.030000   0.030000   0.060000 (  0.116471)
  rb_thread_select   0.050000   0.020000   0.070000 (  0.119874)

Ruby 1.9.2-p0
  Rehearsal ----------------------------------------------------
  select             0.050000   0.030000   0.080000 (  0.134208)
  rb_thread_select   0.080000   0.000000   0.080000 (  0.141316)
  ------------------------------------------- total: 0.160000sec

                         user     system      total        real
  select             0.050000   0.020000   0.070000 (  0.123325)
  rb_thread_select   0.060000   0.010000   0.070000 (  0.124075)

Benchmarks were performed on an _empty_ mysql2_test table to
maximize the relative time for the select(2)-related code path
(vs reading data).  The test was run on Debian Lenny, x86_64 and
a stock 2.6.35.2 Linux kernel.  Hardware was a Core2 Duo @
1.6GHz with the performance CPU governor while on AC power
to eliminate CPU speed fluctuations during the test.
2010-08-18 20:13:13 -07:00
Brian Lopez
d990f68320 slight refactor of how initial commands were being sent 2010-08-18 12:50:03 -07:00
Brian Lopez
60c33be87c multiple variable assignments can done in a single query 2010-08-17 22:55:31 -07:00
Brian Lopez
d962ef2583 update files for 0.2.1 release 2010-08-16 14:47:17 -07:00
Brian Lopez
dd23e2c880 Version bump to 0.2.1 2010-08-16 14:46:54 -07:00
Brian Lopez
e87427abe4 change AR adapter instructions back 2010-08-16 14:45:26 -07:00
Brian Lopez
95fb97dc2b add AR mysql2 adatper back 2010-08-16 14:43:48 -07:00
Brian Lopez
164ad07332 referenced the wrong issue # 2010-08-16 12:39:53 -07:00
Brian Lopez
91671e0d9a update files for 0.2.0 release 2010-08-16 12:38:08 -07:00
Brian Lopez
ed4841e29c Version bump to 0.2.0 2010-08-16 12:25:54 -07:00
Brian Lopez
cebf9af068 Wrap the MYSQL* again so we can:
1) let mysql_init/mysql_close take care of any/all allocation, thread state and freeing
2) for faster access to the encoding and active state variables for the connection
2010-08-16 02:03:19 -07:00
Brian Lopez
3239a449b9 move and slightly refactor benchmark rake task 2010-08-11 11:29:10 -07:00
Lourens Naudé
10ee025647 Benchmark for select VS rb_thread_select 2010-08-11 11:25:20 -07:00
Lourens Naudé
2609783aeb Avoid INT2NUM overhead when coercing date specific elements for MYSQL_TYPE_TIME + introduce basic infrastructure for measuring GC overhead 2010-08-11 11:25:20 -07:00
Lourens Naudé
d9153b82fc Save on coercion overhead for zero value decimal and float column values 2010-08-11 11:25:20 -07:00
Lourens Naudé
c808e78028 Intern error_number= && sql_state= as well 2010-08-11 11:25:20 -07:00
Lourens Naudé
c5d9b7ff65 Introduce test case for Mysql2::Client in multi-threaded environments 2010-08-11 11:25:20 -07:00
Lourens Naudé
9f19b958b0 Add a threaded example as well 2010-08-11 11:25:20 -07:00
Lourens Naudé
9a63a587c0 Declare the selector function pointer as per ISO C90 spec + address brian's concern / comment re. rb_thread_alone() 2010-08-11 11:25:20 -07:00
Lourens Naudé
0190457dbd Skip rb_thread_select overhead if we're running in single threaded mode 2010-08-11 11:25:20 -07:00
Lourens Naudé
80810f7e43 Extract a GET_CLIENT mactro to cleanup inline Data_Get_Struct etc. on methods that require client access 2010-08-11 11:25:20 -07:00
Lourens Naudé
f601c3cef8 Skip additional string length access in rb_mysql_client_escape and benchmark escaping "clean" strings as well 2010-08-11 11:25:20 -07:00
Lourens Naudé
931765ee05 Extract a GET_ENCODING macro 2010-08-11 11:25:20 -07:00
Lourens Naudé
e250e337cf Define rake tasks for running benchmarks 2010-08-11 11:25:20 -07:00
Lourens Naudé
b15ddc4f75 Let spec be the default rake task 2010-08-11 11:24:45 -07:00
Luis Lavena
db64470831 Quick hack from mysql gem.
Added vendored MySQL.
2010-08-12 02:19:24 +08:00
Luis Lavena
5fb043b4da Require a newer rake-compiler for cross-compilation. 2010-08-12 02:19:14 +08:00
Luis Lavena
4c27a1e4fc extconf detect properly mingw. 2010-08-12 02:19:04 +08:00
Brian Lopez
254f42f502 no need for AR specs since the adapter was moved to Rails core 2010-08-09 22:11:47 -07:00
Brian Lopez
0bab31a61f mysql2 adapter moved into AR3 core 2010-08-09 14:52:45 -07:00
Brian Lopez
5a9ca9c76f app_timezone defaults to nil 2010-08-09 14:50:58 -07:00
Brian Lopez
c3c5c8f85a update gemspec now that the Sequel adapter is gone 2010-08-06 17:05:53 -07:00
Brian Lopez
7bf9889103 remove Sequel adapter as it's now in Sequel core :) 2010-08-06 12:47:25 -07:00
Brian Lopez
b448b98146 move -Wextra to development flags area 2010-08-06 11:19:34 -07:00
Brian Lopez
2527454b26 update AR adapter to reflect timezone setting update 2010-08-06 00:01:24 -07:00
Brian Lopez
99af726a58 application_timezone is allowed to be nil 2010-08-06 00:01:09 -07:00
Brian Lopez
957b0bac1b default application_timezone to nil 2010-08-05 23:09:13 -07:00
Brian Lopez
f4fb9e8034 sync up with sequel adapter from my Sequel fork until it's officially merged in 2010-08-05 22:53:36 -07:00
Brian Lopez
ad34357e57 convert :timezone option into two new ones
:database_timezone - the timezone (:utc or :local) Mysql2 will assume time/datetime fields are stored in the db. This modifies what initial timezone your Time objects will be in when creating them from libmysql in C
and
:application_timezone - the timezone (:utc or :local) you'd finally like the Time objects converted to before you get them
2010-08-05 22:50:45 -07:00
Brian Lopez
1bdf44ce7f can't call literal here because it'll try to join it's own thread 2010-08-05 01:20:42 -07:00
Brian Lopez
04932b549b Mysql2::Client uses the :username key, set it to :user if that was used instead 2010-08-05 01:20:15 -07:00
Brian Lopez
93fabe2b24 heh 2010-08-05 00:45:56 -07:00
Brian Lopez
86302eb1f1 fix typo in comment 2010-08-05 00:45:33 -07:00
Brian Lopez
d1b2f98b7c major refactor of Sequel adapter - it's now green in Sequel 2010-08-05 00:44:01 -07:00
Brian Lopez
2514fafa53 add :cast_booleans option for automatically casting tinyint(1) fields into true/false for ruby 2010-08-05 00:39:11 -07:00
Brian Lopez
12c022c8aa move most previously global symbols to static to prevent conflicts (thanks for catching this Eric) 2010-08-04 19:32:14 -07:00
Brian Lopez
2bb8721e84 respect :symbolize_keys option for Mysql2::Result#fields if it's called before the first row is built 2010-08-04 00:54:05 -07:00
Brian Lopez
923393351a initialize @active early on to prevent warnings later 2010-08-03 20:45:00 -07:00
Brian Lopez
c0cf2f13a0 let's try that again - libmysql only allows one query be sent at a time per connection, bail early if that's attempted 2010-08-03 20:37:49 -07:00
Brian Lopez
1a70e83a74 Revert "libmysql only allows one query be sent at a time per connection, bail early if that's attempted"
This reverts commit 3ff7baa5f8.
2010-08-03 20:22:44 -07:00