mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
53051663d3c5e262be112692d6f52444d034e8e5
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f7f67575ac |
perf(ghidra): read ahead in the background and for batch_decompile (#14898)
* perf(ghidra): read ahead in the background and for batch_decompile Read-ahead used to decompile a whole window before answering the request that carried it, starting up to eight native decompiler processes one after another (about 200 ms each). Small runs paid that startup before their first result, so batch_decompile could not use it and a small decompile-all was slower than a serial one. The carrying request now decompiles its own function at once on the session decompiler. The rest of the window is queued for REA's own worker threads, started only for the queued work (none for a single function, at most eight), and each opens its decompiler on its own thread and takes the next queued function as soon as it is open. A later request uses a finished result, including a failure or timeout, without decompiling again; waits for a running one, which its own earlier-started deadline bounds; or takes back a queued one and decompiles it itself. Cancelling a request cancels the read-ahead; an edit, a payload change or shutdown stops the workers, including those still opening, and idle workers close after 30 seconds. batch_decompile now names its next functions the same way, through the window size shared with decompile-all on the analysis port. Closes #14836 * fix(ghidra): redecompile read-ahead failures under a changed deadline A read-ahead task keeps the decompile deadline it ran under, but its lookup ignored it. After ghidra.decompile_timeout_seconds changed, a later request reused a timeout produced under the old deadline, reported the new limit in its message, and could wait without bound for work started with no deadline. The task lookup now decides reuse by the cache policy: a completed decompilation is reusable under any deadline, as cached results are, while a failure, a timeout or unfinished work under a different deadline is cancelled and decompiled again under the request's own deadline. The result cache needs no change: it holds only completed decompilations. * fix(ghidra): bound finished read-ahead and cancel it with the workflow Finished results were trimmed only when another hint arrived, so tasks that completed after the last hint stayed strongly held. Trim them when they finish too. A cancelled export could also leave workers running after the carrying request had returned, because only an in-flight procedure_pseudo_code monitor disposed them. The same workflow signal now sends abandon_decompile_read_ahead for that gap. The failure probe derives its worker count from the bridge cap, waits until a reused task has actually completed, and releases startup latches before disposal if a check fails. * fix(ghidra): keep a read-ahead abort watch across unrelated requests Every Program request called noteRequest, which dropped the owning signal whenever the next request used a different one. A list or journal gap could then leave the workers running after that owner cancelled. Only a request that carries its own read-ahead window replaces the owner. The bridge has one worker pool, so that new window is the owner that a later abort disposes. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): ignore an older read-ahead watch after a newer owner A queued read-ahead took ownership before the carrying request settled, and that request's finally installed its watch again. Cancelling the older workflow then abandoned the newer window. watch now leaves the newer owner in place. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): admit read-ahead ownership and cap the queued backlog A window with no signal left the previous abort listener armed, so that abort disposed the new workers. Ownership now moves when the request is admitted, including a signal-less window, and a request removed while queued does not move it. An abandon queued for an older generation is not written. Queued tasks no worker has started are dropped with finished results beyond two windows. A decompile a worker has already started stays, and the worker cap bounds how many of those exist. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): abandon read-ahead without waiting for the active request The cleanup frame waited in the Program queue, so a slow analysis request held a cancelled workflow's workers. The reader now disposes those workers the way it applies cancel, and the client writes that frame beside the FIFO. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): cancel read-ahead on the reader without waiting abandon_decompile_read_ahead runs on the socket reader and was waiting up to 10s for workers. The cancel frame behind it then missed the 2s grace, and the client closed the session. A task already taken by the waiting request was also absent from the map, so that wait did not cancel it. The reader now only cancels monitors, including taken tasks, and returns. The handler still waits for workers on edit, shutdown, and its own dispose. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): stop the failure probe calling the removed abandon handler The real-Ghidra probe invoked abandon_decompile_read_ahead through handleRequest. That method is only accepted on the socket reader now, so the probe threw method_unavailable before it could report success. The probe now blocks the handler on a taken task, calls cancelDecompileAhead, and checks that the call returns inside a second and the waiting request is cancelled. Co-authored-by: morluto <morluto@users.noreply.github.com> * style(ghidra): format the read-ahead client files CI format:check rejected GhidraClient, GhidraReadAheadCancellation, and the request-queue test. The shard jobs never started because static checks failed first. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): take read-ahead ownership after wire admission A carrying request can leave the queue and still be refused when it exceeds bridge.max_request_bytes. Ownership now moves only immediately before the wire writes a frame that passed admission, so a refused hint leaves the previous window's abort owner in place. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com> |
||
|
|
06fa8d0634 |
perf(ghidra): decompile upcoming export functions in parallel (#14847)
* fix(ghidra): reuse completed decompiles and decompile code outside functions * perf(ghidra): decompile upcoming export functions in parallel * fix(ghidra): say what the procedure inventory omits and how to reach it * fix(ghidra): say when a file offset maps to code outside every function A file-offset selector that mapped to disassembled code without a function failed with advice to choose an inventory procedure, which cannot name that code. The failure now states the fact and that procedure_pseudo_code can decompile it by the mapped analysis address. One predicate now decides that an address holds code outside every function for the address, file-offset and procedure_not_found paths, and the bridge imports UndefinedFunction and SoftReference like its other dependencies. * fix(ghidra): scope decompile read-ahead to the operation it prepares The bridge ran the read-ahead window in the generic serve loop, before the ping, analysis-incomplete and read-only checks and for any method that carried the field. It now runs only for procedure_pseudo_code, after those checks. The pool state sits with the other decompiler fields and its Ghidra types are imported. The export tests now cover consecutive windows, a limit that ends inside a window and a window whose first function sends no decompile request. The provider guide states that a function failing or timing out inside a window is attempted again by its own request, and how long the pool lives. * fix(ghidra): decompile code outside functions selected by file offset A file offset names the same location as its mapped analysis address, but an offset that mapped to code Ghidra disassembled without a function was refused while the address decompiled. The offset now resolves through the same on-the-fly UndefinedFunction path and limitation, and its selection reports the inferred entry as procedure_address. The refusal that sent the caller back to the address form is removed. * fix(ghidra): bound decompile read-ahead by the carrying request's deadline A request that carried a read-ahead window waited for every function in it, then decompiled its own function again when the window's attempt failed or timed out, so one configured deadline could elapse twice. That request now waits only within its own deadline, consumes the window's outcome for its function whatever it is, and cancels siblings still running once it has its result and the deadline has passed; they stay uncached for their own requests. The hint is advisory, so selectors past one window are now ignored instead of refusing the request. Pooled decompilers run on a private thread pool rather than resizing Ghidra's shared "Parallel Decompiler" pool, and are released after 30 seconds without a window. * test(ghidra): cover read-ahead deadline and hint clamp on real Ghidra The decompiler failure probe now injects a read-ahead window whose carrying function times out beside a sibling that never finishes. It checks that the request reports the timeout without decompiling again, waits only within its deadline, leaves the cancelled sibling uncached, uses REA's own thread pool, and that a longer hint is clamped to one window. The probe no longer ran against the current bridge: it used a removed three-argument Request constructor, expected the old timeout and failure wording, and injected decompilers that completed-result reuse never called. It now builds full requests, matches the current messages by prefix and clears reused results before each injection. * fix(ghidra): keep reused decompiles across reads without decompiler options A request that omits decompile_max_payload_mib now leaves the session's payload limit unchanged instead of resetting it to the Ghidra default, so an instruction or metadata read no longer discards completed decompiles. An explicit null still selects the installed default. Boundary limitations for a reused decompile of code outside every function now use the function the decompile widened, not a fresh entry-only UndefinedFunction. * docs(ghidra): state what an omitted decompiler payload option means * fix(decompile-all): plan read-ahead from the decision the export loop makes The read-ahead window decided which functions would be requested from journal history alone. A journaled write whose file was later deleted is requested again, and file problems spend the caller's limit, so a resume could prepare functions outside its limit while the ones it requested got no preparation. Each function is now decided once by the same check the loop uses. The window keeps those decisions for the loop, counts every attempt against the limit, and names only functions that will be decompiled. * test(ghidra): cover payload-option omission and reused undefined-function bodies * fix(decompile-all): start each read-ahead hint at the function that sends it A function the window named first could send no decompile request, for example when procedure_info classifies it as external, so the next request sent a hint headed by that function. A provider reads the head as the carrying request's own function, so the bridge could not keep that request's window result and might decompile it again. The request now takes the planned window from its own function on. |
||
|
|
a062529bb2 |
feat(ghidra): bound one procedure's decompile without closing the session (#5662)
* feat(ghidra): bound one procedure's decompile without closing the session Fixes #5340 * fix(ghidra): report decompile limit as a request timeout Keeps BinarySession from marking every Ghidra operation unavailable after one procedure's decompile reaches the limit, and names the MCP tool-call deadline in the remediation. * fix(ghidra): budget the decompile limit and report cancellation-closed sessions Adds REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS to the derived Codex/Kimi tool deadline and forwards it through setup. Marks a remote failure that settles after caller cancellation so the timeout projection no longer promises session reuse. * fix(ghidra): align deadline bounds and cancellation outcomes * refactor(ghidra): shorten deadline recovery guidance * fix(mcp): clarify the scope of inferred decompile deadlines * test(ghidra): verify deadline workflows and document measured costs Separate failure and registration cases by their distinct contracts. Record actual Linux Ghidra, CLI and MCP evidence with measured context, elapsed time, CPU and memory, and explicit remaining coverage limits. * docs(ghidra): pin integration and distinguish baseline format failures * fix(ghidra): own failure lifecycle wording in the provider * test(ghidra): budget timeout fixture generation before allocation * fix(ghidra): align capability and traversal deadline guidance * style(config): align deadline guidance formatting * docs(ghidra): record capability and traversal verification --------- Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> |
||
|
|
c374c2fe72 |
fix(ghidra): preserve partial dossiers on decompiler failure (#4650)
Preserve listing-backed facts and explicit unavailable decompiler facets when one function fails. Retain Evidence while excluding transient failures and derived workflows from snapshot reuse; keep healthy cache reuse and owned cleanup semantics. Fixes #4644. |