perf(ssh): Phase 3 BufferPool - preallocate Vec in hot paths
Phase 3: Preallocate Vec with capacity to reduce allocations channel.rs: - poll_exec_stdout_and_client(): Vec::with_capacity(channels * 3 + 1) - poll_exec_stdout_with_fds(): Vec::with_capacity(channels * 2) cipher.rs: - AES-CTR decrypt: payload Vec::with_capacity(payload_length) Performance improvement: - ~25% total improvement (Phase 1-3 cumulative) - 100MB transfer: 1 second (~100 MB/s) - 140x improvement from initial 712 KB/s Test: 158 passed, 0 failed
This commit is contained in:
@@ -703,7 +703,8 @@ impl EncryptedPacket {
|
||||
let payload_part2 = &remaining_encrypted[..payload_part2_len];
|
||||
|
||||
// 合并payload
|
||||
let mut payload = Vec::new();
|
||||
// Phase 3: 预分配 payload Vec(避免扩容)
|
||||
let mut payload = Vec::with_capacity(payload_length);
|
||||
payload.extend_from_slice(payload_part1);
|
||||
payload.extend_from_slice(payload_part2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user