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

erts: Implement max_heap_size process flag #1032

Merged
merged 70 commits into from
May 12, 2016

Commits on Mar 13, 2016

  1. Add diameter_tcp option throttle_cb

    To let a callback module decide whether or to receive another message
    from the peer, so that backpressure can be applied when it's
    inappropriate. This is to let a callback protect against reading more
    than can be processed, which is otherwise possible since diameter_tcp
    otherwise always asks for more.
    
    A callback is made after each message, and can answer to continue
    reading or to ask again after a timeout. It's each message instead of
    each packet partly for simplicity, but also since this should be
    sufficiently fine-grained. Per packet would require some interaction
    with the fragment timer that flushes partial messages that haven't been
    completely received.
    Anders Svensson committed Mar 13, 2016
    Configuration menu
    Copy the full SHA
    472a080 View commit details
    Browse the repository at this point in the history
  2. Make throttling callbacks on message reception

    The callback is now applied to the atom 'false' when asking if another
    message should be received on the socket, and to a received binary
    message after reception. Throttling on received messages makes it
    possible to distinguish between requests and answers.
    
    There is no callback on outgoing messages since these don't have to go
    through the transport process, even if they currently do.
    Anders Svensson committed Mar 13, 2016
    Configuration menu
    Copy the full SHA
    e7b286c View commit details
    Browse the repository at this point in the history
  3. Let throttling callback return a notification pid

    In addition to returning ok or {timeout, Tmo}, let a throttling callback
    for message reception return a pid(), which is then notified if the
    message in question is either discarded or results in a request process.
    Notification is by way of messages of the form
    
      {diameter, discard | {request, pid()}}
    
    where the pid is that of a request process resulting from the received
    message. This allows the notification process to keep track of the
    maximum number of request processes a peer connection can have given
    rise to.
    Anders Svensson committed Mar 13, 2016
    Configuration menu
    Copy the full SHA
    2ffb288 View commit details
    Browse the repository at this point in the history
  4. Let a throttling callback discard a received message

    This can be used as a simple form of overload protection, discarding the
    message before it's passed into diameter to become one more request
    process in a flood. Replying with 3004 would be more appropriate when
    the request has been directed at a specific server (the RFC's
    requirement) however, and possibly it should be possible for a callback
    to do this as well.
    Anders Svensson committed Mar 13, 2016
    Configuration menu
    Copy the full SHA
    993d540 View commit details
    Browse the repository at this point in the history
  5. Let a throttling callback answer a received message

    As discussed in the parent commit. This is easier said than done in
    practice, but there's no harm in allowing it.
    Anders Svensson committed Mar 13, 2016
    Configuration menu
    Copy the full SHA
    9298872 View commit details
    Browse the repository at this point in the history
  6. Don't ask throttling callback to receive more unless needed

    TCP packets can contain more than one message, so only ask to receive
    another message if it hasn't already been received.
    Anders Svensson committed Mar 13, 2016
    Configuration menu
    Copy the full SHA
    eae5e81 View commit details
    Browse the repository at this point in the history
  7. Throttle properly with TLS

    In particular, let a callback decide when to receive the initial
    message.
    Anders Svensson committed Mar 13, 2016
    Configuration menu
    Copy the full SHA
    8f9173b View commit details
    Browse the repository at this point in the history
  8. Acknowledge answers to notification pids when throttling

    By sending {diameter, {answer, pid()}} when an incoming answer is sent
    to the specified pid, instead of a discard message as previously. The
    latter now literally means that the message has been discarded.
    Anders Svensson committed Mar 13, 2016
    Configuration menu
    Copy the full SHA
    c322099 View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2016

  1. Let throttling callback send a throttle message

    That is, don't assume that it's only diameter_tcp doing so: allow it to
    be received when not throttling. This lets a callback module trigger a
    new throttling callback itself, but it's not clear if this will be
    useful in practice.
    Anders Svensson committed Mar 18, 2016
    Configuration menu
    Copy the full SHA
    14eb86d View commit details
    Browse the repository at this point in the history

Commits on Mar 25, 2016

  1. Don't assume list comprehension evaluation order

    Anders Svensson committed Mar 25, 2016
    Configuration menu
    Copy the full SHA
    a54a911 View commit details
    Browse the repository at this point in the history

Commits on Apr 20, 2016

  1. erts: Produce statistics for literal and hipe super carriers

    called 'literal_mmap' and 'exec_mmap'.
    
    Also moved existing erts_mmap info from 'mseg_alloc'
    to its own system_info({allocator, erts_mmap})
    
    with "allocators" default_mmap, literal_mmap and exec_mmap.
    sverker committed Apr 20, 2016
    Configuration menu
    Copy the full SHA
    4319cd6 View commit details
    Browse the repository at this point in the history

Commits on Apr 29, 2016

  1. erts: Move option info for erts_mmap

    from {allocator,mseg_alloc} to {allocator,erts_mmap}
    sverker committed Apr 29, 2016
    Configuration menu
    Copy the full SHA
    c2c4744 View commit details
    Browse the repository at this point in the history
  2. erts: Add literal_mmap and exec_mmap to system_info

    erlang:system_info(allocator) ->
      {Allocator, Version, Features, Settings}
    
    Features includes 'literal_mmap' and/or 'exec_mmap'
    if they exist.
    sverker committed Apr 29, 2016
    Configuration menu
    Copy the full SHA
    0a5d8f3 View commit details
    Browse the repository at this point in the history
  3. erts: Add erts_mmap to system_info(allocator)

    to the Settings list
    
    {Allocator, Version, Features, Settings}
    sverker committed Apr 29, 2016
    Configuration menu
    Copy the full SHA
    48d24da View commit details
    Browse the repository at this point in the history
  4. erts: Fix system_info({allocator_sizes, mseg_alloc})

    will now return
    
    [{instance,0,[{segments_size,9961472,9961472,11010048}]},
     {instance,1,[{segments_size,6291456,6291456,6815744}]},
     {instance,2,[{segments_size,524288,524288,786432}]},
     {instance,3,[{segments_size,1048576,1048576,1835008}]},
     {instance,4,[{segments_size,0,0,262144}]}]
    
    and not just empty lists.
    sverker committed Apr 29, 2016
    Configuration menu
    Copy the full SHA
    9f5fd83 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    e75fdd3 View commit details
    Browse the repository at this point in the history

Commits on May 3, 2016

  1. Remove dead case clause

    Orphaned in commit 9298872.
    Anders Svensson committed May 3, 2016
    Configuration menu
    Copy the full SHA
    9169589 View commit details
    Browse the repository at this point in the history

Commits on May 4, 2016

  1. erts: Refactor erl_mmap.h

    by (only) moving around stuff in the file.
    
    in order to make it easier to ifdef away
    all erts_mmap_* if not supported.
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    067c234 View commit details
    Browse the repository at this point in the history
  2. erts: Add macro HAVE_ERTS_MMAP

    and make erts_mmap unavailable at compile time
    if not supported.
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    dd5087b View commit details
    Browse the repository at this point in the history
  3. Suppress dialyzer warning

    This one:
    
        diameter_tcp.erl:928: (call)
        The call diameter_tcp:throttle({'timeout',_},#transport{socket::port() | {'sslsocket',_,_},parent::pid(),module::atom(),frag::binary() | {non_neg_integer(),non_neg_integer(),binary(),[binary()]},ssl::boolean() | [any()],timeout::'infinity' | non_neg_integer(),tref::'false' | reference(),flush::boolean(),throttle_cb::'false' | fun() | maybe_improper_list(fun() | maybe_improper_list(any(),[any()]) | {atom(),atom(),[any()]},[any()]) | {atom(),atom(),[any()]},throttled::'true' | binary()})
        will never return since it differs in the 1st argument from the
    success typing arguments:
    
        ('discard' | 'ok' | binary() | pid() | {'discard' | 'ok' | binary() | pid(),'false' | fun() | [fun() | [any()] | {atom(),atom(),[any()]}] | {atom(),atom(),[any()]}},#transport{socket::port() | {'sslsocket',_,_},parent::pid(),module::atom(),frag::binary() | {non_neg_integer(),non_neg_integer(),binary(),[binary()]},ssl::boolean() | [any()],timeout::'infinity' | non_neg_integer(),tref::'false' | reference(),flush::boolean(),throttle_cb::'false' | fun() | [fun() | [any()] | {atom(),atom(),[any()]}] | {atom(),atom(),[any()]},throttled::binary()})
    
    It's true that the clause doesn't return, because of the throw, and
    that's the intention.
    Anders Svensson committed May 4, 2016
    Configuration menu
    Copy the full SHA
    4709258 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    03afaae View commit details
    Browse the repository at this point in the history
  5. erts: Rename struct type

    as is trips up my editor symbol tagging.
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    9791998 View commit details
    Browse the repository at this point in the history
  6. erts: Rename constants in enum erts_break_op

    with uppercase for constants
    and why not call them 'RESTART' and 'PAUSE' as the API.
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    af2a4c5 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    4a4475d View commit details
    Browse the repository at this point in the history
  8. erts: Remove multi scheduler blocking in match specs

    for enable_trace and disable_trace operations.
    
    Instead seize needed locks while updating trace flags.
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    3261d58 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    8b2906d View commit details
    Browse the repository at this point in the history
  10. erts: Add matchspec restrictions for 'receive' trace

    and non-call-trace.
    
    This is the easy way out to avoid difficult locking
    scenarios when accessing tracing flags on another process.
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    5cb62b0 View commit details
    Browse the repository at this point in the history
  11. erts: Add Sender in 'receive' trace matchspec

    All 'EXIT' and monitor messages are sent from 'system'
    
    Timeouts are "sent" from 'clock_service'
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    9627711 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    da75310 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    36e9d73 View commit details
    Browse the repository at this point in the history
  14. erts: Fix PAM to be callable from non-scheduler thread

    also simplified the interface to to run PAM from trace
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    14b81c6 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    d0ffd5c View commit details
    Browse the repository at this point in the history
  16. erts: Fix bug in trace_pattern for 'on_load'

    'on_load' is a call trace.
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    6197aa2 View commit details
    Browse the repository at this point in the history
  17. erts: Add send and 'receive' to trace_info/2

    to obtain match specs
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    5417267 View commit details
    Browse the repository at this point in the history
  18. runtime_tools: Add dbg functions tpe/2 and ctpe/1

    To set/clear match specs for send and receive trace.
    
    'e' for Event as we might want to add match specs
    for other trace events (proc exit,link,ulink,...).
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    bc274db View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    e8fa9bb View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    9265763 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    ce0e097 View commit details
    Browse the repository at this point in the history
  22. Change dbg:ctpe to go back to default

    i.e enable all send/receive trace.
    sverker committed May 4, 2016
    Configuration menu
    Copy the full SHA
    d38d8a4 View commit details
    Browse the repository at this point in the history
  23. Add diameter:peer_info/1

    To return information about a single peer_ref(), to avoid having to
    retrieve more than is needed with service_info/2.
    Anders Svensson committed May 4, 2016
    Configuration menu
    Copy the full SHA
    2adc2c2 View commit details
    Browse the repository at this point in the history
  24. Add diameter:peer_find/1

    To return a peer_fsm/transport pair given one of them.
    Anders Svensson committed May 4, 2016
    Configuration menu
    Copy the full SHA
    18449b6 View commit details
    Browse the repository at this point in the history

Commits on May 6, 2016

  1. Editorial update

    xsipewe committed May 6, 2016
    Configuration menu
    Copy the full SHA
    09d138e View commit details
    Browse the repository at this point in the history

Commits on May 9, 2016

  1. Merge branch 'xsipewe_gen_statem1' of https://github.com/xsipewe/otp

    …into raimo/polish-gen_statem/OTP-13065
    
    Conflicts:
    	lib/stdlib/doc/src/gen_statem.xml
    RaimoNiskanen committed May 9, 2016
    Configuration menu
    Copy the full SHA
    7ef564a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1740546 View commit details
    Browse the repository at this point in the history
  3. Merge branch 'raimo/polish-gen_statem/OTP-13065'

    * raimo/polish-gen_statem/OTP-13065:
      Fix all seealso and other minor changes
      Editorial update
    RaimoNiskanen committed May 9, 2016
    Configuration menu
    Copy the full SHA
    9f8c514 View commit details
    Browse the repository at this point in the history
  4. mnesia_ext: Add supervisor and behaviour modules

    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    22a1b43 View commit details
    Browse the repository at this point in the history
  5. mnesia_ext: Add ext copies to records

    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    8015bd8 View commit details
    Browse the repository at this point in the history
  6. mnesia_ext: Add create_external and increase protocol version to monitor

    new protocol version to handle new schema fields
    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    7eec056 View commit details
    Browse the repository at this point in the history
  7. mnesia_ext: Refactor record_validation code

    Should maybe be moved to mnesia.erl and inlined??
    Or is it used elsewhere?
    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    184175a View commit details
    Browse the repository at this point in the history
  8. mnesia_ext: Add ext copies and db_fold to low level api

    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    66e9920 View commit details
    Browse the repository at this point in the history
  9. mnesia_ext: Create schema functionality

    Add ext to table/system information
    Add add_backend_type
    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    549555f View commit details
    Browse the repository at this point in the history
  10. mnesia_ext: Backup handling

    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    c64fa62 View commit details
    Browse the repository at this point in the history
  11. mnesia_ext: Ext support in fragmented tables

    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    0469ff7 View commit details
    Browse the repository at this point in the history
  12. mnesia_ext: Refactor mnesia_schema.erl

    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    81e90e8 View commit details
    Browse the repository at this point in the history
  13. mnesia_ext: Dumper and schema changes

    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    08bfbfe View commit details
    Browse the repository at this point in the history
  14. mnesia_ext: Load table ext

    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    3d13b01 View commit details
    Browse the repository at this point in the history
  15. mnesia_ext: Implement ext copies index

    Make ram_copies index always use ordered_set
    
    And use index type as prefered type not a implementation requirement,
    the standard implmentation will currently ignore the prefered type.
    Ulf Wiger authored and dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    3aff647 View commit details
    Browse the repository at this point in the history
  16. mnesia_ext: Create table/data containers from mnesia monitor not temp…

    …orary processes
    
    Tables or data containers should be owned and monitored by mnesia_monitor and
    should thus be created by that process.
    
    Always create_table before loading it
    
    We need to create tables for ram_copies at least before loading
    them as they are intermittent. It is also needed to get mnesia
    monitor as the parent and supervisor of the data storage.
    dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    545d88a View commit details
    Browse the repository at this point in the history
  17. mnesia_ext: reuse snmp field for ext updates

    Minimal impact when talking to older nodes.
    dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    6fad79d View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    e24275f View commit details
    Browse the repository at this point in the history
  19. Merge branch 'dgud/mnesia/ext-backend/PR-858/OTP-13058'

    * dgud/mnesia/ext-backend/PR-858/OTP-13058:
      mnesia_ext: Add basic backend extension tests
      mnesia_ext: reuse snmp field for ext updates
      mnesia_ext: Create table/data containers from mnesia monitor not temporary processes
      mnesia_ext: Implement ext copies index
      mnesia_ext: Load table ext
      mnesia_ext: Dumper and schema changes
      mnesia_ext: Refactor mnesia_schema.erl
      mnesia_ext: Ext support in fragmented tables
      mnesia_ext: Backup handling
      mnesia_ext: Create schema functionality
      mnesia_ext: Add ext copies and db_fold to low level api
      mnesia_ext: Refactor record_validation code
      mnesia_ext: Add create_external and increase protocol version to monitor
      mnesia_ext: Add ext copies to records
      mnesia_ext: Add supervisor and behaviour modules
    dgud committed May 9, 2016
    Configuration menu
    Copy the full SHA
    387e94f View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    7285415 View commit details
    Browse the repository at this point in the history
  21. Merge branch 'anders/diameter/test/OTP-13438'

    * anders/diameter/test/OTP-13438:
      Don't assume list comprehension evaluation order
    Anders Svensson committed May 9, 2016
    Configuration menu
    Copy the full SHA
    4d6d523 View commit details
    Browse the repository at this point in the history
  22. Merge branch 'anders/diameter/overload/OTP-13330'

    * anders/diameter/overload/OTP-13330:
      Suppress dialyzer warning
      Remove dead case clause
      Let throttling callback send a throttle message
      Acknowledge answers to notification pids when throttling
      Throttle properly with TLS
      Don't ask throttling callback to receive more unless needed
      Let a throttling callback answer a received message
      Let a throttling callback discard a received message
      Let throttling callback return a notification pid
      Make throttling callbacks on message reception
      Add diameter_tcp option throttle_cb
    Anders Svensson committed May 9, 2016
    Configuration menu
    Copy the full SHA
    a3f49cf View commit details
    Browse the repository at this point in the history
  23. Merge branch 'anders/diameter/info/OTP-13508'

    * anders/diameter/info/OTP-13508:
      Add diameter:peer_find/1
      Add diameter:peer_info/1
    Anders Svensson committed May 9, 2016
    Configuration menu
    Copy the full SHA
    f46d8a7 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    d7e7284 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    5ca152a View commit details
    Browse the repository at this point in the history

Commits on May 10, 2016

  1. erts: Implement max_heap_size process flag

    The max_heap_size process flag can be used to limit the
    growth of a process heap by killing it before it becomes
    too large to handle. It is possible to set the maximum
    using the `erl +hmax` option, `system_flag(max_heap_size, ...)`,
    `spawn_opt(Fun, [{max_heap_size, ...}])` and
    `process_flag(max_heap_size, ...)`.
    
    It is possible to configure the behaviour of the process
    when the maximum heap size is reached. The process may be
    sent an untrappable exit signal with reason kill and/or
    send an error_logger message with details on the process
    state. A new trace event called gc_max_heap_size is
    also triggered for the garbage_collection trace flag
    when the heap grows larger than the configured size.
    
    If kill and error_logger are disabled, it is still
    possible to see that the maximum has been reached by
    doing garbage collection tracing on the process.
    
    The heap size is defined as the sum of the heap memory
    that the process is currently using. This includes
    all generational heaps, the stack, any messages that
    are considered to be part of the heap and any extra
    memory the garbage collector may need during collection.
    
    In the current implementation this means that when a process
    is set using on_heap message queue data mode, the messages
    that are in the internal message queue are counted towards
    this value. For off_heap, only matched messages count towards
    the size of the heap. For mixed, it depends on race conditions
    within the VM whether a message is part of the heap or not.
    
    Below is an example run of the new behaviour:
    
    Eshell V8.0  (abort with ^G)
    1> f(P),P = spawn_opt(fun() -> receive ok -> ok end end, [{max_heap_size, 512}]).
    <0.60.0>
    2> erlang:trace(P, true, [garbage_collection, procs]).
    1
    3> [P ! lists:duplicate(M,M) || M <- lists:seq(1,15)],ok.
    ok
    4>
    =ERROR REPORT==== 26-Apr-2016::16:25:10 ===
         Process:          <0.60.0>
         Context:          maximum heap size reached
         Max heap size:    512
         Total heap size:  723
         Kill:             true
         Error Logger:     true
         GC Info:          [{old_heap_block_size,0},
                            {heap_block_size,609},
                            {mbuf_size,145},
                            {recent_size,0},
                            {stack_size,9},
                            {old_heap_size,0},
                            {heap_size,211},
                            {bin_vheap_size,0},
                            {bin_vheap_block_size,46422},
                            {bin_old_vheap_size,0},
                            {bin_old_vheap_block_size,46422}]
    flush().
    Shell got {trace,<0.60.0>,gc_start,
                     [{old_heap_block_size,0},
                      {heap_block_size,233},
                      {mbuf_size,145},
                      {recent_size,0},
                      {stack_size,9},
                      {old_heap_size,0},
                      {heap_size,211},
                      {bin_vheap_size,0},
                      {bin_vheap_block_size,46422},
                      {bin_old_vheap_size,0},
                      {bin_old_vheap_block_size,46422}]}
    Shell got {trace,<0.60.0>,gc_max_heap_size,
                     [{old_heap_block_size,0},
                      {heap_block_size,609},
                      {mbuf_size,145},
                      {recent_size,0},
                      {stack_size,9},
                      {old_heap_size,0},
                      {heap_size,211},
                      {bin_vheap_size,0},
                      {bin_vheap_block_size,46422},
                      {bin_old_vheap_size,0},
                      {bin_old_vheap_block_size,46422}]}
    Shell got {trace,<0.60.0>,exit,killed}
    garazdawi committed May 10, 2016
    Configuration menu
    Copy the full SHA
    e146a3e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    dc203f5 View commit details
    Browse the repository at this point in the history
  3. Update preloaded modules

    garazdawi committed May 10, 2016
    Configuration menu
    Copy the full SHA
    dc30187 View commit details
    Browse the repository at this point in the history