<div dir="ltr">Hi folks,<br><br>The existing implementation of the forward-edge CFI for virtual calls currently has a 128-byte cap [1] on the amount of padding for each vtable. This cap was established a long time ago so I collected code size and performance data for different caps on the vtable padding size to see if there is a better value.<br><br>Experiment Setup:<br>Program under test: Chromium (commit 6407dba4c9759affdb5ef44b9235601bc6b4ba9e)<br>Compiler: Clang (revision 334100, which is required by the version of Chromium used in the experiments)<br>Testing platorms:<br>1) x86-64:<br>CPU: Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz<br>OS: Debian GNU/Linux (Linux version 4.9.0-6-amd64)<br>RAM: 128 GB<br>2) ARM-64<br>Model: Pixel 2<br>OS: Android 8.1.0<br><br>Test results:<br>1) Code size<br>a) x86-64<br>The results are shown in size-x64.png.<br>"x64-[num]" represents the size of the Chromium build with the cap value of [num].<br><br>b) ARM-64<br>The results are shown in size-arm64.png.<br>"arm64-[num]" represents the size of the Chromium build with the cap value of [num].<br><br>On both platforms, 32-byte cap value generates the smallest binary.<br><br>2) Performance tests<br>I used Telemetry [2] to benchmark the performance of the builds.<br>a) x86-64<br>The results are shown in perf-x64.txt.<br>This file provides the regressions of each cap value compared with the exisiting 128-byte cap value.<br><br>b) ARM-64<br>The results are shown in perf-arm64.txt.<br>This file provides the regressions of each cap value compared with the exisiting 128-byte cap value.<br><br>On both platforms, none of the cap values makes a significant performance impact. Considering the noise involved in the performance tests, the absolute numbers here are not too meaningful. All we can learn is that different cap values yield similar performance.  <br><br>Because the 32-byte cap value seems to reduce the code size while maintain the similar performance, I propose to change the cap value from 128-byte to 32-byte. The patch can be found here: <a href="https://reviews.llvm.org/D49405">https://reviews.llvm.org/D49405</a><br><br>Please let me know if there are any questions or issues.  <br><br>Thanks,<br>Zhaomo<br><br>[1] <a href="https://github.com/llvm-mirror/llvm/blob/a94df7d526ce45abe6b10f04b4a73a3aa3bef0a4/lib/Transforms/IPO/LowerTypeTests.cpp#L774">https://github.com/llvm-mirror/llvm/blob/a94df7d526ce45abe6b10f04b4a73a3aa3bef0a4/lib/Transforms/IPO/LowerTypeTests.cpp#L774</a><br><br>[2] <a href="https://github.com/catapult-project/catapult/blob/master/telemetry/README.md">https://github.com/catapult-project/catapult/blob/master/telemetry/README.md</a><br><br></div>