You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "Josh Elser (JIRA)" <ji...@apache.org> on 2015/11/30 18:21:11 UTC

[jira] [Created] (ACCUMULO-4067) TTimeoutTransport repeatedly uses reflection to obtain method

Josh Elser created ACCUMULO-4067:
------------------------------------

             Summary: TTimeoutTransport repeatedly uses reflection to obtain method
                 Key: ACCUMULO-4067
                 URL: https://issues.apache.org/jira/browse/ACCUMULO-4067
             Project: Accumulo
          Issue Type: Improvement
          Components: rpc
            Reporter: Josh Elser
            Priority: Critical
             Fix For: 1.6.5, 1.7.1, 1.8.0


Noticed the following in TTimeoutTransport while looking at ACCUMULO-4065:

{code}
  private static InputStream getInputStream(Socket socket, long timeout) {
    try {
      Method m = NetUtils.class.getMethod("getInputStream", Socket.class, Long.TYPE);
      return (InputStream) m.invoke(null, socket, timeout);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
{code}

We should really just invoke {{getMethod}} once and cache the {{Method}} instance instead of repeatedly getting it every time we create a new connection (which is often).

Not sure if this is a "hot" enough code path to have a noticeable performance impact, but it should be good to fix regardless.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)