Re: LocalVariablesSorter performance

"Eugene Kuleshov" (via asm Mailing List) <[email protected]> Wed, 17 Feb 2021 09:28:42 -0500
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CADFjdoW0-W3AoFPPwyF4fj3SLCXG4_F-d7QOe1HJAchpFgy=jA@mail.gmail.com>
This is a multi-part message in MIME format...

------------=_1613572134-2833-7
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Eirik,

  I'm wondering why you need to prepend variables at all?
  Unless converting static to non-static method or adding parameters,
knowing the max number of variables for the method you can use
variable slots after that.

  regards,
  Eugene


On Wed, Feb 17, 2021 at 5:37 AM Eirik Bj=C3=B8rsn=C3=B8s <[email protected]> wrot=
e:
>
> Hi,
>
> I've been looking into the performance of LocalVariablesSorter. This clas=
s currently only supports expanded frames, which means we need to use the C=
lassReader.EXPAND_FRAMES option when reading the class.
>
> As my use case only requires prepending variables at the very start of me=
thods, I don't need to support adding variables at arbitrary code locations=
. Taking this into consideration, I made a LocalVariablesPrepender class wh=
ich simply shifts local variables forward by the amount needed for injectin=
g the new variables. It also remaps all FULL frames and converts first-fram=
e SAME/APPEND frames into remapped FULL frames.
>
> This allows LocalVariablesPrepender to be used without ClassReader.EXPAND=
_FRAMES.
>
> I then did a JMH benchmark comparing the throughput of injecting a single=
 local variable (injects ICONST_M1, ISTORE x)  using LocalVariablesSorter t=
o that of my LocalVariablesPrepender. The class used for testing was Jetty'=
s Server class.
>
> Here are the results:
>
> Benchmark                                        Mode  Cnt     Score     =
Error  Units
> LocalVariableInjectors.localVariablesPrepender  thrpt   25  3940.191 =C2=
=B1  42.010  ops/s
> LocalVariableInjectors.localVariablesSorter     thrpt   25  2681.776 =C2=
=B1 175.943  ops/s
>
> That's a significant performance improvement for not expanding frames!
>
> What would it take to rewrite LocalVariablesSorter to not require expande=
d frames? If that task is too complex, then perhaps ASM should have somethi=
ng similar to a LocalVariablesPrepender?
>
> Cheers,
> Eirik.
>
>
>
> --
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=3Dhelp
> OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1613572134-2833-7
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1613572134-2833-7--