Discuss the RVC implementation
yangfei at iscas.ac.cn
yangfei at iscas.ac.cn
Tue Sep 20 11:48:35 UTC 2022
Hi Xiaolin,
> -----Original Messages-----
> From: "Xiaolin Zheng" <yunyao.zxl at alibaba-inc.com>
> Sent Time: 2022-09-20 18:44:21 (Tuesday)
> To: yangfei <yangfei at iscas.ac.cn>
> Cc: riscv-port-dev <riscv-port-dev at openjdk.org>
> Subject: Re: Discuss the RVC implementation
>
> Hi Felix,
>
> TL;DR of code size evaluations, stably reproduced:
>
> If a piece of code is 100 bytes full of 4-byte instructions:
> 1. In the current master branch with RVC, it may shrink to 95 bytes. (compression rate is %5)
> 2. With the new implementation at [1], it may shrink to 84 bytes. (compression rate is 16%; ~11% more than master)
> 3. With the special patch at [2] (a special optimization of compressing two "slli"s in the movptr), it may shrink to 79 bytes. (compression rate is 21%; ~%5 addition to the previous one, because movptr() is used in a quite big quantity. But this patch might need further beautification for the hard-coded enumeration and will cause complexity for reviewing, so we'd postpone that temporarily)
> These are evaluated by a hand-written toy histogram[3], excluding the scratch_emit, and tested with release build (for fastdebug build, the compression rate is far more than release mode; but we may not care about that), only for evaluation purposes.
>
> About the performance, I need more time to make some more evaluations. Due to the patch of the new implementation should wait for the loom port merging first, we have plenty of time then. I am going to make a long run of specjbb2015 to measure it on average. Will update the result in the same thread.
>
> ---------------
>
> Precisely, here are some detailed data about the code size.
>
> This histogram mentioned above presents all the instructions emitted in a JVM process, shown when exiting. For example, the picture in [4].
>
> The second row (RVC instructions) + The third row (4-byte normal instructions) = The fourth row (total instructions); sorted by the fourth row.
> If RVC is not enabled, the second row is always 0 and the third row is always equal to the fourth row.
>
> Tested with the new RVC [1] branch with springboot / springboot-petclinic / SPECjvm2008 / SPECjbb2015(when exiting), the results are all a stable ~84%. The SPECjvm2008 results are at [5]. Please search the keywords "Ideally Code Size Could Shrink to" in the files in the browser for more details.
>
> P.S.: the result with the special patch [2] is about ~79% at [6] for future references, but might be reserved for now.
>
> Best,
> Xiaolin
>
> [1] https://github.com/zhengxiaolinX/jdk/commits/REBASE-rvc-beautify
> [2] https://github.com/zhengxiaolinX/jdk/commit/3a4d80197da0c497c844016b9a9fbae541eca9c8
> [3] https://github.com/zhengxiaolinX/jdk/commit/5312cbd8ac860f47b109ab2a99750041865c018d
> [4] https://github.com/openjdk/riscv-port/pull/34
> [5] http://cr.openjdk.java.net/~xlinzheng/rvc-size/size/
> [6] http://cr.openjdk.java.net/~xlinzheng/rvc-size/size-full/
Thanks for taking the time measuring those figures :-)
It's great to know that your new proposal for supporting RVC works better in respect of codesize metric.
I am currently looking at the details of your code changes at [1].
I just realized that your work bears some code cleanup in the first two commits. I would suggest we upstream those code cleanup first if possible.
Regards,
Fei
[1] https://github.com/zhengxiaolinX/jdk/commits/REBASE-rvc-beautify</riscv-port-dev@openjdk.org></yangfei at iscas.ac.cn></yunyao.zxl at alibaba-inc.com>
More information about the riscv-port-dev
mailing list