From f0d2d51ee6ef982a36785cc223c781d96e26d95e Mon Sep 17 00:00:00 2001 From: blasty Date: Fri, 7 Aug 2026 02:49:28 +0200 Subject: HexView.render_line emits style RUNS instead of one Segment per byte cell (35 -> 7 segments per row), and Head is a NamedTuple rather than a frozen dataclass (tuple.__new__ 1.9us vs a dataclass __init__ 2.9us, and it is built once per listing row walked). Result: {"status":"keep","total_ms":17784.1,"lg_boot_ms":680.8,"lg_decomp_ms":2344,"lg_graph_ms":1106.5,"lg_hex_ms":576.4,"lg_index_ms":96.5,"lg_listing_cold_ms":552.9,"lg_listing_warm_ms":431.3,"lg_nav_ms":6256.4,"lg_palette_ms":4.8,"lg_render_ms":224.1,"lg_search_ms":1916.5,"pure_graph_ms":241.3,"sm_boot_ms":442.6,"sm_decomp_ms":591.3,"sm_graph_ms":663.9,"sm_hex_ms":419.2,"sm_index_ms":0,"sm_listing_cold_ms":258.2,"sm_listing_warm_ms":281.8,"sm_nav_ms":374.4,"sm_palette_ms":0.3,"sm_render_ms":251.1,"sm_search_ms":69.8,"fails":0} --- idatui/domain.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'idatui/domain.py') diff --git a/idatui/domain.py b/idatui/domain.py index 9dea353..e107786 100644 --- a/idatui/domain.py +++ b/idatui/domain.py @@ -28,6 +28,7 @@ import threading import urllib.request from concurrent.futures import ThreadPoolExecutor from dataclasses import dataclass, field, replace +from typing import NamedTuple from typing import Callable, TYPE_CHECKING from . import diag @@ -90,15 +91,19 @@ class Line: ) -@dataclass(frozen=True, slots=True) -class Head: +class Head(NamedTuple): """One flat-listing item (from the ``heads`` server tool): a code instruction, a data item, or an undefined byte run. - ``slots=True`` because this is the most-constructed object in the codebase: - a jump to an address near the end of a big binary builds one per listing row - it walks past, hundreds of thousands of them, and the slotted layout is ~20% - cheaper to build (and smaller to hold). + A ``NamedTuple`` rather than a dataclass because this is by far the + most-constructed object in the codebase -- a jump to an address near the end + of a big binary builds one per listing row it walks past, a quarter of a + million of them -- and ``tuple.__new__`` costs 1.9us where a frozen + dataclass's ``__init__`` costs 2.9us. Attribute reads are marginally slower + (10ns vs 20ns), which is the right trade: rows are built far more often than + they are read, and a viewport only ever reads forty of them. + + Immutable, like the frozen dataclass it replaced. """ ea: int -- cgit v1.3.1-sl0p