RFC-0001: PerfettoSQL Standard Library Documentation Enhancement #3103
LalitMaganti
started this conversation in
Team Design Discussions
Replies: 4 comments
-
📝 RFC Document Updated View changes: [Commit History](https://github.com/google/perfetto/commits/rfcs/0001-stdlib-doc-enhancements copy.md) |
Beta Was this translation helpful? Give feedback.
0 replies
-
📝 RFC Document Updated View changes: Commit History |
Beta Was this translation helpful? Give feedback.
0 replies
-
📝 RFC Document Updated View changes: Commit History |
Beta Was this translation helpful? Give feedback.
0 replies
-
📝 RFC Document Updated View changes: Commit History |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
📄 RFC Doc: 0001-stdlib-doc-enhancements.md
PerfettoSQL Standard Library Documentation Enhancement
Authors: @LalitMaganti
Status: Draft
Overview
This document outlines the comprehensive enhancement plan for PerfettoSQL
standard library documentation generation. The goal is to transform the current
basic documentation into rich, navigable documentation with visual diagrams,
proper module organization, and better structure.
Current State Analysis
Existing Scripts
tools/gen_stdlib_docs_json.py
- Parses SQL files and generates JSON docsusing
python.generators.sql_processing.docs_parse
infra/perfetto.dev/src/gen_stdlib_docs_md.py
- Converts JSON to markdownwith basic table formatting
infra/perfetto.dev/src/gen_sql_tables_reference.js
- Contains mermaiddiagram generation for table relationships (reference for our implementation)
Current Problems
prelude tables, 50+ android tables, etc.) is crammed into one massive page,
making it difficult to navigate and slow to load. Need Rust-style
documentation with global list + per-module pages.
android
with >50tables produce tiny, illegible mermaid diagrams. Diagrams need to be scoped
to individual modules or broken into focused subgraphs.
different packages connect (e.g., Android tables linking to prelude's
process/thread tables via JOINID).
how stdlib tables connect via
JOINID(table.column)
relationships (within amodule).
without logical grouping
and relationships
prelude/after_eof/tables_views.sql
contains 32 tables in one file
Enhancement Goals
Primary Objectives
tables connect through joins
modules
Success Criteria
Implementation Plan
IMPORTANT: Phase 2 (Multi-page Documentation) must be completed BEFORE Phase
3 (Mermaid Diagrams) to avoid creating unusable single-page diagrams.
Phase 1: Foundation & Refactoring (Dependencies First)
Status: Completed
Task 1.1: Reorganize Prelude Module Structure
Files:
src/trace_processor/perfetto_sql/stdlib/prelude/after_eof/
Priority: High (blocks other improvements) Dependencies: None
Break up the monolithic
tables_views.sql
(32 tables) into focused modules:core.sql
- Fundamental trace conceptstrace_metrics
,trace_bounds
cpu_scheduling.sql
- CPU and scheduling datacpu
,cpu_available_frequencies
,sched_slice
,sched
,thread_state
,cpu_track
tracks.sql
- Track infrastructuretrack
,thread_track
,process_track
,gpu_track
(deprecated)counters.sql
- Performance counters and trackscounter_track
,counters
, all*_counter_track
variantsevents.sql
- Event data and slicesftrace_event
,frame_slice
,gpu_slice
, timeline slices,raw
(deprecated)
memory.sql
- Memory and heap analysisheap_graph_*
tables,memory_snapshot*
tablesImplementation Steps:
-- @module
documentationtables_views.sql
to appropriate modulesBUILD.gn
dependenciestables_views.sql
to include new modules9df0833e9e - tp: reorganize prelude into focused modules
Task 1.2: Add Module Documentation Support to Parser
Files:
tools/gen_stdlib_docs_json.py
,python/generators/sql_processing/docs_parse.py
Priority: High (enablesmodule organization) Dependencies: Task 1.1
Extend SQL parsing to extract module-level documentation:
Module Documentation Syntax:
Implementation Steps:
docs_parse.py
to recognize-- @module
commentsgen_stdlib_docs_json.py
to include module metadata in outputc324ab46cb - tp: add module documentation support to stdlib parser
Phase 2: Multi-Page Documentation Structure
Status: Not Started Priority: CRITICAL - Must complete before Phase 3
(Mermaid Diagrams)
Rationale
The single-page documentation approach has several critical issues:
Task 2.1: Design Multi-Page Documentation Structure
Files: Design document,
infra/perfetto.dev/BUILD.gn
(new targets)Priority: Critical (blocks diagram work) Dependencies: Phase 1 complete
Current Build Process:
gen_stdlib_docs_json.py
→stdlib_docs.json
gen_stdlib_docs_md.py
→stdlib_docs.md
(single file)md_to_html
→docs/analysis/stdlib-docs
(single HTML)Proposed Structure (Rust-style):
URL Examples:
/docs/analysis/sql-tables/
→ Global index/docs/analysis/sql-tables/prelude/
→ Prelude package index/docs/analysis/sql-tables/prelude/core
→ Core module details/docs/analysis/sql-tables/android/startup
→ Android startup modulePage Types:
Global Index (
sql-tables/index
)Package Index (
sql-tables/{package}/index
)Module Detail (
sql-tables/{package}/{module}
)@module
docs)Build System Changes:
Backward Compatibility:
/docs/analysis/stdlib-docs
URL active/docs/analysis/sql-tables/
(global index)Implementation Steps:
Task 2.2: Implement Multi-Page Documentation Generator
Files:
infra/perfetto.dev/src/gen_stdlib_docs_md.py
,infra/perfetto.dev/BUILD.gn
Priority: Critical Dependencies: Task 2.1Implementation Steps:
gen_stdlib_docs_md.py
to support multi-page outputgit add . && git commit -m "tp: implement multi-page stdlib documentation"
Task 2.3: Update Documentation Site Integration
Files:
infra/perfetto.dev/
site templates and configuration Priority:High Dependencies: Task 2.2
Implementation Steps:
git add . && git commit -m "tp: integrate multi-page stdlib docs into site"
Phase 3: Mermaid Diagram Integration
Status: Blocked (waiting for Phase 2 completion)
Task 3.1: Port Table Relationship Logic to Python
Files:
tools/stdlib_mermaid_generator.py
(new),infra/perfetto.dev/src/gen_stdlib_docs_md.py
Priority: High (core visualenhancement) Dependencies: Phase 1 complete
Port the mermaid diagram generation from
gen_sql_tables_reference.js
toPython:
Reference Implementation:
infra/perfetto.dev/src/gen_sql_tables_reference.js:113-149
Key Components:
JOINID(table.column)
relationships from JSON data (already extractedby
_long_type_to_table()
)Implementation Steps:
tools/stdlib_mermaid_generator.py
with relationship parsinggit add . && git commit -m "tp: add mermaid diagram generation for stdlib tables"
Task 2.2: Integrate Mermaid Generation into Markdown Output
Files:
infra/perfetto.dev/src/gen_stdlib_docs_md.py
Priority: High(user-facing improvement) Dependencies: Task 2.1
Enhance markdown generation to include mermaid diagrams:
Diagram Types:
Implementation Steps:
ModuleMd
classPackageMd
to include package-level diagramsgit add . && git commit -m "tp: integrate table relationship diagrams into docs"
Phase 3: Enhanced Documentation Structure
Status: Not Started
Task 3.1: Improve Prelude Organization in Docs
Files:
infra/perfetto.dev/src/gen_stdlib_docs_md.py
Priority: Medium(improves user experience) Dependencies: Phase 1 and 2 complete
Transform prelude from flat lists to organized modules:
Current Prelude Output:
Enhanced Prelude Output:
Implementation Steps:
PackageMd.get_prelude_description()
to organize by modulesinstead of flat lists
git add . && git commit -m "tp: improve prelude organization in generated docs"
Task 3.2: Enhanced Formatting and Navigation
Files:
infra/perfetto.dev/src/gen_stdlib_docs_md.py
Priority: Medium(polish and usability) Dependencies: Phases 1-2 complete
Improve overall documentation formatting and navigation:
Enhancements:
Implementation Steps:
_md_table_header()
_md_rolldown()
git add . && git commit -m "tp: enhance stdlib docs formatting and navigation"
Phase 4: Testing and Validation
Status: Not Started
Task 4.1: Comprehensive Testing
Files: All modified files Priority: High (ensure quality)
Dependencies: All previous phases
Testing Areas:
reorganization
Task 4.2: Documentation and Examples
Files: Documentation, examples Priority: Medium (maintenance and
adoption) Dependencies: Task 4.1
Deliverables:
Progress Tracking
Phase 1 Progress: 0/2 tasks complete
Phase 2 Progress: 0/2 tasks complete
Phase 3 Progress: 0/2 tasks complete
Phase 4 Progress: 0/2 tasks complete
Key Implementation Notes
Maintaining Backward Compatibility
reorganization
existing fields)
Performance Considerations
Code Quality Standards
Future Enhancements (Out of Scope)
Potential Follow-up Work
Git Workflow and CL Stacking
Branch Strategy
Use
git new-branch --current-parent <branch-name>
to create a proper CL stackfor review:
Commit Points
Each task should result in a separate commit/CL:
tp: reorganize prelude into focused modules
tp: add module documentation support to stdlib parser
tp: add mermaid diagram generation for stdlib tables
tp: integrate table relationship diagrams into docs
tp: improve prelude organization in generated docs
tp: enhance stdlib docs formatting and navigation
Testing and Validation
Before each commit:
Usage Instructions for Incremental Implementation
depend on
git new-branch --current-parent
for eachtask
state
blockers
This design document should be treated as a living specification that evolves
with implementation learnings.
Implementation Status and Findings (as of 2025-10-09)
Completed Work
Branch:
dev/lalitm/stdlib-docs-mermaid-generation
Completed Commits:
9df0833e9e
- tp: reorganize prelude into focused modulesc324ab46cb
- tp: add module documentation support to stdlib parsere9ca2a4121
- tp: add mermaid diagram generation for stdlib tablesd98f1b670f
- tp: integrate table relationship diagrams into docsCritical Findings from Initial Implementation
1. Single-Page Documentation is Unusable
The current approach generates one massive markdown file with all stdlib
documentation:
Problems:
Solution Required: Rust-style multi-page documentation with:
2. Package-Level Diagrams are Illegible
Packages like
android
with 50+ tables produce mermaid diagrams that are:Example: The
android
package diagram attempts to show all 50+ tables andtheir relationships in one graph, resulting in microscopic text and overlapping
edges.
Solution Required:
3. Cross-Package Relationships Not Visualized
Many stdlib tables reference tables in other packages via JOINID:
process
/thread
tablesheap_graph
tablesCurrent limitation: Mermaid generator only shows intra-module or
intra-package relationships, missing the important cross-package connections.
Solution Required:
relationships
Revised Implementation Plan
Critical Change: Multi-page documentation (Phase 2) must be implemented
BEFORE continuing with mermaid diagrams. The current single-page approach
makes diagrams unusable.
Recommended Next Steps:
prototype
to individual module pages
Rationale: Diagrams are only useful when scoped to individual module pages.
Putting 50-table diagrams on a single page provides no value and creates a poor
user experience.
Lessons Learned
multi-page docs first
package-level diagrams (50+ tables) are not
technique as intra-module relationships
android
package (50+ tables)revealed problems that weren't apparent with smaller modules
Updated Progress Tracking
Phase 1: Foundation & Refactoring - ✅ COMPLETE
Phase 2: Multi-Page Documentation Structure - 🚧 IN PROGRESS (CRITICAL)
Phase 3: Mermaid Diagram Integration -⚠️ PARTIAL/ON HOLD
refinement)
docs)
Next Action: Focus on Phase 2 (multi-page docs) before continuing diagram
work.
💬 Discussion Guidelines:
Beta Was this translation helpful? Give feedback.
All reactions