mirror of
https://github.com/morluto/rea.git
synced 2026-11-30 18:39:24 +00:00
* 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>