summaryrefslogtreecommitdiffstats
path: root/idatui
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-07 02:35:07 +0200
committeruser <user@clank>2026-08-07 02:35:07 +0200
commit60f0d70b81510d9dd58d4cc7992f33663f5aca88 (patch)
tree5613cc2cf8190b09520e84c13398396a167e4181 /idatui
parentFetch a graph's listing rows from the blocks' MERGED EXTENTS, not their conve... (diff)
downloadida-tui-60f0d70b81510d9dd58d4cc7992f33663f5aca88.tar.gz
ida-tui-60f0d70b81510d9dd58d4cc7992f33663f5aca88.tar.xz
ida-tui-60f0d70b81510d9dd58d4cc7992f33663f5aca88.zip
Two independent constants: memoise the pygments token -> Rich style lookup (a decompilation uses ~18 distinct token types but each token walked up to nine 'token in ttype' hierarchy checks), and hold the worker-connect poll at 5ms for the first 5s instead of backing off geometrically from the first probe.
Result: {"status":"keep","total_ms":18856.8,"lg_boot_ms":689.7,"lg_decomp_ms":2484.2,"lg_graph_ms":1120,"lg_hex_ms":700.1,"lg_index_ms":96.5,"lg_listing_cold_ms":425.6,"lg_listing_warm_ms":511.5,"lg_nav_ms":6590.7,"lg_palette_ms":4.8,"lg_render_ms":215.1,"lg_search_ms":2195.5,"pure_graph_ms":238.1,"sm_boot_ms":431.5,"sm_decomp_ms":667.2,"sm_graph_ms":686.9,"sm_hex_ms":569.8,"sm_index_ms":0,"sm_listing_cold_ms":258.1,"sm_listing_warm_ms":283.2,"sm_nav_ms":365.2,"sm_palette_ms":0.3,"sm_render_ms":243.7,"sm_search_ms":79,"fails":0}
Diffstat (limited to 'idatui')
-rw-r--r--idatui/highlight.py24
-rw-r--r--idatui/worker_client.py13
2 files changed, 32 insertions, 5 deletions
diff --git a/idatui/highlight.py b/idatui/highlight.py
index 5f504bf..a19f86a 100644
--- a/idatui/highlight.py
+++ b/idatui/highlight.py
@@ -41,11 +41,24 @@ _DEFAULT = Style(color="#c3cad3") # 11.0:1 body
_lexer = CLexer(stripnl=False, ensurenl=False)
+#: Resolved styles by token type. Pygments token types are interned singletons
+#: and a whole decompilation only ever uses about eighteen of them, but
+#: ``token in ttype`` is a hierarchy walk and _STYLES is scanned in order -- so
+#: without this every token in the body pays up to nine of those walks. It was a
+#: quarter of the time spent highlighting a function.
+_STYLE_CACHE: dict[object, Style] = {}
+
+
def _style_for(token) -> Style:
- for ttype, style in _STYLES:
- if token in ttype:
- return style
- return _DEFAULT
+ style = _STYLE_CACHE.get(token)
+ if style is None:
+ style = _DEFAULT
+ for ttype, candidate in _STYLES:
+ if token in ttype:
+ style = candidate
+ break
+ _STYLE_CACHE[token] = style
+ return style
def highlight_c(code: str) -> list[list[Segment]]:
@@ -55,6 +68,9 @@ def highlight_c(code: str) -> list[list[Segment]]:
if not value:
continue
style = _style_for(token)
+ if "\n" not in value: # the common case: a token inside one line
+ lines[-1].append(Segment(value, style))
+ continue
parts = value.split("\n")
for i, part in enumerate(parts):
if i > 0:
diff --git a/idatui/worker_client.py b/idatui/worker_client.py
index 59c62a1..4f90700 100644
--- a/idatui/worker_client.py
+++ b/idatui/worker_client.py
@@ -116,7 +116,17 @@ class WorkerClient:
# fifth of a second even when the worker was ready in milliseconds
# (a small binary, or a seeded .i64), which is most of the time in
# the tests and noticeable on a re-open.
+ #
+ # Backing off geometrically from the first probe was still too eager:
+ # a seeded database is ready at ~250ms, by which point the delay has
+ # grown to 134ms, so every open waited ~350ms whatever the binary --
+ # the same number for a 47KB `echo` and a 1.2MB `bash`, which is what
+ # gives a polling artefact away. Hold the fast rate for the first few
+ # seconds (a connect attempt on an absent socket is microseconds) and
+ # only slow down for a genuine cold auto-analysis, which runs for
+ # minutes and does not care about 200ms.
delay = 0.005
+ fast_until = t0 + 5.0
while time.time() < deadline:
try:
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -132,7 +142,8 @@ class WorkerClient:
progress(f"auto-analyzing {os.path.basename(self._bin)}… "
f"({int(time.time() - t0)}s)")
time.sleep(delay)
- delay = min(delay * 1.6, 0.2)
+ if time.time() > fast_until:
+ delay = min(delay * 1.6, 0.2)
raise IDAConnectionError("worker did not become ready in time")
@property