Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization ideas #13

Open
5 tasks
xermicus opened this issue May 24, 2024 · 0 comments
Open
5 tasks

Optimization ideas #13

xermicus opened this issue May 24, 2024 · 0 comments

Comments

@xermicus
Copy link
Member

xermicus commented May 24, 2024

  • We need to cast pointers safely from i256 to register size ints when calling into runtime API methods. While in theory all pointers should be automatically in bounds, this assumption doesn't necessarily hold (as pointers / memory offsets are potentially untrusted user input). Safe truncation adds a lot of overhead in contract code; I tried to offload it into it's own function but on 32bit PolkaVM leads to even more code overall (because we have an i256 argument). On 64bit this could work though and if so we should use this optimization when compiling for size (-Oz).
  • zbb instructions need to be implemented in PolkaVM. By experimentally switching the LLVM target to rv64 with+zbb significant changes in code size can be observed:
    ---- cases::tests::codesize stdout ----
    ERC20: 93072 bytes (change from 194140 bytes)
    Baseline: 63128 bytes (change from 131084 bytes)
    Flipper: 63688 bytes (change from 131796 bytes)
    Fibonacci: 63880 bytes (change from 133328 bytes)
    Computation: 65056 bytes (change from 135456 bytes)
    
  • Investigate potential improvements of byte swaps, memset, memmove, mulmod, divs and the like
  • Check all alignments, attributes etc. if they still make sense with our target
  • Related: Constant arguments for calls #62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant