ets:delete slow when using complex keys ?

Pascal Brisset pascal.brisset@REDACTED
Tue Oct 9 13:56:05 CEST 2001

The code below shows that ets:delete can take as much as 70 seconds to
free a 60MB ETS table, and that other processes are frozen during that
time (tested on OTP R7B-1 and P8A-20011007, linux, x86, 400MHz).

The delay seems to depend a lot on the complexity of keys (only 4
seconds if we replace PIDs with atoms). Could there be a problem in
free_hash_table()/free_tree_table() ?

My problem is that mnesia_recover.erl builds such tables and deletes
them every few minutes. Can this problem be avoided with some magic
combination of system_flags, process_flags and mnesia parameters ?

-- Pascal Brisset <pascal.brisset@REDACTED> +33141986741 --
----- Cellicium | 73 avenue Carnot | 94230 Cachan | France -----


start() ->
    spawn(?MODULE, check_realtime, [1.0e20]),
    T = ets:new(tbl, [{keypos, 2}, set, public]),
    fill(T, 1000000),

fill(T, 0) -> ok;
fill(T, N) ->
    ets:insert(T, {transient_decision,{tid,N,self()},committed}),
    %% ets:insert(T, {transient_decision,{tid,N,committed},self()}),
    fill(T, N-1).

check_realtime(Time) ->
    receive after 100 -> ok end,
    {MS,S,US} = now(),
    Time1 = (MS*1000000+S)*1000 + US div 1000,
    Delay = Time1 - Time,
    if Delay > 1000 -> io:format("Been sleeping for ~p ms !~n", [Delay]);
       true -> ok

More information about the erlang-questions mailing list