neonlabsorg / solana-program-library

A collection of Solana-maintained on-chain programs
https://solana.com
Other
0 stars 0 forks source link

Evaluate the effect of using memcpy/memmove from custom Solana SDK #183

Closed s-medvedev closed 3 years ago

s-medvedev commented 3 years ago

To carry out measurements, we need to use a Solana node with support for memory system calls and build a contract with a custom toolchain.

Memory operations syscall can be found in https://github.com/solana-labs/solana/pull/16447

Custom toolchain supported the memory operations:

  1. https://github.com/dmakarov/bpf-tools/actions/runs/748017344 - first version.
  2. https://github.com/dmakarov/bpf-tools/actions/runs/755303744 - second version. This version doesn't generate a call to sol_mem* syscalls unless the number of store or load instructions is greater than 8 for the operation. It may be more efficient to perform mem-ops on small amounts of data in the VM than to make a syscall for every mem-op. It would be interesting to see your results comparing both versions of the toolchain.

Expected result: Here is what jackmay expect:

s-medvedev commented 3 years ago
Base Syscalls-1 Syscalls-2    
8830 7849 11% 8857 0% CREATE  
9246 8199 11% 9268 0% CREATE  
6293523 6230410 1% 6234533 1% DEPLOY deploy UniswapV2Factory
224226 95898 57% 102172 54% CONT  
9246 8199 11% 9268 0% CREATE  
6074352 6054892 0% 6059066 0% DEPLOY deploy ERC20
279963 236590 15% 248772 11% CONT  
9246 8199 11% 9268 0% CREATE  
6018818 5999342 0% 6003465 0% DEPLOY deploy ERC20
279411 236183 15% 248226 11% CONT  
9246 8199 11% 9268 0% CREATE  
341660 289435 15% 294316 14% TRX factory.createPair(tokenA, tokenB)
1242029 1002169 19% 1031531 17% CONT  
107548 92136 14% 96298 10% TRX token0.transfer(pair, token0Amount)
246454 222255 10% 233165 5% CONT  
107591 92179 14% 96341 10% TRX token1.transfer(pair, token1Amount)
246666 222378 10% 233374 5% CONT  
300680 254991 15% 261689 13% TRX pair.mint(wallet)
1743233 1602006 8% 1647768 5% CONT  
827038 748724 9% 783558 5% CONT  
107548 92136 14% 96298 10% TRX token0.transfer(pair, swapAmount)
247376 223088 10% 234081 5% CONT  
296910 251969 15% 257596 13% TRX pair.swap()
1467123 1349944 8% 1400329 5% CONT