Artifact 108eb140ec4f858b5d12d616419e7f3d106e45a5
File tools/cvs2fossil/lib/c2f_prtopsort.tcl part of check-in [00bf8c198e] - The performance was still not satisfying, even with faster recomputing of successors. Doing it multiple times (Building the graph in each breaker and sort passes) eats time. Caching in memory blows the memory. Chosen solution: Cache this information in the database.Created a new pass 'CsetDeps' which is run between 'InitCsets' and 'BreakRevCsetCycles' (i.e. changeset creation and first breaker pass). It computes the changeset dependencies from the file-level dependencies once and saves the result in the state, in the new table 'cssuccessor'. Now the breaker and sort passes can get the information quickly, with virtually no effort. The dependencies are recomputed incrementally when a changeset is split by one of the breaker passes, for its fragments and its predecessors.
The loop check is now trivial, and integrated into the successor computation, with the heavy lifting for the detailed analysis and reporting moved down into the type-dependent SQL queries. The relevant new method is 'loops'. Now that the loop check is incremental the pass based checks have been removed from the integrity module, and the option '--loopcheck' has been eliminated. For paranoia the graph setup and modification code got its loop check reinstated as an assert, redusing the changeset report code.
Renumbered the breaker and sort passes. A number of places, like graph setup and traversal, loading of changesets, etc. got feedback indicators to show their progress.
The selection of revision and symbol changesets for the associated breaker passes was a bit on the slow side. We now keep changeset lists sorted by type (during loading or general construction) and access them directly.
by aku on 2007-12-02 20:04:40.
## -*- tcl -*- # # ## ### ##### ######## ############# ##################### ## Copyright (c) 2007 Andreas Kupries. # # This software is licensed as described in the file LICENSE, which # you should have received as part of this distribution. # # This software consists of voluntary contributions made by many # individuals. For exact contribution history, see the revision # history and logs, available at http://fossil-scm.hwaci.com/fossil # # ## ### ##### ######## ############# ##################### ## Pass VIII. This pass goes over the set of revision based changesets ## and sorts them topologically. It assumes that there are no cycles ## which could impede it, any having been broken by the previous pass, ## and aborts if that condition doesn't hold. # # ## ### ##### ######## ############# ##################### ## Requirements package require Tcl 8.4 ; # Required runtime. package require snit ; # OO system. package require struct::list ; # Higher order list operations. package require vc::tools::log ; # User feedback. package require vc::fossil::import::cvs::cyclebreaker ; # Breaking dependency cycles. package require vc::fossil::import::cvs::state ; # State storage. package require vc::fossil::import::cvs::project::rev ; # Project level changesets # # ## ### ##### ######## ############# ##################### ## Register the pass with the management vc::fossil::import::cvs::pass define \ RevTopologicalSort \ {Topologically Sort Revision ChangeSets} \ ::vc::fossil::import::cvs::pass::rtopsort # # ## ### ##### ######## ############# ##################### ## snit::type ::vc::fossil::import::cvs::pass::rtopsort { # # ## ### ##### ######## ############# ## Public API typemethod setup {} { # Define the names and structure of the persistent state of # this pass. state reading revision state reading changeset state reading csitem state writing csorder { -- Commit order of the revision changesets based on their -- dependencies cid INTEGER NOT NULL REFERENCES changeset, pos INTEGER NOT NULL, UNIQUE (cid), UNIQUE (pos) } return } typemethod load {} { # Pass manager interface. Executed to load data computed by # this pass into memory when this pass is skipped instead of # executed. state reading changeset project::rev loadcounter return } typemethod run {} { # Pass manager interface. Executed to perform the # functionality of the pass. set len [string length [project::rev num]] set myatfmt %${len}s incr len 12 set mycsfmt %${len}s cyclebreaker savecmd [myproc SaveOrder] state transaction { cyclebreaker run tsort-rev [myproc Changesets] } return } typemethod discard {} { # Pass manager interface. Executed for all passes after the # run passes, to remove all data of this pass from the state, # as being out of date. state discard csorder return } # # ## ### ##### ######## ############# ## Internal methods proc Changesets {} { log write 2 breakscycle {Selecting the revision changesets} return [project::rev rev] } proc SaveOrder {graph at cset} { ::variable myatfmt ::variable mycsfmt set cid [$cset id] log write 4 rtopsort "Changeset @ [format $myatfmt $at]: [format $mycsfmt [$cset str]] <<[FormatTR $graph $cset]>>" state run { INSERT INTO csorder (cid, pos) VALUES ($cid, $at) } return } proc FormatTR {graph cset} { return [join [struct::list map [$graph node set $cset timerange] {clock format}] { -- }] } typevariable myatfmt ; # Format for log output to gain better alignment of the various columns. typevariable mycsfmt ; # Ditto for the changesets. # # ## ### ##### ######## ############# ## Configuration pragma -hasinstances no ; # singleton pragma -hastypeinfo no ; # no introspection pragma -hastypedestroy no ; # immortal # # ## ### ##### ######## ############# } namespace eval ::vc::fossil::import::cvs::pass { namespace export rtopsort namespace eval rtopsort { namespace import ::vc::fossil::import::cvs::cyclebreaker namespace import ::vc::fossil::import::cvs::state namespace eval project { namespace import ::vc::fossil::import::cvs::project::rev } namespace import ::vc::tools::log log register rtopsort } } # # ## ### ##### ######## ############# ##################### ## Ready package provide vc::fossil::import::cvs::pass::rtopsort 1.0 return