Store gas #201
@ -25,7 +25,7 @@
|
|||||||
%% Size in bytes of serialization of a map for which we turn it into a store
|
%% Size in bytes of serialization of a map for which we turn it into a store
|
||||||
%% map. It's not worth turning small maps into store maps.
|
%% map. It's not worth turning small maps into store maps.
|
||||||
%% Under consensus!
|
%% Under consensus!
|
||||||
-define(STORE_MAP_THRESHOLD, 500).
|
-define(STORE_MAP_THRESHOLD, 100).
|
||||||
|
|
||||||
-type fate_value() :: aeb_fate_data:fate_type().
|
-type fate_value() :: aeb_fate_data:fate_type().
|
||||||
-type fate_value_or_tombstone() :: fate_value() | ?FATE_MAP_TOMBSTONE.
|
-type fate_value_or_tombstone() :: fate_value() | ?FATE_MAP_TOMBSTONE.
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
, heap_value_maps/1
|
, heap_value_maps/1
|
||||||
, heap_value_offset/1
|
, heap_value_offset/1
|
||||||
, heap_value_heap/1
|
, heap_value_heap/1
|
||||||
|
, heap_value_byte_size/1
|
||||||
, heap_fragment_maps/1
|
, heap_fragment_maps/1
|
||||||
, heap_fragment_offset/1
|
, heap_fragment_offset/1
|
||||||
, heap_fragment_heap/1
|
, heap_fragment_heap/1
|
||||||
@ -90,6 +91,25 @@ heap_value_offset({_, Heap}) -> Heap#heap.offset.
|
|||||||
binary() | #{non_neg_integer() => non_neg_integer()}.
|
binary() | #{non_neg_integer() => non_neg_integer()}.
|
||||||
heap_value_heap({_, Heap}) -> Heap#heap.heap.
|
heap_value_heap({_, Heap}) -> Heap#heap.heap.
|
||||||
|
|
||||||
|
%% -- Byte size of a heap value ----------------------------------------------
|
||||||
|
|
||||||
|
-spec heap_value_byte_size(heap_value()) -> non_neg_integer().
|
||||||
|
heap_value_byte_size({_, Heap}) ->
|
||||||
|
Value = Heap#heap.heap,
|
||||||
|
Maps = Heap#heap.maps,
|
||||||
|
ValueSize =
|
||||||
|
if is_binary(Value) -> byte_size(Value);
|
||||||
|
true -> 0 end,
|
||||||
|
MapsSize =
|
||||||
|
lists:sum([ pmap_size(Map) || Map <- maps:values(Maps#maps.maps) ]),
|
||||||
|
ValueSize + MapsSize.
|
||||||
|
|
||||||
|
pmap_size(#pmap{data = stored}) -> 0;
|
||||||
|
pmap_size(#pmap{data = Data}) when is_map(Data) ->
|
||||||
|
lists:sum([ byte_size(Key) + byte_size(Val)
|
||||||
|
|| {Key, Val} <- maps:to_list(Data),
|
||||||
|
Val /= tombstone ]).
|
||||||
|
|
||||||
%% -- Value to binary --------------------------------------------------------
|
%% -- Value to binary --------------------------------------------------------
|
||||||
|
|
||||||
-spec to_binary(aeb_aevm_data:data()) -> aeb_aevm_data:heap().
|
-spec to_binary(aeb_aevm_data:data()) -> aeb_aevm_data:heap().
|
||||||
|
Loading…
x
Reference in New Issue
Block a user