diff options
author | Lukas Larsson <[email protected]> | 2017-10-12 16:00:50 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2017-11-20 09:57:43 +0100 |
commit | a1c796e7f6b86b4b506492ae6354382c565278d1 (patch) | |
tree | b83738b3d313a2c43bdcaf25b555a8c4602492c2 /erts/preloaded | |
parent | 0149a73d15df1f80cb46752ec3829f48c38dd230 (diff) | |
download | otp-a1c796e7f6b86b4b506492ae6354382c565278d1.tar.gz otp-a1c796e7f6b86b4b506492ae6354382c565278d1.tar.bz2 otp-a1c796e7f6b86b4b506492ae6354382c565278d1.zip |
erts: Implement batching maps:iterator
This iterator implementation fetches multiple elements to
iterate over in one call to erts_internal:maps_next instead
of one at a time. This means that the memory usage will go
up for the iterator as we are buffering elements, but the
usage is still bounded.
In this implementation the max memory usage is 1000 words.
Using this approach makes the iterator as fast as using
maps:to_list, so maps:iterator/2 has been removed.
Diffstat (limited to 'erts/preloaded')
-rw-r--r-- | erts/preloaded/ebin/erts_internal.beam | bin | 12100 -> 12128 bytes | |||
-rw-r--r-- | erts/preloaded/src/erts_internal.erl | 17 |
2 files changed, 9 insertions, 8 deletions
diff --git a/erts/preloaded/ebin/erts_internal.beam b/erts/preloaded/ebin/erts_internal.beam Binary files differindex 015508d326..3257c68897 100644 --- a/erts/preloaded/ebin/erts_internal.beam +++ b/erts/preloaded/ebin/erts_internal.beam diff --git a/erts/preloaded/src/erts_internal.erl b/erts/preloaded/src/erts_internal.erl index 46bdeaad30..efff76f1fa 100644 --- a/erts/preloaded/src/erts_internal.erl +++ b/erts/preloaded/src/erts_internal.erl @@ -32,7 +32,7 @@ -export([await_port_send_result/3]). -export([cmp_term/2]). -export([map_to_tuple_keys/1, term_type/1, map_hashmap_children/1, - maps_to_list/2, map_next/2]). + maps_to_list/2, map_next/3]). -export([open_port/2, port_command/3, port_connect/2, port_close/1, port_control/3, port_call/3, port_info/1, port_info/2]). @@ -367,11 +367,6 @@ term_type(_T) -> map_hashmap_children(_M) -> erlang:nif_error(undefined). --spec erts_internal:flush_monitor_messages(Ref, Multi, Res) -> term() when - Ref :: reference(), - Multi :: boolean(), - Res :: term(). - %% return a list of key value pairs, at most of length N -spec maps_to_list(M,N) -> Pairs when M :: map(), @@ -382,16 +377,22 @@ maps_to_list(_M, _N) -> erlang:nif_error(undefined). %% return the next assoc in the iterator and a new iterator --spec map_next(I, M) -> {K,V,NI} when +-spec map_next(I, M, A) -> {K,V,NI} | list() when I :: non_neg_integer(), M :: map(), K :: term(), V :: term(), + A :: iterator | list(), NI :: maps:iterator(). -map_next(_I, _M) -> +map_next(_I, _M, _A) -> erlang:nif_error(undefined). +-spec erts_internal:flush_monitor_messages(Ref, Multi, Res) -> term() when + Ref :: reference(), + Multi :: boolean(), + Res :: term(). + %% erlang:demonitor(Ref, [flush]) traps to %% erts_internal:flush_monitor_messages(Ref, Res) when %% it needs to flush monitor messages. |