unicorn_http: reduce rb_global_variable calls
commit979ebcf91705709be5041a3be4514e5f1f6ec02c
authorEric Wong <e@80x24.org>
Tue, 28 Feb 2017 23:58:15 +0000 (28 23:58 +0000)
committerEric Wong <e@80x24.org>
Wed, 8 Mar 2017 09:18:26 +0000 (8 09:18 +0000)
tree5e339d5cbf681872ed1ef83ddb9b9b2cc3598b21
parentff13ad38ba9f83e0dd298be451aac7c75145d33b
unicorn_http: reduce rb_global_variable calls

rb_global_variable registers the address of the variable which
refers to the object, instead of the object itself.  This adds
extra overhead to each global variable for our case, where the
variable is frozen and never changed.

Given there are currently 59 elements in this array, this saves
58 singly-linked list entries and associated malloc calls and
associated overhead in the current mainline Ruby 2.x
implementation.  On 64-bit GNU libc malloc, this is already
16 * 58 = 928 bytes; more than the extra object slot and array
slack space used by the new mark array.

Mainline Ruby 1.9+ currently has a rb_gc_register_mark_object
public function which would suite our needs, too, but it is
currently undocumented, and may not be available in the future.
ext/unicorn_http/common_field_optimization.h
ext/unicorn_http/global_variables.h
ext/unicorn_http/httpdate.c
ext/unicorn_http/unicorn_http.rl