-
Notifications
You must be signed in to change notification settings - Fork 696
[WIP] Refactor Stack to eliminate mix types #1666
Conversation
9943250 to
4ef015f
Compare
4ef015f to
2358e8b
Compare
dd9c025 to
17d4586
Compare
17d4586 to
16560c9
Compare
|
@cburgdorf We can see the A better benchmark would be comparing the times taken to run a |
Some Points to Note
|
To do this we should first write the benchmark code against |
I'm still leaning pretty heavily towards just having |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With respect to benchmarking:
Your suggestion about benchmarking these at the Computation level seems like the right track. As I think you pointed out, the benchmarks in this pull request aren't likely to give us a very good picture of the performance. You might write a small smart contract that does something like the following.
contract TestStack {
function doLotsOfPops() {
uint v = 0
for (uint i=0; i<100; i++) {
v += 100
}It'll be worth examining the bytecode this produces and writing up some variants that use in-memory variables instead of a constant like 100. This approach should give you benchmark scripts that better match the real execution environment and which are not tied directly to the Stack object's API.
| the stack. | ||
| """ | ||
| return self._stack.pop(num_items, type_hint) | ||
| if num_items == 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to completely get rid of the type hinting and any conversion between int <-> bytes in both the Computation and Stack APIs, moving all conversion down into the opcode functions themselves.
For example:
Lines 6 to 8 in dfe43ae
| def mstore(computation: BaseComputation) -> None: | |
| start_position = computation.stack_pop(type_hint=constants.UINT256) | |
| value = computation.stack_pop(type_hint=constants.BYTES) |
This would become:
def mstore(computation: BaseComputation) -> None:
start_position = computation.stack_pop(type_hint=constants.UINT256)
raw_value = computation.stack_pop1()
value = int_to_big_endian(raw_value)
...|
Closing, stale. |
What was wrong?
As part of Issue #1656
How was it fixed?
The
Stacknow stores only objects of typeint. It previously also used to storebytes. Now thebytesare converted tointbefore storing on the stack, and any theStackissues out the popped elements in the form ofint. It is expected to convert theintegerstobytesat the call site, wherever necessary.Cute Animal Picture