X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Ftatoo.ml;h=2b901d47480314c8fc9b9b8b617b37c5ca7c86e1;hb=f2507a58487ba57bbbd7831588523f4577389431;hp=5dec2f69a7b72ed4bc5f40cc68c32ad0e91f57e2;hpb=f41ff8d936d971eb0712e458826f6555b83746da;p=tatoo.git diff --git a/src/tatoo.ml b/src/tatoo.ml index 5dec2f6..2b901d4 100644 --- a/src/tatoo.ml +++ b/src/tatoo.ml @@ -14,6 +14,13 @@ (***********************************************************************) 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 @@ -44,15 +51,35 @@ let restart_sequential run auto_list tree nodes () = 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 d = time Compact_tree.load_xml_file fd "parsing xml document" in + let d = time Runtime.Tree.load_xml_file fd "parsing xml document" in close_fd (); d in + let () = + Gc.full_major(); + Gc.compact(); + Gc.set (tuned_gc) + in + let () = + let rec loop node = if node == Runtime.Tree.nil then () else + let i = Runtime.Tree.preorder doc node in + let () = loop (Runtime.Tree.first_child doc node) in + loop (Runtime.Tree.next_sibling doc node) + in + time loop (Runtime.Tree.root doc) "calibrating full traversal" + in let queries = time (fun l -> @@ -104,24 +131,23 @@ let main () = Logger.msg `STATS "@[Automaton: @\n%a@]" Ata.print auto) auto_list; end; - let module Naive = Run.Make(Compact_tree)(Compact_node_list) in let result_list = - let root = Compact_node_list.create () in - let () = Compact_node_list.add (Compact_tree.root doc) root in + let root = Runtime.ResultSet.create () in + let () = Runtime.ResultSet.add (Runtime.Tree.root doc) root in let f, msg = match !Options.parallel, !Options.compose with true, true -> - compose_parallel Naive.eval auto_list doc root, "parallel/compose" + compose_parallel Runtime.eval auto_list doc root, "parallel/compose" | true, false -> - restart_parallel Naive.full_eval auto_list doc root, "parallel/restart" + restart_parallel Runtime.full_eval auto_list doc root, "parallel/restart" | false, true -> - compose_sequential Naive.eval auto_list doc root , "sequential/compose" + compose_sequential Runtime.eval auto_list doc root , "sequential/compose" | false, false -> - restart_sequential Naive.eval auto_list doc root, "sequential/restart" + restart_sequential Runtime.eval auto_list doc root, "sequential/restart" in time f () ("evaluating query in " ^ msg ^ " mode") in - let s = Naive.stats () in + let s = Runtime.stats () in Run.( Logger.msg `STATS "@[tree size: %d@\ntraversals: %d@\ntransition fetch cache miss ratio: %f@\ntransition eval cache miss ratio: %f@\nNumber of visited nodes per pass: %a@]" @@ -138,11 +164,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 (Compact_node_list.length results)); + output_string output (string_of_int (Runtime.ResultSet.length results)); output_char output '\n'; end else - Compact_node_list.iter (fun n -> - Compact_tree.print_xml output doc n; + Runtime.ResultSet.iter (fun n -> + Runtime.Tree.print_xml output doc n; output_char output '\n' ) results; output_string output "\n";