Feature #16773
openReduce allocations in net/http
Description
Some minor patches which help to reduce allocations in net/http, which should benefit any programs making heavy use of net/http:
-
patch1.diff sets frozen_string_literal to true for some net/http files (I used
''.dup
for mutable strings to match existing code) -
patch2.diff uses (frozen) strings instead of regexps for split separator arguments in
lib/net/http/header.rb
-
patch3.diff eliminates some calls to
self[]
inlib/net/http/header.rb
which eliminates some unnecessary downcasing and string allocations
With these patches applied I get a modest but significant reduction in allocations using a test script which performs 10 HTTP requests representative of the workload for my use case (using net/http inside a web application). Before (recent master):
Total allocated: 3.21 MB (34031 objects)
After (with patches applied):
Total allocated: 2.99 MB (28756 objects)
I have run make test-all TESTS=net/http
and all tests still pass.
Files
No data to display