about summary refs log tree commit homepage
path: root/ext/unicorn_http/common_field_optimization.h
DateCommit message (Collapse)
2018-12-26use rb_gc_register_mark_object
Since Ruby 2.6, it's a documented part of the API and we may depend on it: https://bugs.ruby-lang.org/issues/9894 It's been around since the early Ruby 1.9 days, and reduces overhead compared to relying on rb_global_variable: https://bogomips.org/unicorn-public/20170301002854.29198-1-e@80x24.org/
2018-12-12deduplicate strings VM-wide in Ruby 2.5+
String#-@ deduplicates strings starting with Ruby 2.5.0 Hash#[]= deduplicates strings starting in Ruby 2.6.0-rc1 This allows us to save a small amount of memory by sharing objects with other parts of the stack (e.g. Rack).
2017-03-08unicorn_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.
2010-02-18http: avoid signedness warnings
We never come close to the signed limits anywhere, so it should be safe either way, but make paranoid compiler settings less noisy if possible.
2009-09-06http: verbose assertions
This makes it easier for bug reporters to tell us what's wrong in case line numbers change.
2009-08-12http: freeze fields when creating them, always
Otherwise we'll be creating an extra garbage string because rb_hash_aset can't tell the string isn't being used elsewhere and creates a new frozen one.
2009-08-09http: move non-Ruby-specific macros c_util.h
2009-08-09http: split uncommon_field into a separate function
There's also no point in validating field hits if our field is a common field; so only do the validation for field length if we need to allocate memory for a new field.
2009-08-09http: find_common_field_value => find_common_field
The "_value" suffix was used to denote the return type, which is redundandant as it is already known at compile time (being that this is C and functions have explicit return types). Furthurmore, the "_value" is confusing since we're actually returning a "key" when "value" is used in the context of "key-value" pairs.
2009-08-09Refactoring unicorn_http C/Ragel code
More tightly integrate the C/Ruby portions with C/Ragel to avoid the confusing the flow. Split out some files into hopefully logical areas so it's easier to focus on more interesting/volatile code.