aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
AgeCommit message (Collapse)Author
2019-01-24Merge branch 'lukas/erts/scheduler-pollset-fixes/OTP-15538' into maint-21Erlang/OTP
* lukas/erts/scheduler-pollset-fixes/OTP-15538: erts: Fix getting of poll events on linux >= 4.15.0 erts: Use reduction based polling for starved poll-set erts: Fix pollset test cases
2019-01-18erts: Use reduction based polling for starved poll-setLukas Larsson
When the schedulers never go to sleep (and thus never polls) it may be that the fds in schedulers poll-sets are never polled. Before this commit, this was solved by starting a timer when an overload was detected. This had issues as overloads were not always detected in time. So this commit reverts to the pre OTP-21 behaviour so keep a global counter makes that the poll is called when it should.
2019-01-15Merge branch 'rickard/dirty_scheduler_collapse/maint-21/OTP-15509' into maint-21Erlang/OTP
* rickard/dirty_scheduler_collapse/maint-21/OTP-15509: Fix bug causing dirty scheduler sleeper list inconsistency
2019-01-11Merge branch 'rickard/dirty_scheduler_collapse/OTP-15509' into ↵Rickard Green
rickard/dirty_scheduler_collapse/maint-21/OTP-15509 * rickard/dirty_scheduler_collapse/OTP-15509: Fix bug causing dirty scheduler sleeper list inconsistency
2019-01-11Fix bug causing dirty scheduler sleeper list inconsistencyRickard Green
2019-01-07Spawn prim_file helper as a system processJohn Högberg
2018-12-20Merge branch 'sverker/big-band-bug/ERL-804/OTP-15487' into maint-21Erlang/OTP
* sverker/big-band-bug/ERL-804/OTP-15487: erts: Fix bug in 'band' of two negative numbers, one big
2018-12-17erts: Fix bug in 'band' of two negative numbers, one bigSverker Eriksson
Similar bug as for bxor fixed by abc4fd372d476821448dfb9 Ex: 1> io:format("~.16B\n", [-16#1110000000000000000 band (-1)]). -1120000000000000000 Wrong result for (-X bsl WS) band -Y. where X is any positive integer WS is erlang:system_info(wordsize)*8*N where N is 1 or larger Y is any positive integer smaller than (1 bsl WS) Fix: The subtraction of 1 (for 2-complement conversion) must be carried along all the way to the last words.
2018-12-13erts: Fix possible heap corruption getting atomicsTomas Abrahamsson
Due to comparison as a signed integer, when getting an unsigned atomic in the range 2^63-1..2^64-1 (when the most significant bit was set), the heap could get corrupted when the integer was retrieved: hsz would get set to zero, but the code proceeded to build a bignum. Steps to reproduce (at least on x86_64): $ erl 1> A = atomics:new(1,[{signed,false}]). 2> atomics:put(A,1,18446744073709551615). 3> atomics:get(A,1). At the last step, the shell would print some garbage and hang.
2018-12-06Merge branch 'lukas/OTP-21.1.1/scheduler_pollset/OTP-15475' into maintLukas Larsson
* lukas/OTP-21.1.1/scheduler_pollset/OTP-15475: erts: Move fds with active true behaviour to own pollset erts: Fix lists_member_2 reduction count erts: Allow code_model_small to be set in xcomp setting erts: Implement delay_send using timer instead of poll erts: Optimize driver_set_timer(0) to fire at once erts: Optimize the inet driver multi timers for one timer erts: Move all inet tcp CONNECTED timers to multi timer erts: Add erts_io_notify_port_task_executed to check_io msacc state erts: Add pre-alloc to ALLOC msacc state erts: Make thr prgr wakeup current or sched 1 erts: Pass thread progress data where possible
2018-12-06erts: Move fds with active true behaviour to own pollsetLukas Larsson
At start of the VM a poll-set that the schedulers will check is created where fds that have triggered many (at the moment, many means 10) times without being deselected inbetween. In this scheduler specific poll-set fds do not use ONESHOT, which means that the number of syscalls goes down dramatically for such fds. This pollset is introduced in order to handle fds that are used by the erlang distribution and that never change their state from {active, true}. This pollset only handles ready_input events, ready_output is still handled by the poll threads. During overload, polling the scheduler poll-set is done on a 10ms timer.
2018-12-04erts: Fix copy of literal msg during gcLukas Larsson
A copy has to be made of the message as there is a trace token. There was a bug where the actual message was incorrectly modified even if it was a literal.
2018-12-03erts: Fix some 32-bit gcc warningsLukas Larsson
2018-12-03erts: Fix lists_member_2 reduction countLukas Larsson
OTP-15474
2018-12-03erts: Optimize driver_set_timer(0) to fire at onceLukas Larsson
By optimizing driver_set_timer for 0 we can use it instead of select to do a yield in the driver. Use full for delay_send in the inet driver. OTP-15472
2018-12-03erts: Add pre-alloc to ALLOC msacc stateLukas Larsson
OTP-15450
2018-11-27Merge branch 'lukas/erts/fix-msacc-gc-states/OTP-15450' into maintLukas Larsson
* lukas/erts/fix-msacc-gc-states/OTP-15450: erts: Fix msacc GC states on dirty scheds
2018-11-27Merge pull request #2024 from max-au/fix_aux_work_on_dcpu_schedJohn Högberg
erts: fix attempt to start timer when executing on dirty scheduler OTP-15446
2018-11-26erts: fix attempt to start timer when executing on dirty schedulerMaxim Fedorov
Since OTP R20, there is a possibility for MAJOR garbage collection to run on dirty scheduler. So DistEntry destructor is being called on dirty scheduler as well. This, in turn, leads to an attempt to schedule timer on a dirty scheduler too, which is impossible (and will assert on debug build, but does succeed for release build, creating an infinite busy loop, since aux work wakes scheduler up, but dirty scheduler cannot execute aus work). There is a similar method in erl_hl_timer, see erts_start_timer_callback.
2018-11-26Merge branch 'sverker/erts/atomics-counters/OTP-13468' into maintSverker Eriksson
* sverker/erts/atomics-counters/OTP-13468: erts: Fix bug in counters erts: Refactor erl_bif_counters.c
2018-11-23erts: Fix bug in countersSverker Eriksson
Wow, that could have been embarrassing.
2018-11-23erts: Refactor erl_bif_counters.cSverker Eriksson
with more consistent naming.
2018-11-23Merge branch 'john/erts/spectre-configure-flag-otp_20/OTP-15430/ERIERL-237' ↵John Högberg
into maint * john/erts/spectre-configure-flag-otp_20/OTP-15430/ERIERL-237: Allow disabling retpoline in interpreter loop Add a ./configure flag for spectre mitigation
2018-11-22Merge branch 'sverker/erts/atomics-counters/OTP-13468' into maintSverker Eriksson
AGAIN * sverker/erts/atomics-counters/OTP-13468: erts: Add counters:put/3
2018-11-21erts: Add counters:put/3Sverker Eriksson
2018-11-20Merge branch 'john/erts/spectre-configure-flag/OTP-15430/ERIERL-237' into ↵John Högberg
john/erts/spectre-configure-flag-otp_20/OTP-15430/ERIERL-237 * john/erts/spectre-configure-flag/OTP-15430/ERIERL-237: Allow disabling retpoline in interpreter loop Add a ./configure flag for spectre mitigation
2018-11-20Allow disabling retpoline in interpreter loopJohn Högberg
We only do this when the user has explicitly told us it's okay to partially disable mitigation (spectre-mitigation=incomplete). The macro is inert if it isn't.
2018-11-16Merge branch 'john/erts/defer-orphan-file-close/OTP-15421/ERIERL-261' into maintJohn Högberg
* john/erts/defer-orphan-file-close/OTP-15421/ERIERL-261: Fix broken assertion on monitor release Avoid closing files in gc/monitor callbacks
2018-11-15Merge branch 'sverker/erts/atomics-counters/OTP-13468' into maintSverker Eriksson
* sverker/erts/atomics-counters/OTP-13468: erts: Add new module 'counters' erts: Add new module 'atomics'
2018-11-15erts: Add new module 'counters'Sverker Eriksson
2018-11-15erts: Add new module 'atomics'Sverker Eriksson
2018-11-13Fix broken assertion on monitor releaseJohn Högberg
We sometimes bump the refc without messing with the table, which means that we sometimes decrement it while in the table, causing the old assertion to fail. The property we want to check is that neither end of the monitor is present in the table when the monitor is deleted.
2018-11-09Remove --/2 from dirty BIF testsJohn Högberg
Now that it traps, --/2 would hang forever when building under --enable-dirty-schedulers-test.
2018-11-06Merge branch 'bjorn/erts/persistent_terms/OTP-14669' into maintBjörn Gustavsson
* bjorn/erts/persistent_terms/OTP-14669: Implement a tab for persistent terms in crashdump viewer Add tests of persistent terms for crashdump_viewer Add a persistent term storage Refactor releasing of literals Extend the sharing-preserving routines to optionally copy literals
2018-11-06Add a persistent term storageBjörn Gustavsson
Persistent terms are useful for storing Erlang terms that are never or infrequently updated. They have the following advantages: * Constant time access. A persistent term is not copied when it is looked up. The constant factor is lower than for ETS, and no locks are taken when looking up a term. * Persistent terms are not copied in garbage collections. * There is only ever one copy of a persistent term (until it is deleted). That makes them useful for storing configuration data that needs to be easily accessible by all processes. Persistent terms have the following drawbacks: * Updates are expensive. The hash table holding the keys for the persistent terms are updated whenever a persistent term is added, updated or deleted. * Updating or deleting a persistent term triggers a "global GC", which will schedule a heap scan of all processes to search the heap of all processes for the deleted term. If a process still holds a reference to the deleted term, the process will be garbage collected and the term copied to the heap of the process. This global GC can make the system less responsive for some time. Three BIFs (implemented in C in the emulator) is the entire interface to the persistent term functionality: * put(Key, Value) to store a persistent term. * get(Key) to look up a persistent term. * erase(Key) to delete a persistent term. There are also two additional BIFs to obtain information about persistent terms: * info() to return a map with information about persistent terms. * get() to return a list of a {Key,Value} tuples for all persistent terms. (The values are not copied.)
2018-11-02erts: Fix msacc GC states on dirty schedsLukas Larsson
A dirty scheduler is an un-managed thread so we need to lock the msacc state on those.
2018-11-02Merge branch 'john/erts/minusminus_trapping/OTP-15371' into maintJohn Högberg
* john/erts/minusminus_trapping/OTP-15371: Optimize operator '--' and yield on large inputs Inline erts_cmp Clarify a magical allocation size Fix trapping in lists:reverse/2
2018-11-01Merge branch 'rickard/internal_ref_cmp/OTP-15399/ERL-751' into maintRickard Green
* rickard/internal_ref_cmp/OTP-15399/ERL-751: Fix erts_internal_ref_number_cmp()
2018-10-31Fix erts_internal_ref_number_cmp()Rickard Green
2018-10-29Refactor releasing of literalsBjörn Gustavsson
Introudce erts_queue_release_literals() to queue a literal area to be released.
2018-10-29Optimize operator '--' and yield on large inputsJohn Högberg
The removal set now uses a red-black tree instead of an array on large inputs, decreasing runtime complexity from `n*n` to `n*log(n)`. It will also exit early when there are no more items left in the removal set, drastically improving performance and memory use when the items to be removed are present near the head of the list. This got a lot more complicated than before as the overhead of always using a red-black tree was unacceptable when either of the inputs were small, but this compromise has okay-to-decent performance regardless of input size. Co-authored-by: Dmytro Lytovchenko <[email protected]>
2018-10-26Inline erts_cmpJohn Högberg
This greatly increases the performance of '--'/2 which does a lot of term comparisons.
2018-10-25Clarify a magical allocation sizeDmytro Lytovchenko
2018-10-25Fix trapping in lists:reverse/2John Högberg
The first stage wasn't bounded by reductions, and it bumped far more reductions than it should have due to a logic bug.
2018-10-24Extend the sharing-preserving routines to optionally copy literalsBjörn Gustavsson
In the implementation of the zero-copying term storage, we want to preserve sharing, but not copy literals because the modules holding the literals could be unloaded under our feet.
2018-10-23erts: Make thr prgr wakeup current or sched 1Lukas Larsson
Before this change, it was always the aux thread that was woken to handle thread progress events scheduled to happen when all schedulers were going to sleep. This was ok in the pre-OTP-21 implementation when the aux thread just slept on a tse. Now that it sleeps in the fallback pollset this uses too much cpu so instead we wake the thread that is doing the request if it is a managed thread, or else we wake scheduler 1.
2018-10-23erts: Pass thread progress data where possibleLukas Larsson
The poll thread does a lot of waking up and then going back to sleep. A large part of the waking up is managing thread progress and a large part of that was using thread specific data to get the thread progress data pointer. With this refactor the tpd is passed to each of the functions which greatly decreases the number of ethr_get_tsd calls which in turn halves the CPU usage of the poller thread in certain scenarios.
2018-10-19Honor the max heap size when copying literals after purgingBjörn Gustavsson
When a module has been purged from memory, any literals belonging to that module will be copied to all processes that hold references to them. The max heap size limit would be ignored in the garbage collection initiated when copying literals to a process. If the max heap size was exceeded, the process would typically be terminated in the following garbage collection. Since the process would be killed anyway later, kill the process before copying a literal that would make it exceed its max heap size. While at it, also fix a potential bug in `erlang:garbage_collect/0`. If it was found that the max heap sized had been exceeded while executing `erlang:garbage_collect/0`, the process would enter a kind of zombie state instead of being properly terminated.
2018-10-15erts: Fix bug in debug_free for NULL pointerSverker Eriksson
causing ASSERT in sys_memset to fail.
2018-10-09Merge branch 'sverker/erts/ets-select_replace-bug/OTP-15346' into maintSverker Eriksson
* sverker/erts/ets-select_replace-bug/OTP-15346: erts: Fix bug in ets:select_replace for bound key