about summary refs log tree commit homepage
path: root/ext/unicorn_http/gperf.rb
DateCommit message (Collapse)
2019-07-05http: gperf 3.0.3 compatibility gperf
gperf actually used to use offsetof in older versions: https://git.savannah.gnu.org/cgit/gperf.git/commit?h=b468e3aae05d176d So we don't need to do that substitution for versions before that commit in gperf. Now why do we care about gperf 3.0.3 from 2007? That's because FreeBSD is stuck on 3.0.3 from GPL-3-phobia, despite the gperf manual explicitly stating the output is NOT subject to the copyright of gperf: https://www.gnu.org/software/gperf/manual/gperf.html#Output-Copyright But there's plenty of other GPL-3 packages distributed by FreeBSD... Fwiw, OpenBSD and NetBSD have no problem with distributing the latest gperf 3.1; but I haven't tested those systems.
2019-07-04http: use gperf for common fields optimization
GNU gperf is a commonly-used tool for generating perfect hashes and available on every platform unicorn runs on. C Ruby, gcc, glibc all already use it. Using a hash lookup instead of a linear scan already shows measurable improvements when memoized header keys are all used: * test/benchmark/http_parser.rb (no options): 100000 iterations user system total real - 0.411857 0.000200 0.412057 ( 0.412070) + 0.397960 0.000181 0.398141 ( 0.398149) Results which require generating a new string from an unmemoized header is less significant, but still consistent measurable: * test/benchmark/http_parser.rb -H 'DNT: 1' 100000 iterations user system total real - 0.461416 0.000000 0.461416 ( 0.461417) + 0.461329 0.000000 0.461329 ( 0.461363) Most importantly, this change allows us to memoize more keys without worrying too much about the overhead of a O(n) scan.