-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOBuffer back to Ruby #1980
IOBuffer back to Ruby #1980
Conversation
bde2c0b
to
1fbae70
Compare
end | ||
|
||
def append(*args) | ||
args.each { |a| concat(a) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, Ruby 2.4+ supports multi-args String#concat
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! We have to support 2.2+ for now.
This looks great to me: I guess the main concern is: how does it affect performance? |
0b99359
to
f32961a
Compare
a bit ugly that |
This branch, extra large request body:
Master, large request body:
This branch, hello world:
Master, hello world:
Maybe a 5% slowdown but that's really within the statistical margin of error. I think this is good for a merge. |
This appears to just stall the ruby 2.3 build 😖 |
lib/puma/io_buffer.rb
Outdated
module Puma | ||
class IOBuffer < String | ||
def initialize | ||
if RUBY_VERSION <= "2.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is incorrect (e.g. 2.3.4
<= 2.3
doesn't hold), use capacity if RUBY_VERSION >= 2.4
should work fine instead, and that's likely what makes the 2.3 build fails:
https://github.com/puma/puma/pull/1980/checks?check_run_id=258129791
/home/runner/work/puma/puma/lib/puma/io_buffer.rb:9:in `initialize': unknown keyword: capacity (ArgumentError)
from /home/runner/work/puma/puma/lib/puma/io_buffer.rb:9:in `initialize'
from /home/runner/work/puma/puma/lib/puma/thread_pool.rb:97:in `new'
from /home/runner/work/puma/puma/lib/puma/thread_pool.rb:97:in `block (2 levels) in spawn_thread'
from /home/runner/work/puma/puma/lib/puma/thread_pool.rb:97:in `map'
from /home/runner/work/puma/puma/lib/puma/thread_pool.rb:97:in `block in spawn_thread'
I'm not sure the capacity optimization is worth it. Removed it and it's now benchmarking faster than master, and hello.sh benchmark on this branch is now EDIT: Those numbers are MRI, I'll go back and check JRuby too before merge. |
@nateberkopec Where are the benchmarks you ran above? I'd like to confirm there's no performance hit on JRuby and see if any tweaks might help improve things further. |
This is failing on JRuby because the HTTP parser ext still references the Java IOBuffer. I'll have a patch shortly. |
Just remove import: diff --git a/ext/puma_http11/PumaHttp11Service.java b/ext/puma_http11/PumaHttp11Service.java
index da7c2719..00f63aa2 100644
--- a/ext/puma_http11/PumaHttp11Service.java
+++ b/ext/puma_http11/PumaHttp11Service.java
@@ -6,7 +6,6 @@ import org.jruby.Ruby;
import org.jruby.runtime.load.BasicLibraryService;
import org.jruby.puma.Http11;
-import org.jruby.puma.IOBuffer;
import org.jruby.puma.MiniSSL;
public class PumaHttp11Service implements BasicLibraryService { |
On a simple Roda benchmark, this change appears to have no negative performance impact for JRuby. It's within the margin of error for this wrk-driven Roda benchmark. 👍 |
File under "weird idea".