Optimize read/write concurrency of mnesia/ets tables
This commit is contained in:
parent
e15e5d1f98
commit
d9470f365f
|
@ -43,7 +43,8 @@ mnesia(boot) ->
|
||||||
{type, set},
|
{type, set},
|
||||||
{disc_copies, [node()]},
|
{disc_copies, [node()]},
|
||||||
{record_name, banned},
|
{record_name, banned},
|
||||||
{attributes, record_info(fields, banned)}]);
|
{attributes, record_info(fields, banned)},
|
||||||
|
{storage_properties, [{ets, [{read_concurrency, true}]}]}]);
|
||||||
|
|
||||||
mnesia(copy) ->
|
mnesia(copy) ->
|
||||||
ok = ekka_mnesia:copy_table(?TAB).
|
ok = ekka_mnesia:copy_table(?TAB).
|
||||||
|
|
|
@ -54,7 +54,9 @@ mnesia(boot) ->
|
||||||
{type, bag},
|
{type, bag},
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{record_name, route},
|
{record_name, route},
|
||||||
{attributes, record_info(fields, route)}]);
|
{attributes, record_info(fields, route)},
|
||||||
|
{storage_properties, [{ets, [{read_concurrency, true},
|
||||||
|
{write_concurrency, true}]}]}]);
|
||||||
mnesia(copy) ->
|
mnesia(copy) ->
|
||||||
ok = ekka_mnesia:copy_table(?ROUTE).
|
ok = ekka_mnesia:copy_table(?ROUTE).
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,8 @@ mnesia(boot) ->
|
||||||
{type, set},
|
{type, set},
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{record_name, routing_node},
|
{record_name, routing_node},
|
||||||
{attributes, record_info(fields, routing_node)}]);
|
{attributes, record_info(fields, routing_node)},
|
||||||
|
{storage_properties, [{ets, [{read_concurrency, true}]}]}]);
|
||||||
|
|
||||||
mnesia(copy) ->
|
mnesia(copy) ->
|
||||||
ok = ekka_mnesia:copy_table(?ROUTING_NODE).
|
ok = ekka_mnesia:copy_table(?ROUTING_NODE).
|
||||||
|
|
|
@ -69,9 +69,11 @@ init([]) ->
|
||||||
{type, bag},
|
{type, bag},
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{record_name, global_session},
|
{record_name, global_session},
|
||||||
{attributes, record_info(fields, global_session)}]),
|
{attributes, record_info(fields, global_session)},
|
||||||
|
{storage_properties, [{ets, [{read_concurrency, true},
|
||||||
|
{write_concurrency, true}]}]}]),
|
||||||
ok = ekka_mnesia:copy_table(?TAB),
|
ok = ekka_mnesia:copy_table(?TAB),
|
||||||
ekka:monitor(membership),
|
_ = ekka:monitor(membership),
|
||||||
{ok, #{}}.
|
{ok, #{}}.
|
||||||
|
|
||||||
handle_call(Req, _From, State) ->
|
handle_call(Req, _From, State) ->
|
||||||
|
|
|
@ -36,16 +36,21 @@
|
||||||
%% @doc Create or replicate trie tables.
|
%% @doc Create or replicate trie tables.
|
||||||
-spec(mnesia(boot | copy) -> ok).
|
-spec(mnesia(boot | copy) -> ok).
|
||||||
mnesia(boot) ->
|
mnesia(boot) ->
|
||||||
|
%% Optimize
|
||||||
|
StoreProps = [{ets, [{read_concurrency, true},
|
||||||
|
{write_concurrency, true}]}],
|
||||||
%% Trie table
|
%% Trie table
|
||||||
ok = ekka_mnesia:create_table(?TRIE, [
|
ok = ekka_mnesia:create_table(?TRIE, [
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{record_name, trie},
|
{record_name, trie},
|
||||||
{attributes, record_info(fields, trie)}]),
|
{attributes, record_info(fields, trie)},
|
||||||
|
{storage_properties, StoreProps}]),
|
||||||
%% Trie node table
|
%% Trie node table
|
||||||
ok = ekka_mnesia:create_table(?TRIE_NODE, [
|
ok = ekka_mnesia:create_table(?TRIE_NODE, [
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{record_name, trie_node},
|
{record_name, trie_node},
|
||||||
{attributes, record_info(fields, trie_node)}]);
|
{attributes, record_info(fields, trie_node)},
|
||||||
|
{storage_properties, StoreProps}]);
|
||||||
|
|
||||||
mnesia(copy) ->
|
mnesia(copy) ->
|
||||||
%% Copy trie table
|
%% Copy trie table
|
||||||
|
|
Loading…
Reference in New Issue