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

Load tests/2.11.0 ccip1.4 #1023

Closed

Conversation

mateusz-sekara
Copy link
Contributor

Motivation

Solution

asoliman92 and others added 6 commits June 14, 2024 13:17
## Motivation

Every call to arm_contract.NewARMContract deserialized ARM contract abi
under the hood. Considering that OnRamp.IsSourceCursed is called very
often by the background worker it creates a huge CPU overhead. Please
initialize ARMContract only once and cache it instead of doing it with
every method call

## Solution

* Add new cachedRmnContract field to OnRamp struct
* Cache it once per OnRamp initialization
*  fix: Use correct cache function for StaticConfig
* Add Benchmark before and after caching

Note: I did benchmark the caching function against using a map with the
address as key and the function caching was a bit faster. Also using the
caching is more consistent with the current implementation like
`StaticConfig`.

Benchmark results:
```
BenchmarkIsSourceCursedWithCache-14        90266             12526 ns/op
BenchmarkIsSourceCursedWithCache-14        88867             12411 ns/op
BenchmarkIsSourceCursedWithCache-14        90930             12379 ns/op
BenchmarkIsSourceCursedWithCache-14        91108             12259 ns/op
BenchmarkIsSourceCursedWithCache-14        90915             12306 ns/op
BenchmarkIsSourceCursedOriginal-14          3002            397356 ns/op
BenchmarkIsSourceCursedOriginal-14          2996            402220 ns/op
BenchmarkIsSourceCursedOriginal-14          3009            399806 ns/op
BenchmarkIsSourceCursedOriginal-14          2575            397963 ns/op
BenchmarkIsSourceCursedOriginal-14          2596            396812 ns/op
```
## Motivation

ABIEncode/ABIDecode functions are used in multiple places in CCIP.
Unfortunately, these functions keep serializing provided abi with every
call to them and most (all?) of the usage in CCIP has always const abi
that never change over time.


## Solution

* Add a string to *abi.ABI map which is only accessible inside
abi_helpers
* Cache all abiStr ( distinguish between encode, decode for same abiStr)
* Add new public facing functions for `ABIEncode` and `ABIDecode` and
use them instead `utils.ABIEncode` and `utils.ABIDecode`

Benchmark results:
```
BenchmarkComparisonEncode/WithoutCache-14                 125930              8219 ns/op
BenchmarkComparisonEncode/WithoutCache-14                 145154              8355 ns/op
BenchmarkComparisonEncode/WithoutCache-14                 141247              8437 ns/op
BenchmarkComparisonEncode/WithoutCache-14                 141610              8371 ns/op
BenchmarkComparisonEncode/WithCache-14                   1219718               969.8 ns/op
BenchmarkComparisonEncode/WithCache-14                   1233378               979.3 ns/op
BenchmarkComparisonEncode/WithCache-14                   1220919               988.2 ns/op
BenchmarkComparisonEncode/WithCache-14                   1000000              1063 ns/op
BenchmarkComparisonDecode/WithoutCache-14                 149152              8080 ns/op
BenchmarkComparisonDecode/WithoutCache-14                 148034              7842 ns/op
BenchmarkComparisonDecode/WithoutCache-14                 149011              7815 ns/op
BenchmarkComparisonDecode/WithoutCache-14                 145190              8369 ns/op
BenchmarkComparisonDecode/WithCache-14                   2385868               501.6 ns/op
BenchmarkComparisonDecode/WithCache-14                   2335604               517.9 ns/op
BenchmarkComparisonDecode/WithCache-14                   2327654               495.4 ns/op
BenchmarkComparisonDecode/WithCache-14                   2376956               493.6 ns/op
```
## Motivation

Currently we marshal the updated observation just to unmarshall it after
returning from `commitObservationJSONBackComp`.

## Solution

We can return the CommitObservation directly.
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

Successfully merging this pull request may close these issues.

4 participants