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/12/04 22:30:11 UTC

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

     [ https://issues.apache.org/jira/browse/ACCUMULO-4067?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Josh Elser resolved ACCUMULO-4067.
----------------------------------
    Resolution: Fixed

Reduce down to major after a quick microbenchmark showed getMethod only taking about .5millis. Not going to be a big performance hit :)

> 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
>            Assignee: Josh Elser
>             Fix For: 1.6.5, 1.7.1, 1.8.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> 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)