Move instruction profiling to a dedicated thread#526
Move instruction profiling to a dedicated thread#526mohitejaikumar wants to merge 1 commit intosolana-foundation:mainfrom
Conversation
|
@lgalabru I’d really appreciate your review and any feedback you may have. |
|
This is really awesome, @mohitejaikumar! I still haven't gotten to test yet so I'm not ready to sign-off. One concern I have - currently this code: let ix_profiles = match ix_profile_rx {
Some(rx) => tokio::task::block_in_place(|| rx.recv().ok().flatten()),
None => None,
};is happening directly after the transaction is processed for the real result. So in the original implementation, the an instruction profile for a transaction with 10 instructions executed 10 transactions: Your implementation slightly parallelizes by spawning a thread for 1-9, awaiting tx 10, then awaiting the thread: So this only shortens the number of txs the user is waiting on by 1. Can we slightly expand this approach. Rather than waiting on the instruction profiling thread to complete, we return the original result without ix profiles and append them later? Later, if the user fetches the profile result for a signature/uuid, we'll fetch whatever we have, which is likely to include the profile result. Thoughts @mohitejaikumar, @lgalabru? |
Implements #320
start_profiling_runloopthat spawns a long-lived "Instruction Profiler" thread viahiro_system_kit::thread_named.ProfilingJobstruct - Packages all data needed for profiling (cloned SVM, transaction, accounts, etc.) to send across the thread boundary.Option<Sender<ProfilingJob>>toSurfnetSvm.fetch_all_tx_accounts_then_process_tx_returning_profile_resto send profiling jobs to the dedicated thread, execute the transaction on the current thread, then collect profiling results — running both in parallel.setup_profilinghelper - Extracted profiling channel setup into a reusable function called from bothstart_local_surfnet_runloopandtests.ClonetoIndexedLoadedAddressesandTransactionLoadedAddressesto enable moving data into the profiling job.