Files
solana/sdk/benches/serialize_instructions.rs
mergify[bot] 53f8e58300 Demote write locks on transaction program ids (backport #19593) (backport #19633) (#19637)
* Demote write locks on transaction program ids (backport #19593) (#19633)

* Demote write locks on transaction program ids (#19593)

* Add feature

* Demote write lock on program ids

* Fixup bpf tests

* Update MappedMessage::is_writable

* Comma nit

* Review comments

(cherry picked from commit decec3cd8b)

# Conflicts:
#	core/src/banking_stage.rs
#	core/src/cost_model.rs
#	core/src/cost_tracker.rs
#	ledger-tool/src/main.rs
#	program-runtime/src/instruction_processor.rs
#	programs/bpf/tests/programs.rs
#	programs/bpf_loader/src/syscalls.rs
#	rpc/src/transaction_status_service.rs
#	runtime/src/accounts.rs
#	runtime/src/bank.rs
#	runtime/src/message_processor.rs
#	sdk/benches/serialize_instructions.rs
#	sdk/program/src/message/mapped.rs
#	sdk/program/src/message/sanitized.rs
#	sdk/src/transaction/sanitized.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
(cherry picked from commit fcda5d4a7d)

# Conflicts:
#	cli-output/src/display.rs
#	core/src/transaction_status_service.rs
#	program-test/src/lib.rs
#	programs/bpf_loader/src/syscalls.rs
#	runtime/src/accounts.rs
#	runtime/src/bank.rs
#	runtime/src/message_processor.rs
#	sdk/benches/serialize_instructions.rs
#	sdk/program/src/message.rs
#	sdk/src/feature_set.rs
#	transaction-status/src/parse_accounts.rs

* Replace feature and fix conflicts

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2021-09-04 09:10:57 +00:00

66 lines
2.0 KiB
Rust

#![feature(test)]
extern crate test;
use bincode::{deserialize, serialize};
use solana_sdk::instruction::{AccountMeta, Instruction};
use solana_sdk::message::Message;
use solana_sdk::pubkey;
use solana_sdk::sysvar::instructions;
use test::Bencher;
fn make_instructions() -> Vec<Instruction> {
let meta = AccountMeta::new(pubkey::new_rand(), false);
let inst = Instruction::new_with_bincode(pubkey::new_rand(), &[0; 10], vec![meta; 4]);
vec![inst; 4]
}
const DEMOTE_PROGRAM_WRITE_LOCKS: bool = true;
#[bench]
fn bench_bincode_instruction_serialize(b: &mut Bencher) {
let instructions = make_instructions();
b.iter(|| {
test::black_box(serialize(&instructions).unwrap());
});
}
#[bench]
fn bench_manual_instruction_serialize(b: &mut Bencher) {
let instructions = make_instructions();
let message = Message::new(&instructions, None);
b.iter(|| {
test::black_box(message.serialize_instructions(DEMOTE_PROGRAM_WRITE_LOCKS));
});
}
#[bench]
fn bench_bincode_instruction_deserialize(b: &mut Bencher) {
let instructions = make_instructions();
let serialized = serialize(&instructions).unwrap();
b.iter(|| {
test::black_box(deserialize::<Vec<Instruction>>(&serialized).unwrap());
});
}
#[bench]
fn bench_manual_instruction_deserialize(b: &mut Bencher) {
let instructions = make_instructions();
let message = Message::new(&instructions, None);
let serialized = message.serialize_instructions(DEMOTE_PROGRAM_WRITE_LOCKS);
b.iter(|| {
for i in 0..instructions.len() {
test::black_box(instructions::load_instruction_at(i, &serialized).unwrap());
}
});
}
#[bench]
fn bench_manual_instruction_deserialize_single(b: &mut Bencher) {
let instructions = make_instructions();
let message = Message::new(&instructions, None);
let serialized = message.serialize_instructions(DEMOTE_PROGRAM_WRITE_LOCKS);
b.iter(|| {
test::black_box(instructions::load_instruction_at(3, &serialized).unwrap());
});
}