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

ISPN-5962 Implementation of RpcManagerImpl.invokeRemotely causes high CPU usage #3841

Closed
wants to merge 2 commits into from

Conversation

pruivo
Copy link
Member

@pruivo pruivo commented Nov 24, 2015

https://issues.jboss.org/browse/ISPN-5962

did some cleanups as well.

@@ -148,4 +150,17 @@ void invokeRemotelyInFuture(NotifyingNotifiableFuture<Map<Address, Response>> fu
*/
RpcOptions getDefaultRpcOptions(boolean sync, DeliverOrder deliverOrder);

static Map<Address, Response> waitFor(CompletableFuture<Map<Address, Response>> future, RpcOptions options)
throws InterruptedException, ExecutionException {
long waitTime = options.timeout() * 2;
Copy link
Member

Choose a reason for hiding this comment

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

@pruivo pruivo force-pushed the ISPN-5962/compfuture_get branch 4 times, most recently from 03106ec to 1ac00a1 Compare November 24, 2015 18:05
@pruivo
Copy link
Member Author

pruivo commented Nov 24, 2015

@tristantarrant updated. I've created a RpcUtil and I put the method there. It is used everywhere (RpcManager and Transport). let me know that you think.

topologyAffectedCommand.setTopologyId(currentTopologyId);
}
}
setTopologyId(rpc);
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather wait for a constant time, expressed in nanos so there's no conversion during the RPC (e.g. private static final long BIG_DELAY_NANOS = TimeUnit.DAYS.toNanos(1)).

private RpcUtil() {
}

public static <T> T waitFor(CompletableFuture<T> future)
Copy link
Member

Choose a reason for hiding this comment

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

One more (very late) suggestion: this should be useful for anything that needs to wait on a CompletableFuture, so I'd move it to CompletableFutures.

@pruivo
Copy link
Member Author

pruivo commented Dec 2, 2015

@danberindei updated!

@@ -502,7 +502,7 @@ public Address getAddress() {
CompletableFuture<Map<Address, Response>> future = invokeRemotelyAsync(recipients, rpcCommand, mode,
timeout, responseFilter, deliverOrder, anycast);
try {
return future.get();
return CompletableFutures.await(future);
Copy link
Member

Choose a reason for hiding this comment

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

Could we add some comments here why we can afford to wait endlessly here? What is providing the guarantees that we are sure that we'll never wait endlessly?

Copy link
Member Author

Choose a reason for hiding this comment

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

what do you mean by "wait endlessly"? all the rpc has a timeout.

Copy link
Member

Choose a reason for hiding this comment

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

@pruivo Please add a comment saying the invokeRemotelyAsync is guaranteed to complete within timeout millis, so there's no need to use a timeout here.

… CPU usage

* Cleanup some code in RpcManager
… CPU usage

* Replace CompletableFuture.get() by CompletableFuture.get(long,TimeUnit).
@pruivo
Copy link
Member Author

pruivo commented Dec 7, 2015

add the comment and rebased @galderz and @danberindei .

@pruivo pruivo removed the Question label Dec 7, 2015
@danberindei
Copy link
Member

Integrated, thanks Pedro!

@danberindei danberindei closed this Dec 7, 2015
@pruivo pruivo deleted the ISPN-5962/compfuture_get branch July 10, 2021 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants