Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
3131-Make-max_transfer_size-parameter-configura...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 3131-Make-max_transfer_size-parameter-configurable-to-opt.patch of Package erlang
From a40338681382a2f578f101db7f1fcfc5d6490293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Smyczy=C5=84ski?= <s.smyczynski@simplito.com> Date: Tue, 1 Jun 2021 13:01:17 +0200 Subject: [PATCH] Make max_transfer_size parameter configurable to optimise mnesia table loading time --- lib/mnesia/doc/src/mnesia.xml | 5 +++++ lib/mnesia/src/mnesia.erl | 2 ++ lib/mnesia/src/mnesia_loader.erl | 14 ++++++++++---- lib/mnesia/src/mnesia_monitor.erl | 4 ++++ lib/mnesia/test/mnesia_evil_coverage_test.erl | 1 + 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/mnesia/doc/src/mnesia.xml b/lib/mnesia/doc/src/mnesia.xml index 9be51a27b3..f39d64b6ab 100644 --- a/lib/mnesia/doc/src/mnesia.xml +++ b/lib/mnesia/doc/src/mnesia.xml @@ -3037,6 +3037,11 @@ raise(Name, Amount) -> non-zero value, ensure that the remote nodes understand this configuration.</p> </item> + <item> + <p><c>-mnesia max_transfer_size Number</c>. Specifies the estimated size + in bytes of a single packet of data to be used when copying a table from the local + node to another one. Default is <c>64000</c>.</p> + </item> <item> <p><c>-mnesia schema_location Loc</c>. Controls where Mnesia looks for its schema. Parameter diff --git a/lib/mnesia/src/mnesia.erl b/lib/mnesia/src/mnesia.erl index f9e452cd59..028deccea4 100644 --- a/lib/mnesia/src/mnesia.erl +++ b/lib/mnesia/src/mnesia.erl @@ -2553,6 +2553,7 @@ system_info2(core_dir) -> mnesia_monitor:get_env(core_dir); system_info2(no_table_loaders) -> mnesia_monitor:get_env(no_table_loaders); system_info2(dc_dump_limit) -> mnesia_monitor:get_env(dc_dump_limit); system_info2(send_compressed) -> mnesia_monitor:get_env(send_compressed); +system_info2(max_transfer_size) -> mnesia_monitor:get_env(max_transfer_size); system_info2(Item) -> exit({badarg, Item}). @@ -2598,6 +2599,7 @@ system_info_items(yes) -> no_table_loaders, dc_dump_limit, send_compressed, + max_transfer_size, version ]; system_info_items(no) -> diff --git a/lib/mnesia/src/mnesia_loader.erl b/lib/mnesia/src/mnesia_loader.erl index a2fde5c808..b7e7f98499 100644 --- a/lib/mnesia/src/mnesia_loader.erl +++ b/lib/mnesia/src/mnesia_loader.erl @@ -189,9 +189,6 @@ do_get_disc_copy2(Tab, Reason, Storage = {ext, Alias, Mod}, _Type) -> %% Release read lock on table %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --define(MAX_TRANSFER_SIZE, 7500). --define(MAX_RAM_FILE_SIZE, 1000000). --define(MAX_RAM_TRANSFERS, (?MAX_RAM_FILE_SIZE div ?MAX_TRANSFER_SIZE) + 1). -define(MAX_NOPACKETS, 20). net_load_table(Tab, {dumper,{add_table_copy, _}}=Reason, Ns, Cs) -> @@ -740,6 +737,15 @@ db_put({disc_only_copies, Tab}, Val) -> db_put({{ext, Alias, Mod}, Tab}, Val) -> ok = Mod:insert(Alias, Tab, Val). +max_transfer_size() -> + MaxTransferSize = 64000, + case ?catch_val(max_transfer_size) of + {'EXIT', _} -> + mnesia_lib:set(max_transfer_size, MaxTransferSize), + MaxTransferSize; + Val -> Val + end. + %% This code executes at the remote site where the data is %% executes in a special copier process. @@ -748,7 +754,7 @@ calc_nokeys(Storage, Tab) -> Key = mnesia_lib:db_first(Storage, Tab), Recs = mnesia_lib:db_get(Storage, Tab, Key), BinSize = size(term_to_binary(Recs)), - (?MAX_TRANSFER_SIZE div BinSize) + 1. + (max_transfer_size() div BinSize) + 1. send_table(Pid, Tab, RemoteS, Reason) -> case ?catch_val({Tab, storage_type}) of diff --git a/lib/mnesia/src/mnesia_monitor.erl b/lib/mnesia/src/mnesia_monitor.erl index 6ea8a0544b..5c1c0395d6 100644 --- a/lib/mnesia/src/mnesia_monitor.erl +++ b/lib/mnesia/src/mnesia_monitor.erl @@ -691,6 +691,7 @@ env() -> no_table_loaders, dc_dump_limit, send_compressed, + max_transfer_size, schema ]. @@ -741,6 +742,8 @@ default_env(dc_dump_limit) -> 4; default_env(send_compressed) -> 0; +default_env(max_transfer_size) -> + 64000; default_env(schema) -> []. @@ -790,6 +793,7 @@ do_check_type(pid_sort_order, _) -> false; do_check_type(no_table_loaders, N) when is_integer(N), N > 0 -> N; do_check_type(dc_dump_limit,N) when is_number(N), N > 0 -> N; do_check_type(send_compressed, L) when is_integer(L), L >= 0, L =< 9 -> L; +do_check_type(max_transfer_size, N) when is_integer(N), N > 0 -> N; do_check_type(schema, L) when is_list(L) -> L. bool(true) -> true; diff --git a/lib/mnesia/test/mnesia_evil_coverage_test.erl b/lib/mnesia/test/mnesia_evil_coverage_test.erl index a451c8d0c8..f6f2bfd45e 100644 --- a/lib/mnesia/test/mnesia_evil_coverage_test.erl +++ b/lib/mnesia/test/mnesia_evil_coverage_test.erl @@ -140,6 +140,7 @@ system_info(Config) when is_list(Config) -> ?match(A when is_atom(A), mnesia:system_info(dump_log_update_in_place)), ?match(I when is_integer(I), mnesia:system_info(transaction_log_writes)), ?match(I when is_integer(I), mnesia:system_info(send_compressed)), + ?match(I when is_integer(I), mnesia:system_info(max_transfer_size)), ?match(L when is_list(L), mnesia:system_info(all)), ?match(L when is_list(L), mnesia:system_info(backend_types)), ?match({'EXIT', {aborted, Reason }} when element(1, Reason) == badarg -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor