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
Synchronization updates: final and volatile fields, immutable struct #284
Conversation
13f4088
to
2166f0f
Compare
- no to pollute the object's space - it can be easily added as noted in documentation
2166f0f
to
686d661
Compare
After applying the new capabilities of Calculating -------------------------------------
value-old 19.844k i/100ms
value-new 21.473k i/100ms
-------------------------------------------------
value-old 300.837k (±13.9%) i/s - 2.937M
value-new 295.720k (±18.5%) i/s - 2.813M
Comparison:
value-old: 300836.7 i/s
value-new: 295720.0 i/s - 1.02x slower
Calculating -------------------------------------
graph-old 59.000 i/100ms
graph-new 231.000 i/100ms
-------------------------------------------------
graph-old 777.004 (±32.9%) i/s - 6.431k
graph-new 2.211k (±25.2%) i/s - 20.328k
Comparison:
graph-new: 2211.0 i/s
graph-old: 777.0 i/s - 2.85x slower
Calculating -------------------------------------
immediate-old 924.000 i/100ms
immediate-new 969.000 i/100ms
-------------------------------------------------
immediate-old 9.124k (±23.4%) i/s - 84.084k
immediate-new 9.134k (±24.7%) i/s - 82.365k
Comparison:
immediate-new: 9133.6 i/s
immediate-old: 9123.7 i/s - 1.00x slower
Calculating -------------------------------------
then-old 402.000 i/100ms
then-new 410.000 i/100ms
-------------------------------------------------
then-old 4.306k (±28.2%) i/s - 36.984k
then-new 4.506k (±27.1%) i/s - 40.590k
Comparison:
then-new: 4505.6 i/s
then-old: 4306.2 i/s - 1.05x slower Before with only Calculating -------------------------------------
value-old 17.623k i/100ms
value-new 11.537k i/100ms
-------------------------------------------------
value-old 293.436k (±15.9%) i/s - 2.837M
value-new 254.683k (±13.1%) i/s - 2.504M
Comparison:
value-old: 293436.4 i/s
value-new: 254682.8 i/s - 1.15x slower
Calculating -------------------------------------
graph-old 73.000 i/100ms
graph-new 237.000 i/100ms
-------------------------------------------------
graph-old 863.588 (±26.5%) i/s - 7.592k
graph-new 2.502k (±18.0%) i/s - 23.700k
Comparison:
graph-new: 2501.6 i/s
graph-old: 863.6 i/s - 2.90x slower
Calculating -------------------------------------
immediate-old 956.000 i/100ms
immediate-new 678.000 i/100ms
-------------------------------------------------
immediate-old 9.920k (±21.0%) i/s - 92.732k
immediate-new 6.752k (±13.1%) i/s - 65.766k
Comparison:
immediate-old: 9919.6 i/s
immediate-new: 6752.0 i/s - 1.47x slower
Calculating -------------------------------------
then-old 518.000 i/100ms
then-new 519.000 i/100ms
-------------------------------------------------
then-old 5.312k (±23.5%) i/s - 48.174k
then-new 4.431k (±19.5%) i/s - 41.520k
Comparison:
then-old: 5312.2 i/s
then-new: 4431.2 i/s - 1.20x slower |
@@ -66,6 +66,8 @@ def initialize(value = NO_VALUE, opts = {}) | |||
set(value) unless value == NO_VALUE | |||
end | |||
|
|||
public :synchronize |
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.
Why is this public
and not protected
?
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.
Good point, thanks. There should be protected
.
can be made public if required in descendant
7b53868
to
4ca5220
Compare
9177c18
to
83372c6
Compare
Documentation added, see https://github.com/ruby-concurrency/concurrent-ruby/blob/synchronization/doc/synchronization.md |
baf8c5d
to
3a71338
Compare
Class.new(self) do | ||
attr_reader(*names) | ||
|
||
class_eval <<-RUBY, __FILE__, __LINE__ + 1 |
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.
What is the advantage of class_eval
over define_method
?
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.
Only performance improvements in some cases, otherwise define_method is cleaner. I wanted to avoid storing instance variables using reflection (which is optimized only on Truffle AFAIK).
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.
One eval removed in 3dbc08f.
👍 |
fe0860e
to
6f68140
Compare
6f68140
to
3dc0e87
Compare
Unfortunately there is an almost consistently failing test in rbx, I'll try to fix it first and then I'll merge. |
The failing test is not using |
I would prefer to merge this branch then work on the failing test afterwards:
|
* master: (5 commits) Deprecate timeout ...
Merging since travis gave a different intermittent error. |
Synchronization updates: final and volatile fields, immutable struct
👍 |
I was able to install Rbx on my MacBook Pro and I've been unable to reproduce the failed test. I think it's safe to call this an intermittent failure and add it to the list. |
@jdantonio added. |
ns_initialize
for ivars setting inside synchronize blockensure_ivar_visibility!
for final fields