mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
Disable the two new caches in make.deps_cache.m.
They turned out to have a zero hit rate, making them useless.
compiler/make.dependencies.m:
Add code to use the two new caches, indirect_imports_non_intermod
and anc0_dir1_indir2_non_intermod. I got statistics on their
performance while they were enabled, but since their hit rate was zero,
this diff includes them only in a commented-out form.
Note that adding the second cache required adding a new dep_spec,
which remains, since it shouldn't affect performance at all.
compiler/make.deps_cache.m:
Disable the those two caches.
Fix an issue where the original statistics-gathering code
mixed up hits and misses.
Include the statistics gathered in course of implementing this diff.
tools/make_deps_cache_stats:
Update this script to fix the hit/miss issue, and to print more info.
This commit is contained in:
@@ -182,10 +182,7 @@ find_target_dependencies_of_module(ProgressStream, KeepGoing, Globals,
|
||||
),
|
||||
DepSpecs = [
|
||||
self(module_target_source),
|
||||
% XXX Should we cache the remaining dep_specs as a whole?
|
||||
ancestors(module_target_int0),
|
||||
direct_imports_non_intermod(module_target_int1),
|
||||
indirect_imports_non_intermod(module_target_int2)
|
||||
anc0_dir1_indir2_non_intermod
|
||||
],
|
||||
find_dep_specs(ProgressStream, KeepGoing, Globals,
|
||||
ModuleIndex, DepSpecs, NewSucceeded, NewDeps, !Info, !IO),
|
||||
@@ -194,9 +191,7 @@ find_target_dependencies_of_module(ProgressStream, KeepGoing, Globals,
|
||||
TargetType = module_target_analysis_registry,
|
||||
DepSpecs = [
|
||||
self(module_target_source),
|
||||
ancestors(module_target_int0),
|
||||
direct_imports_non_intermod(module_target_int1),
|
||||
indirect_imports_non_intermod(module_target_int2),
|
||||
anc0_dir1_indir2_non_intermod,
|
||||
direct_imports_intermod(module_target_opt),
|
||||
indirect_imports_intermod(module_target_opt),
|
||||
intermod_imports(module_target_opt)
|
||||
@@ -304,6 +299,7 @@ compiled_code_dependencies(Globals, DepSpecs) :-
|
||||
; intermod_imports(module_target_type)
|
||||
; foreign_imports_intermod_trans(module_target_type)
|
||||
|
||||
; anc0_dir1_indir2_non_intermod
|
||||
; anc0_dir1_indir2_intermod
|
||||
% Get the .int0 files of ancestors, the .int files of direct
|
||||
% imports, and the .int2 files of indirect imports.
|
||||
@@ -404,6 +400,49 @@ find_dep_spec(ProgressStream, KeepGoing, Globals, ModuleIndex, DepSpec,
|
||||
get_foreign_imports_intermod_trans(ProgressStream, KeepGoing, Globals,
|
||||
ModuleIndex, Succeeded, ModuleIndexSet, !Info, !IO),
|
||||
dfmi_targets(ModuleIndexSet, TargetType, DepFileIndexSet, !Info)
|
||||
;
|
||||
DepSpec = anc0_dir1_indir2_non_intermod,
|
||||
SubDepSpecs = [
|
||||
ancestors(module_target_int0),
|
||||
direct_imports_non_intermod(module_target_int1),
|
||||
indirect_imports_non_intermod(module_target_int2)
|
||||
],
|
||||
trace [
|
||||
compile_time(flag("find_dep_spec")),
|
||||
run_time(env("FIND_DEP_SPEC")),
|
||||
io(!TIO)
|
||||
] (
|
||||
module_index_to_name(!.Info, ModuleIndex, IndexModuleName),
|
||||
IndexModuleNameStr = sym_name_to_string(IndexModuleName),
|
||||
io.format(ProgressStream, "dep_spec %s for %s starts\n\n",
|
||||
[s(string.string(DepSpec)), s(IndexModuleNameStr)], !TIO)
|
||||
),
|
||||
|
||||
% This cache is disabled, because it is ineffective.
|
||||
% ( if
|
||||
% search_anc0_dir1_indir2_non_intermod_cache(!.Info, ModuleIndex,
|
||||
% Result0)
|
||||
% then
|
||||
% Result0 = deps_result(Succeeded, DepFileIndexSet)
|
||||
% else
|
||||
find_dep_specs(ProgressStream, KeepGoing, Globals,
|
||||
ModuleIndex, SubDepSpecs, Succeeded, DepFileIndexSet,
|
||||
!Info, !IO),
|
||||
% Result = deps_result(Succeeded, DepFileIndexSet),
|
||||
% add_to_anc0_dir1_indir2_non_intermod_cache(ModuleIndex, Result,
|
||||
% !Info)
|
||||
% ),
|
||||
|
||||
trace [
|
||||
compile_time(flag("find_dep_spec")),
|
||||
run_time(env("FIND_DEP_SPEC")),
|
||||
io(!TIO)
|
||||
] (
|
||||
module_index_to_name(!.Info, ModuleIndex, IndexModuleName),
|
||||
IndexModuleNameStr = sym_name_to_string(IndexModuleName),
|
||||
io.format(ProgressStream, "dep_spec %s for %s ends\n",
|
||||
[s(string.string(DepSpec)), s(IndexModuleNameStr)], !TIO)
|
||||
)
|
||||
;
|
||||
DepSpec = anc0_dir1_indir2_intermod,
|
||||
SubDepSpecs = [
|
||||
@@ -458,9 +497,9 @@ find_dep_spec(ProgressStream, KeepGoing, Globals, ModuleIndex, DepSpec,
|
||||
[s(string.string(DepSpec)), s(IndexModuleNameStr)], !TIO)
|
||||
),
|
||||
|
||||
get_anc0_dir1_indir2_intermod_of_ancestors_of_intermod_imports(ProgressStream,
|
||||
KeepGoing, Globals, ModuleIndex, Succeeded, DepFileIndexSet,
|
||||
!Info, !IO),
|
||||
get_anc0_dir1_indir2_intermod_of_ancestors_of_intermod_imports(
|
||||
ProgressStream, KeepGoing, Globals, ModuleIndex,
|
||||
Succeeded, DepFileIndexSet, !Info, !IO),
|
||||
|
||||
trace [
|
||||
compile_time(flag("find_dep_spec")),
|
||||
@@ -507,7 +546,8 @@ find_dep_spec(ProgressStream, KeepGoing, Globals, ModuleIndex, DepSpec,
|
||||
DepFiles = [_ | _],
|
||||
DepFileNlStrs = list.map(
|
||||
dependency_file_to_debug_string(" ", "\n"), DepFiles),
|
||||
io.format(ProgressStream, "dep_spec %s for %s yields these deps:\n",
|
||||
io.format(ProgressStream,
|
||||
"dep_spec %s for %s yields these deps:\n",
|
||||
[s(string.string(DepSpec)), s(IndexModuleNameStr)], !TIO),
|
||||
list.foldl(io.write_string(ProgressStream), DepFileNlStrs, !TIO),
|
||||
io.write_string(ProgressStream, "dep list ends\n\n", !TIO)
|
||||
@@ -657,11 +697,21 @@ get_direct_imports_intermod(ProgressStream, KeepGoing, Globals, ModuleIndex,
|
||||
get_indirect_imports_non_intermod(ProgressStream, KeepGoing, Globals,
|
||||
ModuleIndex, Succeeded, IndirectNonIntermodImportModules,
|
||||
!Info, !IO) :-
|
||||
get_direct_imports_non_intermod(ProgressStream, KeepGoing, Globals,
|
||||
ModuleIndex, DirectSucceeded, DirectImportModules, !Info, !IO),
|
||||
get_indirect_imports_uncached(ProgressStream, KeepGoing, Globals,
|
||||
ModuleIndex, DirectSucceeded, DirectImportModules,
|
||||
Succeeded, IndirectNonIntermodImportModules, !Info, !IO).
|
||||
% This cache is disabled, because it is ineffective.
|
||||
% ( if
|
||||
% search_indirect_imports_non_intermod_cache(!.Info, ModuleIndex,
|
||||
% Result0)
|
||||
% then
|
||||
% Result0 = deps_result(Succeeded, IndirectNonIntermodImportModules)
|
||||
% else
|
||||
get_direct_imports_non_intermod(ProgressStream, KeepGoing, Globals,
|
||||
ModuleIndex, DirectSucceeded, DirectImportModules, !Info, !IO),
|
||||
get_indirect_imports_uncached(ProgressStream, KeepGoing, Globals,
|
||||
ModuleIndex, DirectSucceeded, DirectImportModules,
|
||||
Succeeded, IndirectNonIntermodImportModules, !Info, !IO).
|
||||
% Result = deps_result(Succeeded, IndirectNonIntermodImportModules),
|
||||
% add_to_indirect_imports_non_intermod_cache(ModuleIndex, Result, !Info)
|
||||
% ).
|
||||
|
||||
% Return the list of modules for which we should read `.int2' files.
|
||||
%
|
||||
|
||||
@@ -80,10 +80,10 @@
|
||||
|
||||
%---------------------%
|
||||
|
||||
:- pred search_indirect_imports_non_intermod_cache(make_info::in,
|
||||
module_index::in, module_deps_result::out) is semidet.
|
||||
:- pred add_to_indirect_imports_non_intermod_cache(module_index::in,
|
||||
module_deps_result::in, make_info::in, make_info::out) is det.
|
||||
% :- pred search_indirect_imports_non_intermod_cache(make_info::in,
|
||||
% module_index::in, module_deps_result::out) is semidet.
|
||||
% :- pred add_to_indirect_imports_non_intermod_cache(module_index::in,
|
||||
% module_deps_result::in, make_info::in, make_info::out) is det.
|
||||
|
||||
:- pred search_indirect_imports_intermod_cache(make_info::in,
|
||||
module_index::in, module_deps_result::out) is semidet.
|
||||
@@ -99,10 +99,10 @@
|
||||
|
||||
%---------------------%
|
||||
|
||||
:- pred search_anc0_dir1_indir2_non_intermod_cache(make_info::in,
|
||||
module_index::in, dependency_file_deps_result::out) is semidet.
|
||||
:- pred add_to_anc0_dir1_indir2_non_intermod_cache(module_index::in,
|
||||
dependency_file_deps_result::in, make_info::in, make_info::out) is det.
|
||||
% :- pred search_anc0_dir1_indir2_non_intermod_cache(make_info::in,
|
||||
% module_index::in, dependency_file_deps_result::out) is semidet.
|
||||
% :- pred add_to_anc0_dir1_indir2_non_intermod_cache(module_index::in,
|
||||
% dependency_file_deps_result::in, make_info::in, make_info::out) is det.
|
||||
|
||||
:- pred search_anc0_dir1_indir2_intermod_cache(make_info::in,
|
||||
module_index::in, dependency_file_deps_result::out) is semidet.
|
||||
@@ -160,8 +160,8 @@ add_to_direct_imports_non_intermod_cache(ModuleIndex, Result, !Info) :-
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Hit0 = Stats0 ^ direct_non_intermod_hits,
|
||||
Stats = Stats0 ^ direct_non_intermod_hits := Hit0 + 1u,
|
||||
Miss0 = Stats0 ^ direct_non_intermod_misses,
|
||||
Stats = Stats0 ^ direct_non_intermod_misses := Miss0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap0 = make_info_get_direct_imports_non_intermod_cache(!.Info),
|
||||
@@ -189,8 +189,8 @@ add_to_direct_imports_intermod_cache(ModuleIndex, Result, !Info) :-
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Hit0 = Stats0 ^ direct_intermod_hits,
|
||||
Stats = Stats0 ^ direct_intermod_hits := Hit0 + 1u,
|
||||
Miss0 = Stats0 ^ direct_intermod_misses,
|
||||
Stats = Stats0 ^ direct_intermod_misses := Miss0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap0 = make_info_get_direct_imports_intermod_cache(!.Info),
|
||||
@@ -199,34 +199,34 @@ add_to_direct_imports_intermod_cache(ModuleIndex, Result, !Info) :-
|
||||
|
||||
%---------------------%
|
||||
|
||||
search_indirect_imports_non_intermod_cache(Info, ModuleIndex, Result) :-
|
||||
trace [
|
||||
compile_time(flag("deps_cache_stats")),
|
||||
run_time(env("DEPS_CACHE_STATS")),
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Acc0 = Stats0 ^ indirect_non_intermod_accesses,
|
||||
Stats = Stats0 ^ indirect_non_intermod_accesses := Acc0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap = make_info_get_indirect_imports_intermod_cache(Info),
|
||||
map.search(CacheMap, ModuleIndex, Result).
|
||||
|
||||
add_to_indirect_imports_non_intermod_cache(ModuleIndex, Result, !Info) :-
|
||||
trace [
|
||||
compile_time(flag("deps_cache_stats")),
|
||||
run_time(env("DEPS_CACHE_STATS")),
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Hit0 = Stats0 ^ indirect_non_intermod_hits,
|
||||
Stats = Stats0 ^ indirect_non_intermod_hits := Hit0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap0 = make_info_get_indirect_imports_intermod_cache(!.Info),
|
||||
map.det_insert(ModuleIndex, Result, CacheMap0, CacheMap),
|
||||
make_info_set_indirect_imports_intermod_cache(CacheMap, !Info).
|
||||
% search_indirect_imports_non_intermod_cache(Info, ModuleIndex, Result) :-
|
||||
% trace [
|
||||
% compile_time(flag("deps_cache_stats")),
|
||||
% run_time(env("DEPS_CACHE_STATS")),
|
||||
% io(!TIO)
|
||||
% ] (
|
||||
% get_deps_cache_stats(Stats0, !TIO),
|
||||
% Acc0 = Stats0 ^ indirect_non_intermod_accesses,
|
||||
% Stats = Stats0 ^ indirect_non_intermod_accesses := Acc0 + 1u,
|
||||
% set_deps_cache_stats(Stats, !TIO)
|
||||
% ),
|
||||
% CacheMap = make_info_get_indirect_imports_non_intermod_cache(Info),
|
||||
% map.search(CacheMap, ModuleIndex, Result).
|
||||
%
|
||||
% add_to_indirect_imports_non_intermod_cache(ModuleIndex, Result, !Info) :-
|
||||
% trace [
|
||||
% compile_time(flag("deps_cache_stats")),
|
||||
% run_time(env("DEPS_CACHE_STATS")),
|
||||
% io(!TIO)
|
||||
% ] (
|
||||
% get_deps_cache_stats(Stats0, !TIO),
|
||||
% Miss0 = Stats0 ^ indirect_non_intermod_misses,
|
||||
% Stats = Stats0 ^ indirect_non_intermod_misses := Miss0 + 1u,
|
||||
% set_deps_cache_stats(Stats, !TIO)
|
||||
% ),
|
||||
% CacheMap0 = make_info_get_indirect_imports_non_intermod_cache(!.Info),
|
||||
% map.det_insert(ModuleIndex, Result, CacheMap0, CacheMap),
|
||||
% make_info_set_indirect_imports_non_intermod_cache(CacheMap, !Info).
|
||||
|
||||
search_indirect_imports_intermod_cache(Info, ModuleIndex, Result) :-
|
||||
trace [
|
||||
@@ -249,8 +249,8 @@ add_to_indirect_imports_intermod_cache(ModuleIndex, Result, !Info) :-
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Hit0 = Stats0 ^ indirect_intermod_hits,
|
||||
Stats = Stats0 ^ indirect_intermod_hits := Hit0 + 1u,
|
||||
Miss0 = Stats0 ^ indirect_intermod_misses,
|
||||
Stats = Stats0 ^ indirect_intermod_misses := Miss0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap0 = make_info_get_indirect_imports_intermod_cache(!.Info),
|
||||
@@ -280,8 +280,8 @@ add_to_foreign_imports_non_intermod_trans_cache(ModuleIndex, Result, !Info) :-
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Hit0 = Stats0 ^ foreign_non_intermod_hits,
|
||||
Stats = Stats0 ^ foreign_non_intermod_hits := Hit0 + 1u,
|
||||
Miss0 = Stats0 ^ foreign_non_intermod_misses,
|
||||
Stats = Stats0 ^ foreign_non_intermod_misses := Miss0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap0 = make_info_get_foreign_imports_non_intermod_trans_cache(!.Info),
|
||||
@@ -290,34 +290,34 @@ add_to_foreign_imports_non_intermod_trans_cache(ModuleIndex, Result, !Info) :-
|
||||
|
||||
%---------------------------------------------------------------------------%
|
||||
|
||||
search_anc0_dir1_indir2_non_intermod_cache(Info, Key, Result) :-
|
||||
trace [
|
||||
compile_time(flag("deps_cache_stats")),
|
||||
run_time(env("DEPS_CACHE_STATS")),
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Acc0 = Stats0 ^ anc0_dir1_indir2_non_intermod_accesses,
|
||||
Stats = Stats0 ^ anc0_dir1_indir2_non_intermod_accesses := Acc0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap = make_info_get_anc0_dir1_indir2_non_intermod_cache(Info),
|
||||
map.search(CacheMap, Key, Result).
|
||||
|
||||
add_to_anc0_dir1_indir2_non_intermod_cache(Key, Result, !Info) :-
|
||||
trace [
|
||||
compile_time(flag("deps_cache_stats")),
|
||||
run_time(env("DEPS_CACHE_STATS")),
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Hit0 = Stats0 ^ anc0_dir1_indir2_non_intermod_hits,
|
||||
Stats = Stats0 ^ anc0_dir1_indir2_non_intermod_hits := Hit0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap0 = make_info_get_anc0_dir1_indir2_non_intermod_cache(!.Info),
|
||||
map.det_insert(Key, Result, CacheMap0, CacheMap),
|
||||
make_info_set_anc0_dir1_indir2_non_intermod_cache(CacheMap, !Info).
|
||||
% search_anc0_dir1_indir2_non_intermod_cache(Info, Key, Result) :-
|
||||
% trace [
|
||||
% compile_time(flag("deps_cache_stats")),
|
||||
% run_time(env("DEPS_CACHE_STATS")),
|
||||
% io(!TIO)
|
||||
% ] (
|
||||
% get_deps_cache_stats(Stats0, !TIO),
|
||||
% Acc0 = Stats0 ^ anc0_dir1_indir2_non_intermod_accesses,
|
||||
% Stats = Stats0 ^ anc0_dir1_indir2_non_intermod_accesses := Acc0 + 1u,
|
||||
% set_deps_cache_stats(Stats, !TIO)
|
||||
% ),
|
||||
% CacheMap = make_info_get_anc0_dir1_indir2_non_intermod_cache(Info),
|
||||
% map.search(CacheMap, Key, Result).
|
||||
%
|
||||
% add_to_anc0_dir1_indir2_non_intermod_cache(Key, Result, !Info) :-
|
||||
% trace [
|
||||
% compile_time(flag("deps_cache_stats")),
|
||||
% run_time(env("DEPS_CACHE_STATS")),
|
||||
% io(!TIO)
|
||||
% ] (
|
||||
% get_deps_cache_stats(Stats0, !TIO),
|
||||
% Miss0 = Stats0 ^ anc0_dir1_indir2_non_intermod_misses,
|
||||
% Stats = Stats0 ^ anc0_dir1_indir2_non_intermod_misses := Miss0 + 1u,
|
||||
% set_deps_cache_stats(Stats, !TIO)
|
||||
% ),
|
||||
% CacheMap0 = make_info_get_anc0_dir1_indir2_non_intermod_cache(!.Info),
|
||||
% map.det_insert(Key, Result, CacheMap0, CacheMap),
|
||||
% make_info_set_anc0_dir1_indir2_non_intermod_cache(CacheMap, !Info).
|
||||
|
||||
search_anc0_dir1_indir2_intermod_cache(Info, Key, Result) :-
|
||||
trace [
|
||||
@@ -340,8 +340,8 @@ add_to_anc0_dir1_indir2_intermod_cache(Key, Result, !Info) :-
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Hit0 = Stats0 ^ anc0_dir1_indir2_intermod_hits,
|
||||
Stats = Stats0 ^ anc0_dir1_indir2_intermod_hits := Hit0 + 1u,
|
||||
Miss0 = Stats0 ^ anc0_dir1_indir2_intermod_misses,
|
||||
Stats = Stats0 ^ anc0_dir1_indir2_intermod_misses := Miss0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap0 = make_info_get_anc0_dir1_indir2_intermod_cache(!.Info),
|
||||
@@ -371,8 +371,8 @@ add_to_trans_deps_cache(DepsRoot, Result, !Info) :-
|
||||
io(!TIO)
|
||||
] (
|
||||
get_deps_cache_stats(Stats0, !TIO),
|
||||
Hit0 = Stats0 ^ trans_deps_hits,
|
||||
Stats = Stats0 ^ trans_deps_hits := Hit0 + 1u,
|
||||
Miss0 = Stats0 ^ trans_deps_misses,
|
||||
Stats = Stats0 ^ trans_deps_misses := Miss0 + 1u,
|
||||
set_deps_cache_stats(Stats, !TIO)
|
||||
),
|
||||
CacheMap0 = make_info_get_trans_deps_cache(!.Info),
|
||||
@@ -382,34 +382,56 @@ add_to_trans_deps_cache(DepsRoot, Result, !Info) :-
|
||||
%---------------------------------------------------------------------------%
|
||||
%---------------------------------------------------------------------------%
|
||||
|
||||
% The results of a bootcheck in csharp grade on 2023 oct 16
|
||||
% were as follows. The zero hit rate of the indirect_imports_non_intermod
|
||||
% and anc0_dir1_indir2_non_intermod caches is why their code is commented out,
|
||||
% here, in make.make_info, and in make.dependencies.m.
|
||||
%
|
||||
% number of lookups: 2012939
|
||||
% number of hits: 1962569
|
||||
% number of misses: 50370
|
||||
% hit %: 97.50
|
||||
%
|
||||
% ----------------------------------------------------------
|
||||
%
|
||||
% cache #exec #lookup #hit #miss hit%
|
||||
%
|
||||
% direct_imports_non_intermod 100 850145 838363 11782 98.61
|
||||
% direct_imports_intermod 100 17300 10965 6335 63.38
|
||||
% indirect_imports_non_intermod 57 4112 0 4112 0.00
|
||||
% indirect_imports_intermod 100 10965 4630 6335 42.23
|
||||
% anc0_dir1_indir2_non_intermod 57 4112 0 4112 0.00
|
||||
% anc0_dir1_indir2_intermod 84 41386 36891 4495 89.14
|
||||
% trans_deps 100 1084919 1071720 13199 98.78
|
||||
|
||||
:- mutable(deps_cache_stats, deps_cache_stats, init_deps_cache_stats, ground,
|
||||
[untrailed, attach_to_io_state]).
|
||||
|
||||
:- type deps_cache_stats
|
||||
---> deps_cache_stats(
|
||||
direct_non_intermod_accesses :: uint,
|
||||
direct_non_intermod_hits :: uint,
|
||||
direct_non_intermod_misses :: uint,
|
||||
|
||||
direct_intermod_accesses :: uint,
|
||||
direct_intermod_hits :: uint,
|
||||
direct_intermod_misses :: uint,
|
||||
|
||||
indirect_non_intermod_accesses :: uint,
|
||||
indirect_non_intermod_hits :: uint,
|
||||
indirect_non_intermod_misses :: uint,
|
||||
|
||||
indirect_intermod_accesses :: uint,
|
||||
indirect_intermod_hits :: uint,
|
||||
indirect_intermod_misses :: uint,
|
||||
|
||||
foreign_non_intermod_accesses :: uint,
|
||||
foreign_non_intermod_hits :: uint,
|
||||
foreign_non_intermod_misses :: uint,
|
||||
|
||||
anc0_dir1_indir2_non_intermod_accesses :: uint,
|
||||
anc0_dir1_indir2_non_intermod_hits :: uint,
|
||||
anc0_dir1_indir2_non_intermod_misses :: uint,
|
||||
|
||||
anc0_dir1_indir2_intermod_accesses :: uint,
|
||||
anc0_dir1_indir2_intermod_hits :: uint,
|
||||
anc0_dir1_indir2_intermod_misses :: uint,
|
||||
|
||||
trans_deps_accesses :: uint,
|
||||
trans_deps_hits :: uint
|
||||
trans_deps_misses :: uint
|
||||
).
|
||||
|
||||
:- func init_deps_cache_stats = deps_cache_stats.
|
||||
@@ -421,24 +443,24 @@ init_deps_cache_stats =
|
||||
record_make_deps_cache_stats(!IO) :-
|
||||
get_deps_cache_stats(Stats, !IO),
|
||||
Stats = deps_cache_stats(
|
||||
DirectNIAcc, DirectNIHit,
|
||||
DirectIAcc, DirectIHit,
|
||||
IndirectNIAcc, IndirectNIHit,
|
||||
IndirectIAcc, IndirectIHit,
|
||||
ForeignNIAcc, ForeignNIHit,
|
||||
Import012NIAcc, Import012NIHit,
|
||||
Import012IAcc, Import012IHit,
|
||||
TransDepsAcc, TransDepsHit
|
||||
DirectNIAcc, DirectNIMiss,
|
||||
DirectIAcc, DirectIMiss,
|
||||
IndirectNIAcc, IndirectNIMiss,
|
||||
IndirectIAcc, IndirectIMiss,
|
||||
ForeignNIAcc, ForeignNIMiss,
|
||||
Import012NIAcc, Import012NIMiss,
|
||||
Import012IAcc, Import012IMiss,
|
||||
TransDepsAcc, TransDepsMiss
|
||||
),
|
||||
StatTuples = [
|
||||
{"direct_imports_non_intermod", DirectNIAcc, DirectNIHit},
|
||||
{"direct_imports_intermod", DirectIAcc, DirectIHit},
|
||||
{"indirect_imports_non_intermod", IndirectNIAcc, IndirectNIHit},
|
||||
{"indirect_imports_intermod", IndirectIAcc, IndirectIHit},
|
||||
{"foreign_imports_non_intermod", ForeignNIAcc, ForeignNIHit},
|
||||
{"anc0_dir1_indir2_non_intermod", Import012NIAcc, Import012NIHit},
|
||||
{"anc0_dir1_indir2_intermod", Import012IAcc, Import012IHit},
|
||||
{"trans_deps", TransDepsAcc, TransDepsHit}
|
||||
{"direct_imports_non_intermod", DirectNIAcc, DirectNIMiss},
|
||||
{"direct_imports_intermod", DirectIAcc, DirectIMiss},
|
||||
{"indirect_imports_non_intermod", IndirectNIAcc, IndirectNIMiss},
|
||||
{"indirect_imports_intermod", IndirectIAcc, IndirectIMiss},
|
||||
{"foreign_imports_non_intermod", ForeignNIAcc, ForeignNIMiss},
|
||||
{"anc0_dir1_indir2_non_intermod", Import012NIAcc, Import012NIMiss},
|
||||
{"anc0_dir1_indir2_intermod", Import012IAcc, Import012IMiss},
|
||||
{"trans_deps", TransDepsAcc, TransDepsMiss}
|
||||
],
|
||||
list.map(desc_cache_stat, StatTuples, DescStrs),
|
||||
string.append_list(DescStrs, DescsStr),
|
||||
@@ -457,11 +479,11 @@ record_make_deps_cache_stats(!IO) :-
|
||||
|
||||
:- pred desc_cache_stat({string, uint, uint}::in, string::out) is det.
|
||||
|
||||
desc_cache_stat({Name, Acc, Hit}, Desc) :-
|
||||
( if Acc = 0u, Hit = 0u then
|
||||
desc_cache_stat({Name, Acc, Miss}, Desc) :-
|
||||
( if Acc = 0u, Miss = 0u then
|
||||
Desc = ""
|
||||
else
|
||||
string.format("%-36s %12u %12u\n", [s(Name), u(Acc), u(Hit)], Desc)
|
||||
string.format("%-36s %12u %12u\n", [s(Name), u(Acc), u(Miss)], Desc)
|
||||
).
|
||||
|
||||
%---------------------------------------------------------------------------%
|
||||
|
||||
@@ -237,14 +237,14 @@
|
||||
module_to_module_set_cache.
|
||||
:- func make_info_get_direct_imports_intermod_cache(make_info) =
|
||||
module_to_module_set_cache.
|
||||
:- func make_info_get_indirect_imports_non_intermod_cache(make_info) =
|
||||
module_to_module_set_cache.
|
||||
% :- func make_info_get_indirect_imports_non_intermod_cache(make_info) =
|
||||
% module_to_module_set_cache.
|
||||
:- func make_info_get_indirect_imports_intermod_cache(make_info) =
|
||||
module_to_module_set_cache.
|
||||
:- func make_info_get_foreign_imports_non_intermod_trans_cache(make_info) =
|
||||
module_to_module_set_cache.
|
||||
:- func make_info_get_anc0_dir1_indir2_non_intermod_cache(make_info) =
|
||||
module_to_dep_file_set_cache.
|
||||
% :- func make_info_get_anc0_dir1_indir2_non_intermod_cache(make_info) =
|
||||
% module_to_dep_file_set_cache.
|
||||
:- func make_info_get_anc0_dir1_indir2_intermod_cache(make_info) =
|
||||
module_to_dep_file_set_cache.
|
||||
:- func make_info_get_trans_deps_cache(make_info) = trans_deps_cache.
|
||||
@@ -283,18 +283,18 @@
|
||||
:- pred make_info_set_direct_imports_intermod_cache(
|
||||
module_to_module_set_cache::in,
|
||||
make_info::in, make_info::out) is det.
|
||||
:- pred make_info_set_indirect_imports_non_intermod_cache(
|
||||
module_to_module_set_cache::in,
|
||||
make_info::in, make_info::out) is det.
|
||||
% :- pred make_info_set_indirect_imports_non_intermod_cache(
|
||||
% module_to_module_set_cache::in,
|
||||
% make_info::in, make_info::out) is det.
|
||||
:- pred make_info_set_indirect_imports_intermod_cache(
|
||||
module_to_module_set_cache::in,
|
||||
make_info::in, make_info::out) is det.
|
||||
:- pred make_info_set_foreign_imports_non_intermod_trans_cache(
|
||||
module_to_module_set_cache::in,
|
||||
make_info::in, make_info::out) is det.
|
||||
:- pred make_info_set_anc0_dir1_indir2_non_intermod_cache(
|
||||
module_to_dep_file_set_cache::in,
|
||||
make_info::in, make_info::out) is det.
|
||||
% :- pred make_info_set_anc0_dir1_indir2_non_intermod_cache(
|
||||
% module_to_dep_file_set_cache::in,
|
||||
% make_info::in, make_info::out) is det.
|
||||
:- pred make_info_set_anc0_dir1_indir2_intermod_cache(
|
||||
module_to_dep_file_set_cache::in,
|
||||
make_info::in, make_info::out) is det.
|
||||
@@ -418,8 +418,8 @@
|
||||
mki_direct_imports_intermod_cache
|
||||
:: module_to_module_set_cache,
|
||||
|
||||
mki_indirect_imports_non_intermod_cache
|
||||
:: module_to_module_set_cache,
|
||||
% mki_indirect_imports_non_intermod_cache
|
||||
% :: module_to_module_set_cache,
|
||||
mki_indirect_imports_intermod_cache
|
||||
:: module_to_module_set_cache,
|
||||
|
||||
@@ -428,10 +428,10 @@
|
||||
|
||||
% This cache holds dependency sets that are a simple
|
||||
% computation (union) on other dependency sets.
|
||||
% mki_anc0_dir1_indir2_non_intermod_cache
|
||||
% :: module_to_dep_file_set_cache,
|
||||
mki_anc0_dir1_indir2_intermod_cache
|
||||
:: module_to_dep_file_set_cache,
|
||||
mki_anc0_dir1_indir2_non_intermod_cache
|
||||
:: module_to_dep_file_set_cache,
|
||||
|
||||
% The boolean is `yes' if the result is complete.
|
||||
% XXX Use a better representation for the sets.
|
||||
@@ -468,10 +468,10 @@ init_make_info(OptionsVariables, DetectedGradeFlags, KeepGoing, OptionArgs,
|
||||
init_have_read_module_maps,
|
||||
init_module_to_module_set_cache,
|
||||
init_module_to_module_set_cache,
|
||||
% init_module_to_module_set_cache,
|
||||
init_module_to_module_set_cache,
|
||||
init_module_to_module_set_cache,
|
||||
init_module_to_module_set_cache,
|
||||
init_module_to_dep_file_set_cache,
|
||||
% init_module_to_dep_file_set_cache,
|
||||
init_module_to_dep_file_set_cache,
|
||||
init_trans_deps_cache
|
||||
).
|
||||
@@ -514,14 +514,14 @@ make_info_get_direct_imports_non_intermod_cache(Info) = X :-
|
||||
X = Info ^ mki_direct_imports_non_intermod_cache.
|
||||
make_info_get_direct_imports_intermod_cache(Info) = X :-
|
||||
X = Info ^ mki_direct_imports_intermod_cache.
|
||||
make_info_get_indirect_imports_non_intermod_cache(Info) = X :-
|
||||
X = Info ^ mki_indirect_imports_non_intermod_cache.
|
||||
% make_info_get_indirect_imports_non_intermod_cache(Info) = X :-
|
||||
% X = Info ^ mki_indirect_imports_non_intermod_cache.
|
||||
make_info_get_indirect_imports_intermod_cache(Info) = X :-
|
||||
X = Info ^ mki_indirect_imports_intermod_cache.
|
||||
make_info_get_foreign_imports_non_intermod_trans_cache(Info) = X :-
|
||||
X = Info ^ mki_foreign_imports_non_intermod_trans_cache.
|
||||
make_info_get_anc0_dir1_indir2_non_intermod_cache(Info) = X :-
|
||||
X = Info ^ mki_anc0_dir1_indir2_non_intermod_cache.
|
||||
% make_info_get_anc0_dir1_indir2_non_intermod_cache(Info) = X :-
|
||||
% X = Info ^ mki_anc0_dir1_indir2_non_intermod_cache.
|
||||
make_info_get_anc0_dir1_indir2_intermod_cache(Info) = X :-
|
||||
X = Info ^ mki_anc0_dir1_indir2_intermod_cache.
|
||||
make_info_get_trans_deps_cache(Info) = X :-
|
||||
@@ -557,14 +557,14 @@ make_info_set_direct_imports_non_intermod_cache(X, !Info) :-
|
||||
!Info ^ mki_direct_imports_non_intermod_cache := X.
|
||||
make_info_set_direct_imports_intermod_cache(X, !Info) :-
|
||||
!Info ^ mki_direct_imports_intermod_cache := X.
|
||||
make_info_set_indirect_imports_non_intermod_cache(X, !Info) :-
|
||||
!Info ^ mki_indirect_imports_non_intermod_cache := X.
|
||||
% make_info_set_indirect_imports_non_intermod_cache(X, !Info) :-
|
||||
% !Info ^ mki_indirect_imports_non_intermod_cache := X.
|
||||
make_info_set_indirect_imports_intermod_cache(X, !Info) :-
|
||||
!Info ^ mki_indirect_imports_intermod_cache := X.
|
||||
make_info_set_foreign_imports_non_intermod_trans_cache(X, !Info) :-
|
||||
!Info ^ mki_foreign_imports_non_intermod_trans_cache := X.
|
||||
make_info_set_anc0_dir1_indir2_non_intermod_cache(X, !Info) :-
|
||||
!Info ^ mki_anc0_dir1_indir2_non_intermod_cache := X.
|
||||
% make_info_set_anc0_dir1_indir2_non_intermod_cache(X, !Info) :-
|
||||
% !Info ^ mki_anc0_dir1_indir2_non_intermod_cache := X.
|
||||
make_info_set_anc0_dir1_indir2_intermod_cache(X, !Info) :-
|
||||
!Info ^ mki_anc0_dir1_indir2_intermod_cache := X.
|
||||
make_info_set_trans_deps_cache(X, !Info) :-
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
NF == 3 {
|
||||
cache = $1;
|
||||
cur_lookups = $2;
|
||||
cur_hits = $3;
|
||||
cur_misses = cur_lookups - cur_hits;
|
||||
cur_misses = $3;
|
||||
cur_hits = cur_lookups - cur_misses;
|
||||
|
||||
caches[cache] += 1;
|
||||
lookups[cache] += cur_lookups;
|
||||
hits[cache] += cur_hits;
|
||||
misses[cache] += cur_misses;
|
||||
hits[cache] += cur_hits;
|
||||
|
||||
overall_lookups += cur_lookups;
|
||||
overall_hits += cur_hits;
|
||||
@@ -32,11 +32,12 @@ END {
|
||||
|
||||
printf "----------------------------------------------------------\n\n";
|
||||
|
||||
printf "%-36s %10s %10s %6s\n\n",
|
||||
"cache", "#exec", "#lookup", "hit%";
|
||||
printf "%-30s %6s %8s %8s %8s %6s\n\n",
|
||||
"cache", "#exec", "#lookup", "#hit", "#miss", "hit%";
|
||||
for (cache in caches) {
|
||||
hit_rate[cache] = (100 * hits[cache]) / lookups[cache];
|
||||
printf "%-36s %10d %10d %6.2f\n",
|
||||
cache, caches[cache], lookups[cache], hit_rate[cache];
|
||||
printf "%-30s %6d %8d %8d %8d %6.2f\n",
|
||||
cache, caches[cache], lookups[cache],
|
||||
hits[cache], misses[cache], hit_rate[cache];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user