arm64 python: Avoid nested class in insn hook for 10x hook and 10% overall speedup (#2095)
* arm64 python: Avoid nested class in insn hook for 10x hook speedup Promote CpReg to a module-level class to address unnecessary performance reduction. In a real-world use case tracing the emulation of real-world machine code, this change reduces time spent in CpReg namedtuple construction from 10% of overall time to below 1%, for a 10x speedup of the insn hook itself, or a 10% overall speedup. Measured using cProfile, python 3.13. * upgrade distro to 22.04 * revert to 22.04 for now * also revert for wheels --------- Co-authored-by: mio <mio@lazym.io>
This commit is contained in:
committed by
GitHub
parent
1ba25def8e
commit
e166cd93bb
8
.github/workflows/build-uc2.yml
vendored
8
.github/workflows/build-uc2.yml
vendored
@@ -471,7 +471,7 @@ jobs:
|
||||
generators: 'Ninja'
|
||||
}
|
||||
- {
|
||||
os: ubuntu-latest,
|
||||
os: ubuntu-22.04,
|
||||
arch: aarch64,
|
||||
python-arch: aarch64,
|
||||
python-ver: '3.8',
|
||||
@@ -479,10 +479,10 @@ jobs:
|
||||
artifact: 'ubuntu-cmake-aarch64.7z',
|
||||
archiver: '7z a',
|
||||
generators: 'Ninja',
|
||||
distro: ubuntu20.04
|
||||
distro: ubuntu22.04
|
||||
}
|
||||
- {
|
||||
os: ubuntu-latest,
|
||||
os: ubuntu-22.04,
|
||||
arch: ppc64le,
|
||||
python-arch: ppc,
|
||||
python-ver: '3.8',
|
||||
@@ -490,7 +490,7 @@ jobs:
|
||||
artifact: 'ubuntu-cmake-ppc64le.7z',
|
||||
archiver: '7z a',
|
||||
generators: 'Ninja',
|
||||
distro: ubuntu20.04
|
||||
distro: ubuntu22.04
|
||||
}
|
||||
compiler: [ gcc ]
|
||||
steps:
|
||||
|
||||
4
.github/workflows/build-wheels-publish.yml
vendored
4
.github/workflows/build-wheels-publish.yml
vendored
@@ -55,9 +55,9 @@ jobs:
|
||||
# x86_64 - musllinux
|
||||
- { os: ubuntu-latest, arch: x86_64, cibw_build: 'cp38-musllinux*', cibw_skip: '' }
|
||||
# aarch64 - manylinux
|
||||
- { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp38-manylinux*', cibw_skip: '' }
|
||||
- { os: ubuntu-22.04, arch: aarch64, cibw_build: 'cp38-manylinux*', cibw_skip: '' }
|
||||
# aarch64 - musllinux
|
||||
- { os: ubuntu-latest, arch: aarch64, cibw_build: 'cp38-musllinux*', cibw_skip: '' }
|
||||
- { os: ubuntu-22.04, arch: aarch64, cibw_build: 'cp38-musllinux*', cibw_skip: '' }
|
||||
- { os: macos-13, arch: x86_64, cibw_build: 'cp38*', cibw_skip: '' }
|
||||
- { os: macos-latest, arch: arm64, cibw_build: 'cp38*', cibw_skip: '' }
|
||||
- { os: windows-2019, arch: AMD64, cibw_build: 'cp38*', cibw_skip: '' }
|
||||
|
||||
@@ -37,6 +37,15 @@ class UcRegCP64(UcTupledReg[ARM64CPReg]):
|
||||
return self.val
|
||||
|
||||
|
||||
class CpReg(NamedTuple):
|
||||
crn: int
|
||||
crm: int
|
||||
op0: int
|
||||
op1: int
|
||||
op2: int
|
||||
val: int
|
||||
|
||||
|
||||
class UcAArch64(Uc):
|
||||
"""Unicorn subclass for ARM64 architecture.
|
||||
"""
|
||||
@@ -57,14 +66,6 @@ class UcAArch64(Uc):
|
||||
def __hook_insn_sys_cb(uc: Uc, reg: int, pcp_reg: Any, key: int) -> int:
|
||||
cp_reg = ctypes.cast(pcp_reg, ctypes.POINTER(UcRegCP64)).contents
|
||||
|
||||
class CpReg(NamedTuple):
|
||||
crn: int
|
||||
crm: int
|
||||
op0: int
|
||||
op1: int
|
||||
op2: int
|
||||
val: int
|
||||
|
||||
cp_reg = CpReg(cp_reg.crn, cp_reg.crm, cp_reg.op0, cp_reg.op1, cp_reg.op2, cp_reg.val)
|
||||
|
||||
return callback(uc, reg, cp_reg, user_data)
|
||||
|
||||
Reference in New Issue
Block a user