projects
/
tatoo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a new option to choose tree model at runtime.
[tatoo.git]
/
src
/
tatoo.ml
diff --git
a/src/tatoo.ml
b/src/tatoo.ml
index
e0f29ee
..
5e8144d
100644
(file)
--- a/
src/tatoo.ml
+++ b/
src/tatoo.ml
@@
-14,6
+14,13
@@
(***********************************************************************)
open Format
(***********************************************************************)
open Format
+let default_gc = Gc.get()
+let tuned_gc = { default_gc with
+ Gc.minor_heap_size = 32*1024*1024;
+ Gc.major_heap_increment = 8*1024*1024;
+ Gc.max_overhead = 1000000;
+ Gc.space_overhead = 100;
+}
let time f arg msg =
let t1 = Unix.gettimeofday () in
let time f arg msg =
let t1 = Unix.gettimeofday () in
@@
-44,15
+51,27
@@
let restart_sequential run auto_list tree nodes () =
let main () =
let () = Options.parse () in
let main () =
let () = Options.parse () in
+ let tree_model = List.assoc !Options.tree_model
+ Options.supported_models
+ in
+ let module T = (val tree_model) in
+ let module Runtime = Run.Make(T)
+ in
+
let doc =
let fd, close_fd = match !Options.input_file with
None | Some "-" | Some "/dev/stdin" -> stdin, ignore
| Some input ->
let fd = open_in input in fd, fun () -> close_in fd
in
let doc =
let fd, close_fd = match !Options.input_file with
None | Some "-" | Some "/dev/stdin" -> stdin, ignore
| Some input ->
let fd = open_in input in fd, fun () -> close_in fd
in
- let d = time
Naive_t
ree.load_xml_file fd "parsing xml document" in
+ let d = time
Runtime.T
ree.load_xml_file fd "parsing xml document" in
close_fd (); d
in
close_fd (); d
in
+ let () =
+ Gc.full_major();
+ Gc.compact();
+ Gc.set (tuned_gc)
+ in
let queries =
time
(fun l ->
let queries =
time
(fun l ->
@@
-104,30
+123,29
@@
let main () =
Logger.msg `STATS "@[Automaton: @\n%a@]" Ata.print auto) auto_list;
end;
Logger.msg `STATS "@[Automaton: @\n%a@]" Ata.print auto) auto_list;
end;
- let module Naive = Run.Make(Naive_tree)(Naive_node_list) in
let result_list =
let result_list =
- let root =
Naive_node_lis
t.create () in
- let () =
Naive_node_list.add (Naive_t
ree.root doc) root in
+ let root =
Runtime.ResultSe
t.create () in
+ let () =
Runtime.ResultSet.add (Runtime.T
ree.root doc) root in
let f, msg =
match !Options.parallel, !Options.compose with
true, true ->
let f, msg =
match !Options.parallel, !Options.compose with
true, true ->
- compose_parallel
Naiv
e.eval auto_list doc root, "parallel/compose"
+ compose_parallel
Runtim
e.eval auto_list doc root, "parallel/compose"
| true, false ->
| true, false ->
- restart_parallel
Naiv
e.full_eval auto_list doc root, "parallel/restart"
+ restart_parallel
Runtim
e.full_eval auto_list doc root, "parallel/restart"
| false, true ->
| false, true ->
- compose_sequential
Naiv
e.eval auto_list doc root , "sequential/compose"
+ compose_sequential
Runtim
e.eval auto_list doc root , "sequential/compose"
| false, false ->
| false, false ->
- restart_sequential
Naiv
e.eval auto_list doc root, "sequential/restart"
+ restart_sequential
Runtim
e.eval auto_list doc root, "sequential/restart"
in
time f () ("evaluating query in " ^ msg ^ " mode")
in
in
time f () ("evaluating query in " ^ msg ^ " mode")
in
- let s =
Naiv
e.stats () in
+ let s =
Runtim
e.stats () in
Run.(
Logger.msg `STATS
Run.(
Logger.msg `STATS
- "@[tree size: %d@\ntraversals: %d@\ntransition fetch cache
hit ratio: %f@\ntransition eval cache hit
ratio: %f@\nNumber of visited nodes per pass: %a@]"
+ "@[tree size: %d@\ntraversals: %d@\ntransition fetch cache
miss ratio: %f@\ntransition eval cache miss
ratio: %f@\nNumber of visited nodes per pass: %a@]"
s.tree_size s.pass
s.tree_size s.pass
- (float s.fetch_trans_cache_
hit
/. float s.fetch_trans_cache_access)
- (float s.eval_trans_cache_
hit
/. float s.eval_trans_cache_access)
+ (float s.fetch_trans_cache_
miss
/. float s.fetch_trans_cache_access)
+ (float s.eval_trans_cache_
miss
/. float s.eval_trans_cache_access)
(let i = ref 0 in
Pretty.print_list ~sep:"," (fun fmt n -> Format.fprintf fmt "%i: %i" !i n;incr i))
s.nodes_per_run);
(let i = ref 0 in
Pretty.print_list ~sep:"," (fun fmt n -> Format.fprintf fmt "%i: %i" !i n;incr i))
s.nodes_per_run);
@@
-138,11
+156,11
@@
let main () =
output_string output (string_of_int !count);
output_string output "\" >\n";
if !Options.count then begin
output_string output (string_of_int !count);
output_string output "\" >\n";
if !Options.count then begin
- output_string output (string_of_int (
Naive_node_lis
t.length results));
+ output_string output (string_of_int (
Runtime.ResultSe
t.length results));
output_char output '\n';
end else
output_char output '\n';
end else
-
Naive_node_lis
t.iter (fun n ->
-
Naive_t
ree.print_xml output doc n;
+
Runtime.ResultSe
t.iter (fun n ->
+
Runtime.T
ree.print_xml output doc n;
output_char output '\n'
) results;
output_string output "</xml_result>\n";
output_char output '\n'
) results;
output_string output "</xml_result>\n";
@@
-166,4
+184,6
@@
let () =
Some s -> ("file " ^ s)
| None -> "[stdin]") msg; exit 3
| Xpath.Ulexer.Error (s, e, msg) -> eprintf "Error: character %i-%i: %s\n%!" s e msg; exit 4
Some s -> ("file " ^ s)
| None -> "[stdin]") msg; exit 3
| Xpath.Ulexer.Error (s, e, msg) -> eprintf "Error: character %i-%i: %s\n%!" s e msg; exit 4
- | e -> eprintf "FATAL ERROR: %s\n%!" (Printexc.to_string e); exit 128
+(* | e -> Printexc.print_backtrace stderr;
+ flush stderr;
+ eprintf "FATAL ERROR: %s\n%!" (Printexc.to_string e); exit 128 *)