Skip to content

Render the grouped profile a 2.x engine writes - #810

Open
evertlammerts wants to merge 8 commits into
duckdb:mainfrom
ewoerd:fix-query-graph-renderer
Open

evertlammerts wants to merge 8 commits into
duckdb:mainfrom
ewoerd:fix-query-graph-renderer

Conversation

@evertlammerts

Copy link
Copy Markdown
Member

Fixes #752.

python -m duckdb.query_graph fails on every profile a DuckDB 2.x engine writes, and the command the profiling docs show is refused before it reads the file. The same failure through the Python API:

import duckdb
from duckdb.query_graph import ProfilingInfo

con = duckdb.connect()
con.execute("SET enable_profiling = 'json'")
con.execute("SET profile_output = 'profile.json'")
con.execute("SELECT 42").fetchall()

ProfilingInfo(from_file="profile.json").to_html("profile.html")
# main:        ValueError: could not convert string to float: 'N/A'
# this change: writes profile.html with the query metrics, the SQL and the operator tree

Since 2.0 the engine writes the profile grouped, with query, io and system objects and an operator list, while the renderer still reads the flat keys of 1.x such as latency and children. Its command line takes the path only as --profile_input, so the documented python -m duckdb.query_graph profile.json is a usage error.

  • The renderer now reads the grouped profile: the metric boxes, the SQL, the operator tree and the time per operator type. A metric the profile does not track shows as N/A.
  • Text from the profile is HTML escaped.
  • The command line takes the path as a positional argument and keeps --profile_input. --no-open writes the page without opening a browser. A missing path is a usage error, and a file that is not a profile or a failed write ends in one line instead of a traceback.
  • The code moves into the package __init__.py, so -m no longer warns about a double import, and mypy now checks it.

A flat profile, written by DuckDB 1.x or by 2.x under SET legacy_metrics_format = true, is now refused with a message that names that setting; on main a saved 1.x profile still renders.

tests/fast/test_profiler.py builds its profiles with the running engine and pins the metric grid, the tree as a browser nests it, the escaping, profiles that track few metrics, every refused input and each command line form. 53 of its 55 cases fail on main.

The release line v2.0-cyanoptera has the same defect, and the fix should be ported there.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

query_graph fails with duckdb 2

1 participant