Skip to content

Add dgggen tool to generate production-shaped call graphs#166

Merged
andrewh merged 2 commits into
mainfrom
claude/gracious-curie-c0gnj8
Jun 12, 2026
Merged

Add dgggen tool to generate production-shaped call graphs#166
andrewh merged 2 commits into
mainfrom
claude/gracious-curie-c0gnj8

Conversation

@andrewh

@andrewh andrewh commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Adds dgggen, a new tool that generates synthetic DGG-format call graphs with shape distributions matching production measurements from the Du et al. paper on Alibaba microservice traces. This enables stress testing with realistic graph topologies that reach the tail of the distribution (depths 15+, hundreds of nodes, high fan-out).

Key Changes

  • New tool: tools/dgggen/main.go — Generates deterministic, stratified call graphs with:

    • Heavy-tailed graph sizes (3-450 nodes) and depths (1-20 levels)
    • Hub services with fan-out up to 50 and effective fan-out up to 500
    • Repeated calls with multiplicities reaching hundreds on leaf edges
    • Service type distribution (normal, Memcached, blackhole, relay) matching production
    • Multiple interfaces per service (~49% reuse) via function suffixes
    • Span count clamping to stay under motel's limits while covering the tail
  • Test suite: tools/dgggen/main_test.go — Validates:

    • Deterministic output for a given seed
    • Graph structural validity (no duplicate nodes/edges, proper tree structure)
    • Span and fan-out bounds enforcement
    • Corpus covers production tail (depths 15+, 150+ nodes, 500+ spans)
  • Documentation: docs/demos/demo-dgg.md — Added section showing:

    • How to generate and convert a 100-graph corpus
    • Example output demonstrating production-scale characteristics
    • Distribution analysis reaching depth 18, fan-out 460, 4000+ spans
  • Test infrastructure: tools/dgg2motel/test_corpus.sh — Enhanced to support:

    • CHECK_ARGS environment variable for passing custom motel check flags
    • Allows testing with raised limits for production-shaped graphs

Implementation Details

  • Uses weighted bucket sampling to oversample the distribution tail while keeping corpus size manageable
  • Builds graphs as trees with a guaranteed-depth spine plus preferential-attachment bias for hub formation
  • Clamps multiplicities at two levels: per-node effective fan-out and global static span count
  • Generates deterministic node names with DGG conventions (MS_* prefixes, _funcN suffixes for reuse)
  • Outputs valid DGG JSON consumable by existing dgg2motel converter

https://claude.ai/code/session_014HnMuCVwwmEnBBfPRsERfn

The DGG sample corpus tops out at depth 4 and 11 spans per trace, well
short of the depths of 15+ and hundreds of spans the Du et al. paper
reports for Alibaba production traces. dgggen generates DGG-format JSON
graphs with those production shape distributions: heavy-tailed sizes up
to 450 nodes, depths to 20, hub fan-out, and repeated-call
multiplicities into the hundreds, stratified to cover the tail in a
small corpus. Output is deterministic per seed and feeds the existing
dgg2motel and test_corpus.sh pipeline; test_corpus.sh gains CHECK_ARGS
for raising motel check limits.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Go tool (dgggen) to generate deterministic, production-shaped DGG JSON call graphs (heavy-tailed depth/size/fan-out), plus tests and documentation to enable stress-testing motel with more realistic topology distributions.

Changes:

  • Add tools/dgggen generator that builds stratified, tail-covering tree-shaped DGG graphs and writes them to disk.
  • Add a test suite validating determinism, structural validity, and span/fan-out bounds.
  • Update demo docs and tools/dgg2motel/test_corpus.sh to support raised motel check limits via CHECK_ARGS.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tools/dgggen/main.go New DGG corpus generator with production-shaped distributions and bounding logic
tools/dgggen/main_test.go Tests for determinism, graph validity, and bound enforcement
tools/dgg2motel/test_corpus.sh Adds CHECK_ARGS passthrough to motel check for larger graphs
docs/demos/demo-dgg.md Documents how to generate and validate a production-shaped corpus

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/dgggen/main.go
Comment on lines +330 to +337
walk = func(n *genNode) {
if len(n.children) == 0 && (largest == nil || n.mult > largest.mult) {
largest = n
}
for _, c := range n.children {
walk(c)
}
}
Comment thread tools/dgg2motel/test_corpus.sh Outdated
Comment on lines 14 to 16
RATE="${RATE:-}" # override traffic rate if set
CHECK_ARGS="${CHECK_ARGS:-}" # extra flags for motel check, e.g. "--max-depth 25"

Comment thread tools/dgg2motel/test_corpus.sh Outdated
Comment on lines +46 to +50
# shellcheck disable=SC2086
if ! "$MOTEL" check $CHECK_ARGS "$f" > /dev/null 2>&1; then
echo "CHECK FAIL: $rel"
"$MOTEL" check "$f" 2>&1 | sed 's/^/ /'
# shellcheck disable=SC2086
"$MOTEL" check $CHECK_ARGS "$f" 2>&1 | sed 's/^/ /'
clampSpans only targeted leaf nodes, but assignMultiplicities can set
mult=2 on interior nodes. An interior mult multiplies the entire subtree,
so a deep spine with an interior mult could keep staticSpans above
maxStaticSpans even after all leaf mults reached 1. Fix: walk all nodes
with mult > 1, not just leaves.

Replace unquoted $CHECK_ARGS expansion in test_corpus.sh with a read -ra
array to avoid word-splitting and glob expansion at the call sites.
@andrewh
andrewh merged commit 45f21bb into main Jun 12, 2026
2 checks passed
@andrewh
andrewh deleted the claude/gracious-curie-c0gnj8 branch June 12, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants