aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_db_hash.c
AgeCommit message (Collapse)Author
2019-04-10Decentralized counters for ETS ordered_set with write_concurrencyKjell Winblad
Previously, all ETS tables used centralized counter variables to keep track of the number of items stored and the amount of memory consumed. These counters can cause scalability problems (especially on big NUMA systems). This commit adds an implementation of a decentralized counter and modifies the implementation of ETS so that ETS tables of type ordered_set with write_concurrency enabled use the decentralized counter. [Experiments][1] indicate that this change substantially improves the scalability of ETS ordered_set tables with write_concurrency enabled in scenarios with frequent `ets:insert/2` and `ets:delete/2` calls. The new counter is implemented in the module erts_flxctr (`erts_flxctr.h` and `erts_flxctr.c`). The module has the suffix flxctr as it contains the implementation of a flexible counter (i.e., counter instances can be configured to be either centralized or decentralized). Counters that are configured to be centralized are implemented with a single counter variable which is modified with atomic operations. Decentralized counters are spread over several cache lines (how many can be configured with the parameter `+dcg`). The scheduler threads are mapped to cache lines so that there is no single point of contention when decentralized counters are updated. The thread progress functionality of the Erlang VM is utilized to implement support for linearizable snapshots of decentralized counters. The snapshot functionality is used by the `ets:info/1` and `ets:info/2` functions. [1]: http://winsh.me/ets_catree_benchmark/flxctr_res.html
2019-03-15erts: Fix bug for yielding ets:replaceSverker Eriksson
Found by valgrind: Conditional jump or move depends on uninitialised value(s) Suspected: ets_select_replace_1:3034 [erl_db.c] Bug introduced by already merged parent commit 0d550c80d4f19cc432e7de056169695d436c02a0.
2019-03-11erts: Fix ets:select table fixation leak at owner changeSverker Eriksson
Symtom: ETS table remains fixed after finished ets:select* call. Problem: The decision to unfix table after a yielding ets:select* is based on table ownership, but ownership might have changed while ets:select* was yielding. Solution: Remember and pass along whether table was fixed when the traversal started.
2019-03-11erts: Refactor common things into traverse_context_tSverker Eriksson
and rename it from match_callbacks_t.
2019-03-07Merge branch 'sverker/maint/ets-no-mbuf-trapping/OTP-15660'Sverker Eriksson
into sverker/master/ets-no-mbuf-trapping/OTP-15660
2019-03-07Merge branch 'sverker/ets-no-mbuf-trapping/OTP-15660'Sverker Eriksson
into sverker/maint/ets-no-mbuf-trapping/OTP-15660
2019-03-07erts: Remove ets traversal yielding if heap fragmentSverker Eriksson
Many heap fragments do no longer make the GC slow. Even worse, we are not guaranteed that a yield will provoke a GC removing the fragments, which might lead to a one-yield-per-bucket scenario if the heap fragment(s) still remains after each yield.
2018-10-23erts: Refactor DbUpdateHandle with nicer typesSverker Eriksson
2018-10-03erts: Improve deallocation of CATree nodesSverker Eriksson
Update table memory stats before scheduling free to not be dependent on deallocation order with main table struct.
2018-09-03erts: Refactor ets FixedDeletion allocationsSverker Eriksson
2018-09-03erts: Fix ets memstat false leak of FixedDeletionSverker Eriksson
causing erlang:memory to report too much ets memory.
2018-06-18Update copyright yearHenrik Nord
2018-05-08erts: Rename untrapping db_free_*empty*_tableSverker Eriksson
as it's now only used for empty tables by ets:new/2.
2018-05-08erts: Make ets:delete_all_objects yield on fixed tableSverker Eriksson
2018-05-08erts: Optimize ets delete all in fixed tableSverker Eriksson
by only allocating one FixedDeletion with the new "all" flag instead of one FixedDeletion per slot.
2018-05-08erts: Refactor ets select iteration codeSverker Eriksson
* Remove all "mtraversal_" prefixes. * Rename all local context variables as "ctx". * Changed callbacks from function arguments to members of new base context struct "match_callbacks_t" * Remove unnecessary struct initializations "= {0}"
2018-05-08erts: Cleanup ets codeSverker Eriksson
2018-05-08erts: Optimize ets hash object deallocactionsSverker Eriksson
to be done after lock has been released.
2018-05-08erts: Refactor pseudo deleted ets objectsSverker Eriksson
Separate pseudo-deleted-flag from the hash value.
2018-05-08erts: Make atomic ets:delete_all_objects yieldSverker Eriksson
by using a cooperative strategy that will make any process accessing the table execute delelete_all_objects_continue until the table is empty. This is not an optimal solution as concurrent threads will still block on the table lock, but at least thread progress is made.
2018-04-20erts: Use table ref for select continuationSverker Eriksson
and not the name. For more sane named table semantics. Applies to both select/1 continuation and trap context.
2018-04-20erts: Refactor erl_db_hash next() into next_live()Sverker Eriksson
where argument 'list' is the first candidate (not list->next). Also simplified db_first_hash().
2018-04-20erts: Change wrong alloc_fnfSverker Eriksson
There is no NULL check here !?
2017-09-11Merge branch 'maint'John Högberg
2017-09-07Replace ad-hoc MIN/MAX macros with common onesJohn Högberg
Besides being noisy, they were already defined by a global Unix- specific header, causing the Windows build to fail if one forgot to define them.
2017-07-17erts: Replace usage of all erts_smp prefixes to just ertsLukas Larsson
2017-07-17erts: Remove ERTS_SMP and USE_THREAD definesLukas Larsson
This refactor was done using the unifdef tool like this: for file in $(find erts/ -name *.[ch]); do unifdef -t -f defile -o $file $file; done where defile contained: #define ERTS_SMP 1 #define USE_THREADS 1 #define DDLL_SMP 1 #define ERTS_HAVE_SMP_EMU 1 #define SMP 1 #define ERL_BITS_REENTRANT 1 #define ERTS_USE_ASYNC_READY_Q 1 #define FDBLOCK 1 #undef ERTS_POLL_NEED_ASYNC_INTERRUPT_SUPPORT #define ERTS_POLL_ASYNC_INTERRUPT_SUPPORT 0 #define ERTS_POLL_USE_WAKEUP_PIPE 1 #define ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE 1 #undef ERTS_HAVE_PLAIN_EMU #undef ERTS_SIGNAL_STATE
2017-07-06Allow toggling lock counting at runtimeJohn Högberg
The implementation is still hidden behind ERTS_ENABLE_LOCK_COUNT, and all categories are still enabled by default, but the actual counting can be toggled at will. OTP-13170
2017-05-04Update copyright yearRaimo Niskanen
2017-04-28Merge PR1413 from g-andrade/feature/phash2_nifSverker Eriksson
Support hashing terms from NIF code
2017-04-22erts: Support custom salt in enif_hashGuilherme Andrade
2017-04-12erts: Introduce struct binary_internalsSverker Eriksson
to replace macro ERTS_INTERNAL_BINARY_FIELDS as header in Binary and friends.
2017-03-28Fix use of uninitialized variable 'ret'Sverker Eriksson
DID_TRAP will read 'ret' even when error is returned. Found by valgrind.
2017-03-24Fix double hit bug of select/3 with bound keySverker Eriksson
2017-03-23Remove redundant variable initializationsGuilherme Andrade
2017-03-22Use ETS table id references on select_replaceGuilherme Andrade
2017-03-22erts: Optimize ets:select_replace to not use heapSverker Eriksson
for temporary matchspec results. ToDo: Would be even nicer if PAM could allocate and build the ETS objects without extra copy_struct needed.
2017-03-22Cleanup some unnecessary variable initializationSverker Eriksson
2017-03-22Fix typo that broke debug buildsGuilherme Andrade
2017-03-22Reject unsafe matchspecs on ets:select_replace/2Guilherme Andrade
Preemptively fail operation with badarg if the replacement object might have a different key.
2017-03-22Use magic refs on revamped ETS codeGuilherme Andrade
2017-03-22Deduplicate select* code on ETS hash tablesGuilherme Andrade
Refactor existing solution into a common iteration loop parameterized using stateful callbacks.
2017-03-22Disable ets:select_replace/2 for bagsGuilherme Andrade
The existing implementation presented both semantic inconsistencies and performance issues.
2017-03-22ETS: Allow for matchspec-based replacementGuilherme Andrade
2017-03-22erts: Improve reduction count during table cleanupSverker Eriksson
2017-03-22erts: Remove meta_main_tabSverker Eriksson
\o/ O / \ Also removed the body for CHECK_TABLES enabled by HARDDEBUG. Removed quite useless check for hash, but kept dead check code for tree.
2017-03-22erts: Pass tid argument down to trapping functionsSverker Eriksson
to get rid of meta table lookup by integer (tb->common.id)
2017-03-22erts: Replace meta_pid_to{_fixed}_tab with linked listsSverker Eriksson
from process psd through all owned/fixed tables. As meta_pid_to{_fixed}_tab maps to slot in meta_main_tab which is planned for destruction. In this commit we no longer seize table lock while freeing the table (free_table_cont) as it's not needed and makes the code a bit simpler. Any concurrent operation on the table will only access lock, owner and status and then bail out.
2017-02-06Use magic refs for compiled match specsRickard Green
2016-11-22Merge branch 'maint'Sverker Eriksson