From 7ee8080d1127b30c935dfd896a8e78b3a34ee176 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 29 Aug 2011 15:58:45 +0200 Subject: Improve performance of upgrade when many processes have old code This commit utilizes the new bif erlang:check_old_code/1 to check if a module has old code in the system or not before running erlang:check_process_code/2. This is to optimize release_handler:install_release (and release_handler:check_install_release). A new test is added which checks that after traversing all processes/modules once and purging all old code, the second run through this part of the code is "sufficiently" much faster. A note is also added in the reference manual for release_handler:install_release about how to go around the efficiency problem of this function. --- lib/sasl/src/release_handler_1.erl | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'lib/sasl/src') diff --git a/lib/sasl/src/release_handler_1.erl b/lib/sasl/src/release_handler_1.erl index ff62f847ac..590ecdba65 100644 --- a/lib/sasl/src/release_handler_1.erl +++ b/lib/sasl/src/release_handler_1.erl @@ -122,22 +122,29 @@ split_instructions([], Before) -> %% Mod = atom() %%----------------------------------------------------------------- check_old_processes(Script) -> + Procs = erlang:processes(), lists:foreach(fun({load, {Mod, soft_purge, _PostPurgeMethod}}) -> - check_old_code(Mod); + check_old_code(Mod,Procs); ({remove, {Mod, soft_purge, _PostPurgeMethod}}) -> - check_old_code(Mod); + check_old_code(Mod,Procs); (_) -> ok end, Script). -check_old_code(Mod) -> - lists:foreach(fun(Pid) -> - case erlang:check_process_code(Pid, Mod) of - false -> ok; - true -> throw({error, Mod}) - end - end, - erlang:processes()). +check_old_code(Mod,Procs) -> + case erlang:check_old_code(Mod) of + true -> + lists:foreach(fun(Pid) -> + case erlang:check_process_code(Pid, Mod) of + false -> ok; + true -> throw({error, Mod}) + end + end, + Procs); + false -> + ok + end. + %%----------------------------------------------------------------- %% An unpurged module is a module for which there exist an old -- cgit v1.2.3