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

GEODE-866: Converting calls of vm.invoke to lambdas #98

Merged
merged 12 commits into from
Feb 19, 2016

Conversation

upthewaterspout
Copy link
Contributor

I automatically converted many of the calls of vm.invoke(Class, String) to use a lambda instead, as discussed. Please review this PR - I think it will be easier to review the individual commits than a review board post.

There were a few roadblocks along the way:

  • I changed SerializableRunnableIF to throw an exception from the run method. That made it easier to write short lambda expressions without having to put in a try catch in the lambda.
  • I had to modify some tests to make variables effectively final, or not refer to a static inside the lambda, and a few other issues to get all of the tests to compile and pass. See my individual commits.

Not all vm.invoke calls are gone, unfortunately. There are a number of places that could not be automatically converted - mostly where the code built up an object array in a weird way and then passed it to invoke. We'll have to manually fix these.

This makes writing tests easier, it will get converted to an unchecked
exception.

Adding throws Exception to some tests that invoked run directory on
SerializableRunnable.
These methods should no longer be used. Unfortunately, there are some
calls that could not be automatically converted, so they cannot be
completely removed.
This is an automatic conversion of many of the calls to vm.invoke that
take a string to instead use a lambda.

This was done using the following perl search/replace expressions on all
dunit tests.
perl -i -0pe 's/.\s*invoke(?:Boolean|Int|Long|)(Async|)\(\s*(\w+)(?:\.class|\.getClass\(\))\s*,\s*"([^"]+)",\s*new\s+Object\[\]\s*{([^}]*)}\s*\)/.invoke$1(() -> $2.$3($4))/mg' $1
perl -i -0pe 's/.\s*invoke(?:Boolean|Int|Long|)(Async|)\(\s*(\w+)(?:\.class|\.getClass\(\))\s*,\s*"([^"]+)"\s*\)/.invoke$1(() -> $2.$3())/mg' $1
perl -i -0pe 's/.\s*invoke(?:Boolean|Int|Long|)(Async|)\(\s*getClass\(\)\s*,\s*"([^"]+)",\s*new\s+Object\[\]\s*{([^}]*)}\s*\)/.invoke$1(() -> $2($3))/mg' $1
perl -i -0pe 's/.\s*invoke(?:Boolean|Int|Long|)(Async|)\(\s*getClass\(\)\s*,\s*"([^"]+)"\s*\)/.invoke$1(() -> $2())/mg' $1
Now that we are using lambdas, variables passed to the lambda should be
effectively final.
These are places where the code invoke was calling a method that doesn't
exist. These tests were either not running, or in some cases never
checking the return value of an invokeAsync call.
These couldn't be automatically converted. I've changed them to lambdas.
Fixing various issues being checked by the compiler:
 - Changing generics to match callers
 - Calling invoke on the correct class
 - Fixing some ambiguous casts.
 - Fixing some method visibility issues.
 - Removing extra comma after parameters
After converting these tests to use lambdas, it appears that the large
number of lambdas are overflowing some limit of the compiler. By
extracting methods for common lambdas, the overall number of lambda
classes required is reduced for these tests.
A bunch of tests were failing because the location in which static
fields are evaluated has changed. Before, a static in the parameter list
was evaluated on the controller. Now it is evaluated on the remote VM.

Converting the statics to fields or local variables so they are captured
and serialized.
These are a few places I missed in my last checkin.
@upthewaterspout
Copy link
Contributor Author

BTW - I can push this change myself, I just thought it would be easier to review as a PR than a reviewboard request. If I get a couple of +1s and no -1s in the next day or so I'll push it.

@jdeppe-pivotal
Copy link
Contributor

+1 Awesome!

@sboorlagadda
Copy link
Member

+1

@kirklund
Copy link
Contributor

+1 changes look great

@bschuchardt
Copy link
Contributor

+1 very nice

@jinmeiliao
Copy link
Member

+1 great

@asfgit asfgit merged commit f593119 into develop Feb 19, 2016
@asfgit asfgit deleted the feature/GEODE-866 branch March 7, 2017 18:14
bschuchardt pushed a commit to bschuchardt/geode that referenced this pull request Jul 10, 2020
By reducing thread count to 10x CPUs we found that on the same instances we only lose about 4% of throughput but seem more than 40% improvement in latency. More importantly the variation between runs drops significantly. This variation was greater than 10% on Java 11 and 3% on Java 8. When lowered to 10x threads we see closer to 1% variation for both Java 11 and 8.
robbadler pushed a commit to smgoller/geode that referenced this pull request Jul 12, 2022
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.

7 participants