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

[Ruby 2.3] Concurrency improvements to Queue/SizedQueue #3552

Closed
wants to merge 114 commits into from

Conversation

thedarkone
Copy link
Contributor

Context:

The implementation is now based on Doug Lea’s LinkedBlockingQueue.

Concurrency wise, this is now dual locked (head/tail) linked queue,
since Ruby std lib queues have blocking operations a completely
lock-free queue is not practical endeavor.

headius and others added 30 commits November 20, 2015 11:32
This patch implements `Coverage.peek_result` that was implemented in MRI
here:

  https://bugs.ruby-lang.org/issues/10816
remove "initial_state" argument of Enumerable#{slice_before,chunk}
* master: (29 commits)
  [travis-ci] revert jdk 9 testing from 2fa04aa
  Eliminate Block.Type arg in BlockBody yield/call signatures
  Pass Block instead of Binding in BlockBody.yield/call
  Minor: fix typo in name of runtime helper instr method name
  Update to jnr-unixsocket 0.10.
  Improve CamelCase package splitting. Fixes jruby#3493.
  Update to jnr-unixsocket 0.10-SNAPSHOT for forFD.
  [Truffle] j+tr: support for passing any extra ruby options
  each_object(cls.singleton_class) should not walk special classes.
  This test has been moved to RubySpec.
  [Truffle] Typo.
  [Truffle] Tag failing regex specs.
  [Truffle] Tag failing Time.at spec.
  The bin200 distribution has grown in size.
  [Truffle] Fixed two typos of the same word on the same line of code.
  [Truffle] Simplified the fix in 5446cc2.
  [Truffle] Fixed an NPE when a SharedMethodInfo has a null argumentsDescriptors.
  [Truffle] Fixed the interpreter_path when the root JRuby distribution directory is not named "jruby."
  Fixes jruby#3483. define_method with empty body throws RuntimeError in interpreter
  Test main on Java 9
  ...
[Ruby-2.3] - Implements Hash#fetch_values
* master:
  PushBindingInstr -> PushMethodBindingInstr
  Push/PopFrameInstr --> Push/PopMethodFrameInstr
  Change interpret sigs to distinguish between executing block and blockArg
  Rename block to blockArg in interpreter for clarity
  Remove one more line of code left behind that broke the build
  Remove changes to Block.java accidentally committed in 5e13527
  Next step in refactoring block body signature for improved clarity
  Rename arguments in blockBody signatures for easier understanding
  [Truffle] findbugs: fix missing locale in toUpperCase
  [Truffle] code style
  [Truffle] fix Time#localtime
[Ruby-2.3] - Implements Enumerable#grep_v
[Ruby-2.3] - Implements Numeric#positive? and Numeric#negative?
[Ruby-2.3] - Implements Thread#name and Thread#name=
…oc sub-class

also revert the protected block field in RubyProc introduced due previous hack

as advised in jruby#2499
kares and others added 26 commits December 15, 2015 09:33
…ruby#3542)

also did some internal cleanup e.g. private initialize now receive the runtime
and added more asserts to go along with those from MRI's test_enumerator.rb
we're already passing Ruby 2.3 define_method without block behaviour
Queue impl is changing, so I'm isolating Fiber's use of it to a
separate class to avoid volatility in Fiber logic.
MRI implements Queue and SizedQueue differently than we had been:

* Implicitly locking around all operations, due to the GIL.
* Notification of just those waiting to push for SizedQueue.

In addition, the new #close method wakes up all threads waiting
to pop or push, which was not easily done by wrapping JDK's
LinkedBlockingQueue.

This new impl is somewhat more in line with MRI, with regards to
locking and notification. This locking will likely introduce some
overhead compared to the old implementation, but the use of a
simple ArrayList may balance that out somewhat. All tests in 2.3's
thread/test_queue.rb pass now except for one relating to a
a peculiarity in MRI's implementation: if you remove marshal_dump
it falls back on Struct marshaling, since in MRI both Queue and
SizedQueue are Structs. Ours are not Struct and I do not see a
good reason to make them be so.
The implementation is now based on Doug Lea’s LinkedBlockingQueue.

Concurrency wise, this is now dual locked (head/tail) linked queue,
since Ruby std lib queues have blocking operations a completely
lock-free queue is not practical endeavor.
@thedarkone
Copy link
Contributor Author

Sorry, wrong branch.

@thedarkone thedarkone closed this Dec 19, 2015
@enebo enebo modified the milestone: Non-Release May 25, 2016
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.

None yet

10 participants