pgraph, lang: funcs: dage: Add an awkward graphviz interface
This refactors the code to make it not depend on the specific engine.
This commit is contained in:
@@ -1451,10 +1451,10 @@ func (obj *Engine) Stats() string {
|
|||||||
return obj.stats.String()
|
return obj.stats.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Graphviz writes out the diagram of a graph to be used for visualization and
|
// ExecGraphviz writes out the diagram of a graph to be used for visualization
|
||||||
// debugging. You must not modify the graph (eg: during Lock) when calling this
|
// and debugging. You must not modify the graph (eg: during Lock) when calling
|
||||||
// method.
|
// this method.
|
||||||
func (obj *Engine) Graphviz(dir string) error {
|
func (obj *Engine) ExecGraphviz(dir string) error {
|
||||||
// XXX: would this deadlock if we added this?
|
// XXX: would this deadlock if we added this?
|
||||||
//obj.graphMutex.Lock() // XXX: should this be a RLock?
|
//obj.graphMutex.Lock() // XXX: should this be a RLock?
|
||||||
//defer obj.graphMutex.Unlock() // XXX: should this be an RUnlock?
|
//defer obj.graphMutex.Unlock() // XXX: should this be an RUnlock?
|
||||||
|
|||||||
@@ -498,12 +498,12 @@ func (obj *graphTxn) commit() error {
|
|||||||
|
|
||||||
// XXX: running this on each commit has a huge performance hit.
|
// XXX: running this on each commit has a huge performance hit.
|
||||||
// XXX: we could write out the .dot files and run graphviz afterwards
|
// XXX: we could write out the .dot files and run graphviz afterwards
|
||||||
if engine, ok := obj.GraphAPI.(*Engine); ok && GraphvizDebug {
|
if g, ok := obj.GraphAPI.(pgraph.Graphvizable); ok && GraphvizDebug {
|
||||||
//d := time.Now().Unix()
|
//d := time.Now().Unix()
|
||||||
//if err := engine.graph.ExecGraphviz(fmt.Sprintf("/tmp/txn-graphviz-%d.dot", d)); err != nil {
|
//if err := g.ExecGraphviz(fmt.Sprintf("/tmp/txn-graphviz-%d.dot", d)); err != nil {
|
||||||
// panic("no graphviz")
|
// panic("no graphviz")
|
||||||
//}
|
//}
|
||||||
if err := engine.Graphviz(""); err != nil {
|
if err := g.ExecGraphviz(""); err != nil {
|
||||||
panic(err) // XXX: improve me
|
panic(err) // XXX: improve me
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,23 @@ const (
|
|||||||
ptrLabelsSize = 10
|
ptrLabelsSize = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Graphvizable is a simple interface to handle the common signature for this
|
||||||
|
// useful graphviz exec method that is used in debugging. Expect that this
|
||||||
|
// signature might change if the authors find a different variant more useful.
|
||||||
|
type Graphvizable interface {
|
||||||
|
|
||||||
|
// ExecGraphviz runs graphviz and stores the result at this absolute
|
||||||
|
// path. It (awkwardly) can be used by someone expecting either a
|
||||||
|
// filename, or a directory. The filename scenario should be used if you
|
||||||
|
// are expecting a single .dot output file. The directory scenario
|
||||||
|
// should be used if you are expecting a series of .dot graphs.
|
||||||
|
// Directories must end with a trailing slash. A filename passed will
|
||||||
|
// get this location overwritten if there is something already there. If
|
||||||
|
// the string is empty, it might create a file in a temporary directory
|
||||||
|
// somewhere.
|
||||||
|
ExecGraphviz(filename string) error
|
||||||
|
}
|
||||||
|
|
||||||
// Graphviz adds some visualization features for pgraph.
|
// Graphviz adds some visualization features for pgraph.
|
||||||
type Graphviz struct {
|
type Graphviz struct {
|
||||||
// Name is the display name of the graph. If specified it overrides an
|
// Name is the display name of the graph. If specified it overrides an
|
||||||
|
|||||||
Reference in New Issue
Block a user