From 207a569d4caf80b10a54eec2220ac672a3377f00 Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Fri, 22 Jan 2016 17:48:49 +0100 Subject: Improved scheduler suspend functionality - The calling process is now suspended while synchronizing scheduler suspends via erlang:system_flag(schedulers_online, _) and erlang:system_flag(multi_scheduling, _), instead of blocking the scheduler thread in the BIF call waiting for the operation to synchronize. Besides releasing the scheduler for other work (or immediate suspend) it also makes it possible to abort the operation by killing the process. - erlang:system_flag(schedulers_online, _) now only wait for normal schedulers to complete before it returns. This since it may take a very long time before all dirty schedulers suspends. - erlang:system_flag(multi_scheduling, block_normal|unblock_normal) which only operate on normal schedulers has been introduced. This since there are use cases where suspend of dirty schedulers are not of interest (hipe loader). - erlang:system_flag(multi_scheduling, block) still blocks all dirty schedulers as well as all normal schedulers except one since it is hard to redefine what multi scheduling block means. - The three operations: - changing amount of schedulers online - blocking/unblocking normal multi scheduling - blocking/unblocking full multi scheduling can now be done in parallel. This is important since otherwise a full multi scheduling block would potentially delay the other operations for a very long time. --- erts/doc/src/erlang.xml | 99 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 28 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index 1f8e89768c..350a8506f5 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -6469,32 +6469,44 @@ ok

If multi-scheduling is enabled, more than one scheduler thread is used by the emulator. Multi-scheduling can be - blocked. When multi-scheduling is blocked, only - one scheduler thread schedules Erlang processes.

+ blocked in two different ways. Either all schedulers but + one is blocked, or all normal schedulers but + one is blocked. When only normal schedulers are blocked + dirty schedulers are free to continue to schedule + processes.

If BlockState =:= block, multi-scheduling is - blocked. If BlockState =:= unblock and no one + blocked. That is, one and only one scheduler thread will + execute. If BlockState =:= unblock and no one else blocks multi-scheduling, and this process has blocked only once, multi-scheduling is unblocked.

-

One process can block multi-scheduling multiple times. - If a process has blocked multiple times, it must - unblock exactly as many times as it has blocked before it - has released its multi-scheduling block. If a process that - has blocked multi-scheduling exits, it releases its - blocking of multi-scheduling.

+

If BlockState =:= block_normal, normal + multi-scheduling is blocked. That is, only one normal scheduler + thread will execute, but multiple dirty schedulers may execute. + If BlockState =:= unblock_normal and no one + else blocks normal multi-scheduling, and this process has + blocked only once, normal multi-scheduling is unblocked.

+

One process can block multi-scheduling as well as normal + multi-scheduling multiple times. If a process has blocked + multiple times, it must unblock exactly as many times as it + has blocked before it has released its multi-scheduling + block. If a process that has blocked multi-scheduling or normal + multi scheduling exits, it automatically releases its blocking + of multi-scheduling and normal multi-scheduling.

The return values are disabled, blocked, - or enabled. The returned value describes the - state just after the call to + blocked_normal, or enabled. The returned value + describes the state just after the call to erlang:system_flag(multi_scheduling, BlockState) has been made. For information about the return values, see erlang:system_info(multi_scheduling).

-

Blocking of multi-scheduling is normally not needed. - If you feel that you need to block multi-scheduling, - consider it a few more times again. Blocking multi-scheduling - is only to be used as a last resort, as it is most likely - a very inefficient way to solve the problem.

+

Blocking of multi-scheduling and normal multi-scheduling + is normally not needed. If you feel that you need to use these + features, consider it a few more times again. Blocking + multi-scheduling is only to be used as a last resort, as it is + most likely a very inefficient way to solve the problem.

See also erlang:system_info(multi_scheduling), + erlang:system_info(normal_multi_scheduling_blockers), erlang:system_info(multi_scheduling_blockers), and erlang:system_info(schedulers).

@@ -7329,6 +7341,16 @@ ok where MinHeapSize is the current system-wide minimum heap size for spawned processes.

+ message_queue_data + +

Returns the default value of the message_queue_data + process flag which is either off_heap, on_heap, or mixed. + This default is set by the erl command line argument + +xmqd. For more information on the + message_queue_data process flag, see documentation of + process_flag(message_queue_data, + MQD).

+
min_bin_vheap_size

Returns {min_bin_vheap_size, @@ -7348,7 +7370,8 @@ ok multi_scheduling -

Returns disabled, blocked, or enabled:

+

Returns disabled, blocked, blocked_normal, + or enabled:

disabled @@ -7359,14 +7382,22 @@ ok blocked

The emulator has more than one scheduler thread, - but all scheduler threads except one are blocked, - that is, only one scheduler thread schedules + but all scheduler threads except one are blocked. + That is, only one scheduler thread schedules Erlang processes and executes Erlang code.

+ blocked_normal + +

The emulator has more than one scheduler thread, + but all normal scheduler threads except one are + blocked. Note that dirty schedulers are not + blocked, and may schedule Erlang processes and + execute native code.

+
enabled

The emulator has more than one scheduler thread, - and no scheduler threads are blocked, that is, + and no scheduler threads are blocked. That is, all available scheduler threads schedule Erlang processes and execute Erlang code.

@@ -7374,6 +7405,7 @@ ok

See also erlang:system_flag(multi_scheduling, BlockState), erlang:system_info(multi_scheduling_blockers), + erlang:system_info(normal_multi_scheduling_blockers), and erlang:system_info(schedulers).

@@ -7390,6 +7422,8 @@ ok

See also erlang:system_flag(multi_scheduling, BlockState), erlang:system_info(multi_scheduling), + erlang:system_info(normal_multi_scheduling_blockers), + and erlang:system_info(schedulers).

@@ -7399,15 +7433,23 @@ ok used by the runtime system. It is on the form "<major ver>.<minor ver>".

- message_queue_data + normal_multi_scheduling_blockers -

Returns the default value of the message_queue_data - process flag which is either off_heap, on_heap, or mixed. - This default is set by the erl command line argument - +xmqd. For more information on the - message_queue_data process flag, see documentation of - process_flag(message_queue_data, - MQD).

+ +

Returns a list of Pids when + normal multi-scheduling is blocked (i.e. all normal schedulers + but one is blocked), otherwise the empty list is returned. + The Pids in the list represent all the + processes currently blocking normal multi-scheduling. + A Pid occurs only once in the list, even if + the corresponding process has blocked multiple times.

+

See also + erlang:system_flag(multi_scheduling, BlockState), + erlang:system_info(multi_scheduling), + erlang:system_info(multi_scheduling_blockers), + + and + erlang:system_info(schedulers).

otp_release @@ -7650,6 +7692,7 @@ ok erlang:system_info(scheduler_id), erlang:system_flag(multi_scheduling, BlockState), erlang:system_info(multi_scheduling), + erlang:system_info(normal_multi_scheduling_blockers) and erlang:system_info(multi_scheduling_blockers).

-- cgit v1.2.3