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

Synchronization updates: final and volatile fields, immutable struct #284

Merged
merged 17 commits into from May 2, 2015

Conversation

pitr-ch
Copy link
Member

@pitr-ch pitr-ch commented Apr 28, 2015

  • Add ns_initialize for ivars setting inside synchronize block
  • cleans up the Synchronization::Object space
  • add ensure_ivar_visibility! for final fields
  • add volatile attributes

@pitr-ch pitr-ch added the enhancement Adding features, adding tests, improving documentation. label Apr 28, 2015
@pitr-ch pitr-ch added this to the 0.9.0 Release milestone Apr 28, 2015
@pitr-ch pitr-ch force-pushed the synchronization branch 2 times, most recently from 13f4088 to 2166f0f Compare April 28, 2015 16:18
@pitr-ch
Copy link
Member Author

pitr-ch commented Apr 28, 2015

After applying the new capabilities of Synchronization::Object to Edge::Future on the obvious places the performance improved. It now has better or same performance as old implementations.

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 synchronize it was:

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

@pitr-ch pitr-ch changed the title Synchronization updates Synchronization updates, final and volatile fields Apr 28, 2015
@@ -66,6 +66,8 @@ def initialize(value = NO_VALUE, opts = {})
set(value) unless value == NO_VALUE
end

public :synchronize
Copy link
Member

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?

Copy link
Member Author

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.

@pitr-ch pitr-ch changed the title Synchronization updates, final and volatile fields Synchronization updates: final and volatile fields; immutable struct Apr 29, 2015
@pitr-ch pitr-ch changed the title Synchronization updates: final and volatile fields; immutable struct Synchronization updates: final and volatile fields, immutable struct Apr 29, 2015
@pitr-ch pitr-ch force-pushed the synchronization branch 2 times, most recently from 9177c18 to 83372c6 Compare April 29, 2015 09:44
@pitr-ch
Copy link
Member Author

pitr-ch commented Apr 29, 2015

Class.new(self) do
attr_reader(*names)

class_eval <<-RUBY, __FILE__, __LINE__ + 1
Copy link
Member

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?

Copy link
Member Author

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).

Copy link
Member Author

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.

@jdantonio
Copy link
Member

👍

@jdantonio
Copy link
Member

👍 I'm 👌 with merging this. I'll rebase and continue working on #271, #283, and #280 afterwards.

@pitr-ch
Copy link
Member Author

pitr-ch commented Apr 30, 2015

Unfortunately there is an almost consistently failing test in rbx, I'll try to fix it first and then I'll merge.

@pitr-ch
Copy link
Member Author

pitr-ch commented May 2, 2015

The failing test is not using Synchronized::Object and I cannot get it reproduced :/ If It succeeds at least once on travis I'll merge this branch and add it to intermittently failing tests.

@jdantonio
Copy link
Member

I would prefer to merge this branch then work on the failing test afterwards:

  1. This code needs to be in master for is to proceed with our other work
  2. As noted, the failing test appears to be unrelated to the changes in this PR
  3. I spent over an hour the other day trying to get Rbx to install on an Ubuntu laptop and wasn't successful, so fixing this test may be very difficult

@pitr-ch
Copy link
Member Author

pitr-ch commented May 2, 2015

Merging since travis gave a different intermittent error.

pitr-ch pushed a commit that referenced this pull request May 2, 2015
Synchronization updates: final and volatile fields, immutable struct
@pitr-ch pitr-ch merged commit 37edfe3 into master May 2, 2015
@jdantonio
Copy link
Member

👍

@jdantonio
Copy link
Member

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.

@pitr-ch
Copy link
Member Author

pitr-ch commented May 2, 2015

@jdantonio added.

@jdantonio jdantonio deleted the synchronization branch May 7, 2015 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding features, adding tests, improving documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants