Skip to main content

Module cache

Module cache 

Source
Expand description

§解析器缓存模块

提供高性能缓存机制,减少内存分配和重复计算:

  • 程序ID缓存:避免重复查找和分配
  • 账户公钥缓存:线程局部缓存,零锁竞争

§性能优势

  • 减少 30-50% 内存分配:通过缓存重用避免重复分配
  • 零锁竞争:线程局部存储,每个线程独立缓存
  • 快速查找:读写锁优化,读操作无阻塞

§使用示例

use sol_parser_sdk::core::cache::build_account_pubkeys_with_cache;
use solana_sdk::pubkey::Pubkey;

let instruction_accounts = vec![0u8, 1, 2];
let all_accounts = vec![Pubkey::default(); 10];

// 使用线程局部缓存,避免重复分配
let account_pubkeys = build_account_pubkeys_with_cache(&instruction_accounts, &all_accounts);

Structs§

AccountPubkeyCache
高性能账户公钥缓存

Functions§

build_account_pubkeys_with_cache
从线程局部缓存构建账户公钥列表