Skip to content

riscv_dis_opt2_gdb_cache

Tsukasa OI edited this page Nov 20, 2022 · 4 revisions

Disassembler: Optimization: Cache per-BFD disassembler

Feature Description (First Proposal)

On RISC-V, calling the disassembler function (libopcodes) is not a small cost. This is because riscv_get_disassembler function sets the default architecture from given BFD's .riscv.attributes section. However, by default, GDB calls this function for every instruction.

This commit replaces RISC-V's disassembler function and stop calling riscv_get_disassembler function if current BFD has not changed.

It expects around 30-80% improvements on disassembling relatively large chunk of RISC-V code but most of them will be obscured by a RISC-V disassembler optimization the author is currently working on. Still, 3-5% of performance improvements will remain (due to reduced BFD section reads).

Request for Comments (First Proposal)

I'm confident that most of BFD contents won't change so dynamically on GDB and caching itself is not a bad idea. Still, I'm not sure whether this usage of static variables is okay.

Response

It seems it's mildly unsafe to do that and I was recommended to use GDB registry system.

I will submit second proposal after checking registry system and re-benchmarking.

Clone this wiki locally