aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
AgeCommit message (Collapse)Author
2018-08-16Do not allocate good and bad shifts for single byte lookupsJosé Valim
The single byte lookups always rely on `memchr` and never really use the good and bad shifts arrays.
2018-08-16Merge branch 'josevalim/jv-sb/PR-1803/OTP-15238' into masterLukas Larsson
Optimize binary match from 10% up to 70x
2018-08-10Merge branch 'rickard/full-cache-nif-env/OTP-15223/ERL-695' into maint-21Erlang/OTP
* rickard/full-cache-nif-env/OTP-15223/ERL-695: Fix caching of NIF environment when executing dirty # Conflicts: # erts/emulator/beam/erl_nif.c
2018-08-10Merge branch 'dotsimon/ref_ordering_bug/OTP-15225' into maint-21Erlang/OTP
* dotsimon/ref_ordering_bug/OTP-15225: Fixed #Ref ordering bug Test #Ref ordering in lists and ets
2018-08-09Merge branch 'maint'Rickard Green
* maint: Fix caching of NIF environment when executing dirty
2018-08-09Merge branch 'rickard/full-cache-nif-env/OTP-15223/ERL-695' into maintRickard Green
* rickard/full-cache-nif-env/OTP-15223/ERL-695: Fix caching of NIF environment when executing dirty
2018-08-09Fix caching of NIF environment when executing dirtyRickard Green
2018-08-09Fixed #Ref ordering bugSimon Cornish
2018-08-09Merge branch 'maint'Rickard Green
* maint: Fixed #Ref ordering bug Test #Ref ordering in lists and ets
2018-08-07Fixed #Ref ordering bugSimon Cornish
2018-08-07Optimize binary matchJosé Valim
The idea is to use memchr on the first lookup for binary:match/2 and also after every match on binary:matches/2. We only use memchr in case of matches because benchmarks showed that using memchr even when we had false positives could negatively affect performance. This speeds up binary matching and binary splitting by 4x in some cases and by 70x in other scenarios (when the last character in the needle does not occur in the subject). The reason to use memchr is that it is highly specialized in most modern operating systems, often defaulting to SIMD operations. The implementation uses the reduction count to figure out how many bytes should be read with memchr. We could increase those numbers but they do not seem to make a large difference.
2018-08-03josevalim/jv-preserve-map-same-value/PR-1889/OTP-15211Lukas Larsson
Do not allocate a new map when the value is the same
2018-08-03Merge branch 'maint'Lukas Larsson
2018-08-03erts: Fix seq_trace to not clear token for system messagesLukas Larsson
A lot of erts internal messages used behind APIs to create non-blocking calls, e.g. port_command, would cause the seq_trace token to be cleared from the caller when it should not. This commit fixes that and adds asserts that makes sure that all messages sent have to correct token set. Fixes: ERL-602
2018-07-31Merge branch 'maint'Lukas Larsson
2018-07-30Merge pull request #1891 from ↵Raimo Niskanen
RaimoNiskanen/raimo/can_not-should-mostly-be-cannot OTP-14282 'can not' should mostly be 'cannot'
2018-07-30erl_alloc: align ErtsAllocatorState_tMikael Pettersson
2018-07-27Change "can not" into "cannot"Raimo Niskanen
I did not find any legitimate use of "can not", however skipped changing e.g RFCs archived in the source tree.
2018-07-27Remove newline between can and notRaimo Niskanen
After this whitespace modification there should be no "can not"s separated by a newline in the entire OTP repository, so to find them all a simple git grep will do just fine.
2018-07-26Merge branch 'maint'John Högberg
2018-07-26Merge branch 'maint-21' into maintJohn Högberg
2018-07-25Do not allocate a new map when the value is the sameJose Valim & Michal Muskala
This patch optimizes map operations to not allocate new maps when the key is being replaced by the exact same value in memory. Imagine this very common idiom: Map#{key := compute_new_value(Value, Condition)} where: compute_new_x(X, true) -> X + 1; compute_new_x(X, false) -> X; In many cases, we are not changing the value in `Key`, however the code prior to this patch would still allocate a new array for the map values. This optimization changes this. The cost of optimization is minimum, as in the worst case scenario it only adds a pointer comparison and boolean check. The major benefit is reducing the GC pressure by avoiding allocating data. Next we list the operations we have changed alongside the benchmark results. The benchmarks basically create a map and perform the same operations, roughly 20000 times, once replacing the key with the same value, and another with a different value. * Map#{Key := Value} For a map with 4 keys, replacing the fourth key 20000 times went from 718us to 539us. For a map with 8 keys, replacing the fourth key 20000 times went from 976us to 555us. * maps:update/3 For a map with 4 keys, replacing the fourth key 20000 times went from 673us to 575us. For a map with 8 keys, replacing the fourth key 20000 times went from 827us to 585us. * maps:put/3 For a map with 4 keys, replacing the fourth key 20000 times went from 763us to 553us. For a map with 8 keys, replacing the fourth key 20000 times went from 788us to 561us. Note that we have ported some optimizations found in maps:update/3 to maps:put/3 while creating this patch.
2018-07-20erts: Add ERL_NIF_SELECT_CANCEL flag for enif_selectSverker Eriksson
to deselect read and/or writes without stop callback.
2018-07-20Merge PR-1878 from michalmuskala/mm/map-new-bif-2 OTP-15200Sverker Eriksson
maps:new/0 is no longer a BIF
2018-07-18Merge branch 'maint'Sverker Eriksson
2018-07-18Merge branch 'sverker/erl_interface/valgrind/OTP-15171' into maintSverker Eriksson
* sverker/erl_interface/valgrind/OTP-15171: erl_interface: Fix bug in ei_*receive_msg* functions erl_interface: Seal test case memory leaks erl_interface: Initialize erl_errno to zero erts: Remove use of VALGRIND_PRINTF_XML erl_interface: Add valgrind ability for test port programs erts: Fix benign bug in cerl for valgrind erts: Fix buggy calls to erts_sys_explicit_8bit_getenv
2018-07-18erts: Remove use of VALGRIND_PRINTF_XMLSverker Eriksson
which only existed in a patched version of valgrind (by pan) no longer used. Instead we use standard VALGRIND_PRINTF which will end up like this if valgrind log format is XML and valgrind version >= 3.9: <clientmsg> <tid>7</tid> <threadname>3_scheduler</threadname> <text>Test case #20 ei_encode_SUITE:test_ei_encode_long/1 </text> </clientmsg> Note the extra trailing whitespace that may occure before </text>.
2018-07-18Merge branch 'john/erts/fix-literal-map-elements/OTP-15184' into maint-21Erlang/OTP
* john/erts/fix-literal-map-elements/OTP-15184: Fix a rare crash when matching on literal maps
2018-07-18Merge pull request #1812 from michalmuskala/mm/make-fun-loaderJohn Högberg
Optimise creation of anonymous functions
2018-07-17maps:new/0 is no longer a BIFMichał Muskała
Implementing it in Erlang allows taking advantage of the literal pool optimisation, this means the function implemented in Erlang does no allocations, while the BIF had to allocate new map each time it was called. Benchmarks show the function is also slightly faster now.
2018-07-17Optimise creation of anonymous functionsMichał Muskała
This introduces a similar optimisation for normal funs to what was introduced for external funs in #1725. It is possible to allocate the fun as a literal, if it does not capture the environment (i.e. it does not close over any variables). Unfortunately it's not possible to do this in the compiler due to problems with representation of such functions in the `.beam` files. Fortunately, we can do this in the loader. Simple evaluation shows that functions that don't capture the enviornment consistute over 60% of all funs in the source code of Erlang/OTP itself. The only downside is that we lose a meningful value in the `pid` field of the fun. The goal of this field, beyond debugging, was to be able to identify the original node of a function. To be able to still do this, the functions that are created in the loader are assigned the init pid as the creator. To solve issues with staryp, initially set the `erts_init_process_id` to `ERTS_INVALID_PID` and skip the described optimisation if the value is still uninitialised.
2018-07-16Merge branch 'maint'Sverker Eriksson
2018-07-16Merge branch 'sverker/crash-dump-crash-literals/OTP-15181' into maintSverker Eriksson
* sverker/crash-dump-crash-literals/OTP-15181: erts: Fix bug in crash dump generation
2018-07-13Merge branch 'maint'Rickard Green
* maint: Updated OTP version Update release notes Update version numbers Fix trace_info/2 Provide build support for standalone corba repo Fix release notes for OTP-21.0.2 Move to a dirty scheduler even when we have pending system tasks
2018-07-13Merge branch 'maint-21' into maintRickard Green
* maint-21: Updated OTP version Update release notes Update version numbers Fix trace_info/2 Provide build support for standalone corba repo Fix release notes for OTP-21.0.2 Move to a dirty scheduler even when we have pending system tasks
2018-07-13Fix a rare crash when matching on literal mapsJohn Högberg
When matching on a literal map, the map is placed into the general scratch register first. This is fine in isolation, but when the key to be matched was in a Y register it would also be placed in the scratch register, overwriting the map and crashing the emulator.
2018-07-12Merge branch 'john/erts/fix-dirty-reschedule-bug/OTP-15154' into maint-21Erlang/OTP
* john/erts/fix-dirty-reschedule-bug/OTP-15154: Move to a dirty scheduler even when we have pending system tasks
2018-07-12Fix trace_info/2Rickard Green
2018-07-12Merge branch 'john/erts/adjust-fix-alloc-sizes'John Högberg
* john/erts/adjust-fix-alloc-sizes: Adjust fix_alloc sizes to guarantee they fit a dd block
2018-07-12erts: Fix bug in crash dump generationSverker Eriksson
Symptom: emulator core dumps during crash dump generation. Problem: erts_dump_lit_areas did not grow correctly to always be equal or larger than number of loaded modules. The comment about twice the size to include both curr and old did not seem right. The beam_ranges structure contains *all* loaded module instances until they are removed when purged.
2018-07-10Merge branch 'sverker/erts/cpool-simplify'Sverker Eriksson
* sverker/erts/cpool-simplify: erts: Simplify calc of allctr->cpool.abandon_limit erts: Simplify cpool_fetch
2018-07-10erts: Fix buggy calls to erts_sys_explicit_8bit_getenvSverker Eriksson
Two of them only affect valgrind builds and the one for ERL_CRASH_DUMP_NICE seems benign. Return value changed in c2d70945dce9cb09d5d7120d6e9ddf7faac8d230 old -> new -1 -> 0 not found 0 -> 1 found ok 1 -> -1 found but too big
2018-07-09Adjust fix_alloc sizes to guarantee they fit a dd blockJohn Högberg
This failed on 32-bit builds, and wasn't noticed because 32-bit debug builds didn't run during the test period.
2018-07-06Merge branch 'maint'Björn Gustavsson
* maint: Call test_lib:recompile/1 from init_per_suite/1 beam_debug: Fix printing of floating point registers
2018-07-05beam_debug: Fix printing of floating point registersBjörn Gustavsson
2018-07-05erts: Simplify calc of allctr->cpool.abandon_limitSverker Eriksson
Remove check_limit_count and just recalculate when needed, that is when carriers are added/removed.
2018-07-05erts: Simplify cpool_fetchSverker Eriksson
and avoid faulty bumps of 'entrance_removed' stat.
2018-07-03Merge pull request #1854 from ↵John Högberg
jhogberg/john/erts/cross-type-carrier-migration/OTP-15063 Allow carrier migration between different allocator types
2018-06-29Merge branch 'john/erts/merge-OTP-15067' into maint-21Erlang/OTP
* john/erts/merge-OTP-15067: Don't enqueue system tasks if target process is in fail_state Fix erroneous schedule of freed/exiting processes Fix deadlock in run queue evacuation Fix memory leak of processes that died in the run queue
2018-06-28Add 'chaos first fit' to test mixed-order carrier migrationJohn Högberg