Skip to content

Commit

Permalink
Avoid GC run between mysql_stmt_execute and mysql_stmt_store_result
Browse files Browse the repository at this point in the history
  • Loading branch information
kamipo committed Nov 29, 2015
1 parent 69154e4 commit a7f8604
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions ext/mysql2/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,6 @@ static void *nogvl_execute(void *ptr) {
}
}

static void *nogvl_stmt_store_result(void *ptr) {
MYSQL_STMT *stmt = ptr;

if (mysql_stmt_store_result(stmt)) {
return (void *)Qfalse;
} else {
return (void *)Qtrue;
}
}

/* Free each bind_buffer[i].buffer except when params_enc is non-nil, this means
* the buffer is a Ruby string pointer and not our memory to manage.
*/
Expand Down Expand Up @@ -358,7 +348,7 @@ static VALUE execute(int argc, VALUE *argv, VALUE self) {
is_streaming = (Qtrue == rb_hash_aref(current, sym_stream));
if (!is_streaming) {
// recieve the whole result set from the server
if (rb_thread_call_without_gvl(nogvl_stmt_store_result, stmt, RUBY_UBF_IO, 0) == Qfalse) {
if (mysql_stmt_store_result(stmt)) {

This comment has been minimized.

Copy link
@sodabrew

sodabrew Nov 29, 2015

Does holding the GVL block GC? I did some searching about this, and did not find any good answer.

Releasing the GVL during network activity is a nice performance benefit that I would hope not to lose 😿

Also, I will try your test case with :stream => true – I suspect that it will make the whole issue more complicated...

mysql_free_result(metadata);
rb_raise_mysql2_stmt_error(stmt_wrapper);
}
Expand Down

0 comments on commit a7f8604

Please sign in to comment.