Skip to content
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

Automatically use non-exception NIOs for improved performance #210

Closed
wants to merge 1 commit into from

Conversation

zanker
Copy link
Contributor

@zanker zanker commented Apr 16, 2015

Here's a fun one. Apparently, in 2.1.x (and as such, JRuby 9k), Ruby added an undocumented arg to the NIO methods that allows you to use them without exceptions and instead symbol returns of the results. This is only available for write/read and not connect.

Quick performance test of read_nonblock with and without exceptions. On MRI, without exceptions is 50% faster, on JRuby it's around 85% faster. This is about inline with what we expect, exceptions in Java/JRuby are much more costly than Ruby, which are already costly.

The problem like everything, is testing it is a bitch :(

cc @tarcieri @nerdrew

@tarcieri
Copy link
Member

Rubbocopped!

Otherwise this is incredibly cool

def readpartial(size)
reset_timer
# NIO with exceptions
if RUBY_VERSION < "2.1.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps these could be factored into different backends?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about it but I'd rather just do Socketry really. I was starting work on it last night but things blew up :(

Need to do a bit more testing on a lot of this though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, this seems OK for now

@zanker zanker force-pushed the zanker/exceptionless-nio branch from 449dba2 to e079e86 Compare April 16, 2015 20:31
@ixti ixti mentioned this pull request Apr 27, 2015
@zanker zanker force-pushed the zanker/exceptionless-nio branch from e079e86 to 231c1a5 Compare May 8, 2015 17:03
@zanker zanker closed this Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants