hyperledger-iroha / iroha

Iroha - A simple, enterprise-grade decentralized ledger
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
438 stars 280 forks source link

perf: Don't validate transactions inside WASM #4995

Closed dima74 closed 2 months ago

dima74 commented 2 months ago

Context

I am investigating single peer tps performance (#4727), and it turns out that actual execution of wasm code takes most of the time per transaction (https://github.com/hyperledger/iroha/issues/3716#issuecomment-2299147066).

Solution

This PR removes validation of transactions at WASM side - there is no need to revalidate transaction which comes from Iroha Rust code. This gives approximately 50% tps increase (single peer). Also size of default executor is reduced from 492KB to 391KB.

Comparison of tps:

compare

Fixes #4803 Related: #4727 Related: #3716

Checklist

github-actions[bot] commented 2 months ago

@BAStos525

mversic commented 2 months ago

I think you should apply this to all validate_*** methods in this crate

you still didn't apply it to Name::validate_str

mversic commented 2 months ago

I think you should apply this to all validate_*** methods in this crate

you still didn't apply it to Name::validate_str

also Parameter, Trigger and event_set

dima74 commented 2 months ago
mversic commented 2 months ago
  • Removed validation for Name::validate_str

    • For Parameter, the only validation is NonZeroUsize::try_from(/* NonZeroU64 */), I think it should be kept as is

    • For Trigger there is method ActionCandidate::validate which does really small match check, and also is used in ActionCandidate::new. Do you think it is worth to change it?

    • For event_set didn't find validation method, could you clarify?

it's fine, I only looked around for deserialize functions

Can you update the numbers in the PR description?

dima74 commented 2 months ago

Can you update the numbers in the PR description?

Updated executor size. Tps numbers remains the same