-
Notifications
You must be signed in to change notification settings - Fork 2
riscv_dis_opts_hashtable
- Branch:
riscv-dis-opts-hashtable - Tracking PR: #4 (view Pull Request and Diff)
- Mailing List:
- PATCH v1 (2022-07-09)
- Pending: Disassembler: Implement "generic subsets"
It also changes the core disassembler. - Pending (RFC): Disassembler: Check shift amount against XLEN (disassembler)
It also changes the core disassembler.
- (You are here) Disassembler: Use faster hash table
- Disassembler: Minor optimizations (batch 1)
- Disassembler: Cache instruction class support
This patchset intends to improve performance on disassembling RISC-V code (which may possibly contain invalid data). It replaces riscv_hash (on opcodes/riscv-dis.c) with much faster data structure: sorted and partitioned hash table.
This is a technique actually used on SPARC architecture (opcodes/sparc-dis.c) and I simplified the algorithm even further. Unlike SPARC, RISC-V hashed opcode table is not a table to linked lists, it's just a table, pointing "start" elements of the sorted opcode list (sorted by hash code) and a global tail.
I benchmarked some of the programs and I measure somewhat between 2-10% performance increase while disassembling code section of RISC-V ELF files (objdump -d $FILE). That is not significant but not bad for such a small modification (with about 11KB heap memory allocation on 64-bit environment).
This is not the end. This structure significantly improves plain binary file handling (on objdump, objdump -b binary -m riscv:rv[32|64] -D $FILE). I tested on a big vmlinux image with debug symbols and I got over 50% performance improvements. This is due to the fact that, disassembling about one quarter of invalid "instruction" words required iterating over one thousand opcode entries (348 or more being vector instructions with OP-V, that can be easily skipped with this new data structure).
- Matching/printing phase is splitted (just like
riscv-dis-generics) -
Zfinxwith-M numericgenerates correct disassembly (just likeriscv-float-combined)
On disassembling linked RISC-V ELF files using objdump, performance improvements achieved by this patchset is about 15-20%. Pretty good for such a simple change.
| Program | Improvements | Notes |
|---|---|---|
Busybox 1.35.1 (RV64GC) |
17.5-19.8% | |
OpenSBI 1.1 (generic fw_*.elf) |
18.2-19.1% | |
Linux kernel 5.18 (vmlinux) |
15.6-16.7% | |
Linux kernel 5.18 (vmlinux.o) |
0.4-6.7% | Not finally linked |
glibc (libc.so.6) |
15.1-18.9% |
| Program | Improvements |
|---|---|
glibc (libc.a) |
1.5-1.9% |
newlib (libc.a) |
0.7-3.9% |
| Program | Improvements |
|---|---|
Linux kernel 5.18 (vmlinux) |
70.9-92.7% |
Random files (/dev/urandom) |
96.0-97.9% |
| 1M (1048576) CSR instructions | 104.5% |
| Program | Improvements |
|---|---|
Linux kernel 5.18 (vmlinux) with debug info |
0.9% |
Linux kernel 5.18 (vmlinux) without debug info |
2.1% |
OpenSBI 1.1 (generic fw_*.elf) |
2.2-3.4% |