You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2014/04/24 11:05:15 UTC

[jira] [Updated] (BCEL-119) BCEL is unnecessarily slow

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

Emmanuel Bourg updated BCEL-119:
--------------------------------

      Description: 
Profiling BCEL showed that a lot of time is spent in very little code. I have
tracked down some of those problems, fixed them and saw a performance gain of more than 100%. Later I have also found out that the AspectJ team and probably a few other people had done the same a long time ago. Why these changes were never incorporated into BCEL trunk, I do not know.

I understand, that from a performance perspective, I should use ASM anyway (which is crazily optimized:
http://asm.objectweb.org/doc/developer-guide.html#optimizations).

Nevertheless some improvement probably would not hurt.

Here is the log that shows the performance gains of all the optimizations I
applied: 

// SVN

ClassParser.parse: 0.680119516 s
ClassGen.init: 0.596259385 s
MethodGen.init: 7.627294121 s
MethodGen.getMethod: 2.415617407 s
ClassGen.getJavaClass.getBytes: 0.573408268 s
Total: 12.358684516 s

ClassParser.parse: 0.486115354 s
ClassGen.init: 0.60449182 s
MethodGen.init: 7.111806585 s
MethodGen.getMethod: 2.137157344 s
ClassGen.getJavaClass.getBytes: 0.514757783 s
Total: 11.262602001 s

ClassParser.parse: 0.513113271 s
ClassGen.init: 0.596378125 s
MethodGen.init: 7.09741055 s
MethodGen.getMethod: 2.095376224 s
ClassGen.getJavaClass.getBytes: 0.472800383 s
Total: 11.161931208 s


// Tune Instruction.readInstruction: Replace Reflection with SWITCH

ClassParser.parse: 0.675918174 s
ClassGen.init: 0.644816324 s
MethodGen.init: 2.37364546 s
MethodGen.getMethod: 2.350236018 s
ClassGen.getJavaClass.getBytes: 0.556582776 s
Total: 7.04360494 s

ClassParser.parse: 0.476201456 s
ClassGen.init: 0.579783983 s
MethodGen.init: 2.099810171 s
MethodGen.getMethod: 2.181126984 s
ClassGen.getJavaClass.getBytes: 0.488192476 s
Total: 6.227110003 s

ClassParser.parse: 0.477742278 s
ClassGen.init: 0.624694793 s
MethodGen.init: 2.130978382 s
MethodGen.getMethod: 2.002330381 s
ClassGen.getJavaClass.getBytes: 0.465331297 s
Total: 6.066029749 s

// Tune ConstantPoolGen.init: Use StringBuffer

ClassParser.parse: 0.659908237 s
ClassGen.init: 0.519261101 s
MethodGen.init: 2.305224708 s
MethodGen.getMethod: 2.148664254 s
ClassGen.getJavaClass.getBytes: 0.617371665 s
Total: 6.710080325 s

ClassParser.parse: 0.466696673 s
ClassGen.init: 0.451812126 s
MethodGen.init: 2.017315203 s
MethodGen.getMethod: 1.995585551 s
ClassGen.getJavaClass.getBytes: 0.495333748 s
Total: 5.812121207 s

ClassParser.parse: 0.446558571 s
ClassGen.init: 0.409762396 s
MethodGen.init: 1.937347861 s
MethodGen.getMethod: 2.118172599 s
ClassGen.getJavaClass.getBytes: 0.453922767 s
Total: 5.715940347 s

// Tune InstructionList.findHandle: Search directly

ClassParser.parse: 0.654898115 s
ClassGen.init: 0.55573093 s
MethodGen.init: 1.670222455 s
MethodGen.getMethod: 2.061828405 s
ClassGen.getJavaClass.getBytes: 0.540762239 s
Total: 5.888046098 s

ClassParser.parse: 0.452568062 s
ClassGen.init: 0.423769764 s
MethodGen.init: 1.369177618 s
MethodGen.getMethod: 2.015685293 s
ClassGen.getJavaClass.getBytes: 0.435557417 s
Total: 5.059064222 s

ClassParser.parse: 0.494708779 s
ClassGen.init: 0.455453825 s
MethodGen.init: 1.24245897 s
MethodGen.getMethod: 1.937969884 s
ClassGen.getJavaClass.getBytes: 0.441652383 s
Total: 4.911468856 s

// Tune InvokeInstruction: Determine size directly

ClassParser.parse: 0.660422314 s
ClassGen.init: 0.515718571 s
MethodGen.init: 1.522720755 s
MethodGen.getMethod: 1.321707714 s
ClassGen.getJavaClass.getBytes: 0.542893948 s
Total: 4.963233706 s

ClassParser.parse: 0.447217948 s
ClassGen.init: 0.402592348 s
MethodGen.init: 1.30743097 s
MethodGen.getMethod: 1.242607624 s
ClassGen.getJavaClass.getBytes: 0.445710399 s
Total: 4.194830316 s

ClassParser.parse: 0.442218102 s
ClassGen.init: 0.449956988 s
MethodGen.init: 1.335540618 s
MethodGen.getMethod: 1.136129872 s
ClassGen.getJavaClass.getBytes: 0.441781442 s
Total: 4.132813855 s

  was:
Profiling BCEL showed that a lot of time is spent in very little code. I have
tracked down some of those problems, fixed them and saw a performance gain of
more than 100%. Later I have also found out that the AspectJ team and probably a
few other people had done the same a long time ago. Why these changes were never
incorporated into BCEL trunk, I do not know.

I understand, that from a performance perspective, I should use ASM anyway
(which is crazily optimized:
http://asm.objectweb.org/doc/developer-guide.html#optimizations).

Nevertheless some improvement probably would not hurt.

Here is the log that shows the performance gains of all the optimisations I
applied: 

// SVN

ClassParser.parse: 0.680119516 s
ClassGen.init: 0.596259385 s
MethodGen.init: 7.627294121 s
MethodGen.getMethod: 2.415617407 s
ClassGen.getJavaClass.getBytes: 0.573408268 s
Total: 12.358684516 s

ClassParser.parse: 0.486115354 s
ClassGen.init: 0.60449182 s
MethodGen.init: 7.111806585 s
MethodGen.getMethod: 2.137157344 s
ClassGen.getJavaClass.getBytes: 0.514757783 s
Total: 11.262602001 s

ClassParser.parse: 0.513113271 s
ClassGen.init: 0.596378125 s
MethodGen.init: 7.09741055 s
MethodGen.getMethod: 2.095376224 s
ClassGen.getJavaClass.getBytes: 0.472800383 s
Total: 11.161931208 s


// Tune Instruction.readInstruction: Replace Reflection with SWITCH

ClassParser.parse: 0.675918174 s
ClassGen.init: 0.644816324 s
MethodGen.init: 2.37364546 s
MethodGen.getMethod: 2.350236018 s
ClassGen.getJavaClass.getBytes: 0.556582776 s
Total: 7.04360494 s

ClassParser.parse: 0.476201456 s
ClassGen.init: 0.579783983 s
MethodGen.init: 2.099810171 s
MethodGen.getMethod: 2.181126984 s
ClassGen.getJavaClass.getBytes: 0.488192476 s
Total: 6.227110003 s

ClassParser.parse: 0.477742278 s
ClassGen.init: 0.624694793 s
MethodGen.init: 2.130978382 s
MethodGen.getMethod: 2.002330381 s
ClassGen.getJavaClass.getBytes: 0.465331297 s
Total: 6.066029749 s

// Tune ConstantPoolGen.init: Use StringBuffer

ClassParser.parse: 0.659908237 s
ClassGen.init: 0.519261101 s
MethodGen.init: 2.305224708 s
MethodGen.getMethod: 2.148664254 s
ClassGen.getJavaClass.getBytes: 0.617371665 s
Total: 6.710080325 s

ClassParser.parse: 0.466696673 s
ClassGen.init: 0.451812126 s
MethodGen.init: 2.017315203 s
MethodGen.getMethod: 1.995585551 s
ClassGen.getJavaClass.getBytes: 0.495333748 s
Total: 5.812121207 s

ClassParser.parse: 0.446558571 s
ClassGen.init: 0.409762396 s
MethodGen.init: 1.937347861 s
MethodGen.getMethod: 2.118172599 s
ClassGen.getJavaClass.getBytes: 0.453922767 s
Total: 5.715940347 s

// Tune InstructionList.findHandle: Search directly

ClassParser.parse: 0.654898115 s
ClassGen.init: 0.55573093 s
MethodGen.init: 1.670222455 s
MethodGen.getMethod: 2.061828405 s
ClassGen.getJavaClass.getBytes: 0.540762239 s
Total: 5.888046098 s

ClassParser.parse: 0.452568062 s
ClassGen.init: 0.423769764 s
MethodGen.init: 1.369177618 s
MethodGen.getMethod: 2.015685293 s
ClassGen.getJavaClass.getBytes: 0.435557417 s
Total: 5.059064222 s

ClassParser.parse: 0.494708779 s
ClassGen.init: 0.455453825 s
MethodGen.init: 1.24245897 s
MethodGen.getMethod: 1.937969884 s
ClassGen.getJavaClass.getBytes: 0.441652383 s
Total: 4.911468856 s

// Tune InvokeInstruction: Determine size directly

ClassParser.parse: 0.660422314 s
ClassGen.init: 0.515718571 s
MethodGen.init: 1.522720755 s
MethodGen.getMethod: 1.321707714 s
ClassGen.getJavaClass.getBytes: 0.542893948 s
Total: 4.963233706 s

ClassParser.parse: 0.447217948 s
ClassGen.init: 0.402592348 s
MethodGen.init: 1.30743097 s
MethodGen.getMethod: 1.242607624 s
ClassGen.getJavaClass.getBytes: 0.445710399 s
Total: 4.194830316 s

ClassParser.parse: 0.442218102 s
ClassGen.init: 0.449956988 s
MethodGen.init: 1.335540618 s
MethodGen.getMethod: 1.136129872 s
ClassGen.getJavaClass.getBytes: 0.441781442 s
Total: 4.132813855 s

         Priority: Minor
      Environment:     (was: Operating System: All
Platform: Other)
    Fix Version/s: 6.0
         Priority:   (was: P3)
       Issue Type: Improvement  (was: Bug)
         Severity:   (was: normal)

> BCEL is unnecessarily slow
> --------------------------
>
>                 Key: BCEL-119
>                 URL: https://issues.apache.org/jira/browse/BCEL-119
>             Project: Commons BCEL
>          Issue Type: Improvement
>          Components: Main
>    Affects Versions: 5.2
>            Reporter: Markus Gaisbauer
>            Assignee: Apache Commons Developers
>            Priority: Minor
>             Fix For: 6.0
>
>
> Profiling BCEL showed that a lot of time is spent in very little code. I have
> tracked down some of those problems, fixed them and saw a performance gain of more than 100%. Later I have also found out that the AspectJ team and probably a few other people had done the same a long time ago. Why these changes were never incorporated into BCEL trunk, I do not know.
> I understand, that from a performance perspective, I should use ASM anyway (which is crazily optimized:
> http://asm.objectweb.org/doc/developer-guide.html#optimizations).
> Nevertheless some improvement probably would not hurt.
> Here is the log that shows the performance gains of all the optimizations I
> applied: 
> // SVN
> ClassParser.parse: 0.680119516 s
> ClassGen.init: 0.596259385 s
> MethodGen.init: 7.627294121 s
> MethodGen.getMethod: 2.415617407 s
> ClassGen.getJavaClass.getBytes: 0.573408268 s
> Total: 12.358684516 s
> ClassParser.parse: 0.486115354 s
> ClassGen.init: 0.60449182 s
> MethodGen.init: 7.111806585 s
> MethodGen.getMethod: 2.137157344 s
> ClassGen.getJavaClass.getBytes: 0.514757783 s
> Total: 11.262602001 s
> ClassParser.parse: 0.513113271 s
> ClassGen.init: 0.596378125 s
> MethodGen.init: 7.09741055 s
> MethodGen.getMethod: 2.095376224 s
> ClassGen.getJavaClass.getBytes: 0.472800383 s
> Total: 11.161931208 s
> // Tune Instruction.readInstruction: Replace Reflection with SWITCH
> ClassParser.parse: 0.675918174 s
> ClassGen.init: 0.644816324 s
> MethodGen.init: 2.37364546 s
> MethodGen.getMethod: 2.350236018 s
> ClassGen.getJavaClass.getBytes: 0.556582776 s
> Total: 7.04360494 s
> ClassParser.parse: 0.476201456 s
> ClassGen.init: 0.579783983 s
> MethodGen.init: 2.099810171 s
> MethodGen.getMethod: 2.181126984 s
> ClassGen.getJavaClass.getBytes: 0.488192476 s
> Total: 6.227110003 s
> ClassParser.parse: 0.477742278 s
> ClassGen.init: 0.624694793 s
> MethodGen.init: 2.130978382 s
> MethodGen.getMethod: 2.002330381 s
> ClassGen.getJavaClass.getBytes: 0.465331297 s
> Total: 6.066029749 s
> // Tune ConstantPoolGen.init: Use StringBuffer
> ClassParser.parse: 0.659908237 s
> ClassGen.init: 0.519261101 s
> MethodGen.init: 2.305224708 s
> MethodGen.getMethod: 2.148664254 s
> ClassGen.getJavaClass.getBytes: 0.617371665 s
> Total: 6.710080325 s
> ClassParser.parse: 0.466696673 s
> ClassGen.init: 0.451812126 s
> MethodGen.init: 2.017315203 s
> MethodGen.getMethod: 1.995585551 s
> ClassGen.getJavaClass.getBytes: 0.495333748 s
> Total: 5.812121207 s
> ClassParser.parse: 0.446558571 s
> ClassGen.init: 0.409762396 s
> MethodGen.init: 1.937347861 s
> MethodGen.getMethod: 2.118172599 s
> ClassGen.getJavaClass.getBytes: 0.453922767 s
> Total: 5.715940347 s
> // Tune InstructionList.findHandle: Search directly
> ClassParser.parse: 0.654898115 s
> ClassGen.init: 0.55573093 s
> MethodGen.init: 1.670222455 s
> MethodGen.getMethod: 2.061828405 s
> ClassGen.getJavaClass.getBytes: 0.540762239 s
> Total: 5.888046098 s
> ClassParser.parse: 0.452568062 s
> ClassGen.init: 0.423769764 s
> MethodGen.init: 1.369177618 s
> MethodGen.getMethod: 2.015685293 s
> ClassGen.getJavaClass.getBytes: 0.435557417 s
> Total: 5.059064222 s
> ClassParser.parse: 0.494708779 s
> ClassGen.init: 0.455453825 s
> MethodGen.init: 1.24245897 s
> MethodGen.getMethod: 1.937969884 s
> ClassGen.getJavaClass.getBytes: 0.441652383 s
> Total: 4.911468856 s
> // Tune InvokeInstruction: Determine size directly
> ClassParser.parse: 0.660422314 s
> ClassGen.init: 0.515718571 s
> MethodGen.init: 1.522720755 s
> MethodGen.getMethod: 1.321707714 s
> ClassGen.getJavaClass.getBytes: 0.542893948 s
> Total: 4.963233706 s
> ClassParser.parse: 0.447217948 s
> ClassGen.init: 0.402592348 s
> MethodGen.init: 1.30743097 s
> MethodGen.getMethod: 1.242607624 s
> ClassGen.getJavaClass.getBytes: 0.445710399 s
> Total: 4.194830316 s
> ClassParser.parse: 0.442218102 s
> ClassGen.init: 0.449956988 s
> MethodGen.init: 1.335540618 s
> MethodGen.getMethod: 1.136129872 s
> ClassGen.getJavaClass.getBytes: 0.441781442 s
> Total: 4.132813855 s



--
This message was sent by Atlassian JIRA
(v6.2#6252)