Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

WIP: Minor Code changes that optimise gas use #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

WIP: Minor Code changes that optimise gas use #27

wants to merge 4 commits into from

Conversation

Hephyrius
Copy link

@Hephyrius Hephyrius commented Dec 14, 2018

Brief: These changes are to the code present on the master branch as of 9th December 2018. They should be compatible with the latest commits, without clashes.

Note: Further smaller changes that reduce gas by providing minor changes to code, will be added to this commit.

Change Log: Compacted EmitRing event. This is done by storing values in a certain way. this allows 24 bytes are saved per ring. This equates to a roughly ~192 gas reduction per ring. Overall benchmark gas reduction ~ 500 gas

Original gas report:
Benchmark gas usage report:
simpleRingGas: 338677
typicalRingGas: 361322
p2pRingGas: 354619
multiRingGas: 528694
average: 395828

Gas after optimisation:
Benchmark gas usage report:
simpleRingGas: 338220
typicalRingGas: 360929
p2pRingGas: 354225
multiRingGas: 527979
average: 395338

Gas Reduction: ~500 gas reduced

Tests: all 216 pass

Harnick Khera added 3 commits December 9, 2018 22:48
Change Log:

Assemblified subring Check ~= 100 gas reduction

Removed all add( x , 0) instances from assembly operations as they are redundant/wasting gas
Replaced clear multiplication instances with answer ie instances with 32*5 with 160	~= 250 gas reduction

Refactored calculation of memory required by lists, using assembly and a new calculate function. this stops an extra for loop and ring index calculations ~= 300 gas reduction

Assemblified the Validity Check ~= 700 gas reduction

orderhelper - ValidateAllInfo is now all assembly ~= 750 gas reduction
@Hephyrius Hephyrius changed the title WIP: Minor Code changes that optomise gas use WIP: Minor Code changes that optimise gas use Dec 14, 2018
@Brechtpd
Copy link
Collaborator

Thanks, good change. It changes the data format a bit of the event so we'll see when we can merge this PR.

@Hephyrius
Copy link
Author

Hephyrius commented Dec 16, 2018

It might be possible to keep the data in its current form/order with this change. I'll see if I can make that work and get back when/if it does.

Edit: I reverted the order of the data, but managed to retain the packing savings.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants