Age | Commit message (Collapse) | Author |
|
|
|
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
|
|
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.
|
|
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.
|
|
and rename it from match_callbacks_t.
|
|
into sverker/master/ets-no-mbuf-trapping/OTP-15660
|
|
into sverker/maint/ets-no-mbuf-trapping/OTP-15660
|
|
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.
|
|
|
|
Update table memory stats before scheduling free
to not be dependent on deallocation order with main table struct.
|
|
|
|
causing erlang:memory to report too much ets memory.
|
|
|
|
as it's now only used for empty tables by ets:new/2.
|
|
|
|
by only allocating one FixedDeletion with the new "all" flag
instead of one FixedDeletion per slot.
|
|
* 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}"
|
|
|
|
to be done after lock has been released.
|
|
Separate pseudo-deleted-flag from the hash value.
|
|
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.
|
|
and not the name. For more sane named table semantics.
Applies to both select/1 continuation and trap context.
|
|
where argument 'list' is the first candidate (not list->next).
Also simplified db_first_hash().
|
|
There is no NULL check here !?
|
|
|
|
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.
|
|
|
|
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
|
|
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
|
|
|
|
Support hashing terms from NIF code
|
|
|
|
to replace macro ERTS_INTERNAL_BINARY_FIELDS
as header in Binary and friends.
|
|
DID_TRAP will read 'ret' even when error is returned.
Found by valgrind.
|
|
|
|
|
|
|
|
for temporary matchspec results.
ToDo: Would be even nicer if PAM could allocate and build
the ETS objects without extra copy_struct needed.
|
|
|
|
|
|
Preemptively fail operation with badarg if the replacement object
might have a different key.
|
|
|
|
Refactor existing solution into a common iteration loop parameterized
using stateful callbacks.
|
|
The existing implementation presented both
semantic inconsistencies and performance issues.
|
|
|
|
|
|
\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.
|
|
to get rid of meta table lookup by integer (tb->common.id)
|
|
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.
|
|
|