Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ability to explain-debug all nodes #1563

Merged
merged 14 commits into from
Jun 13, 2023

Conversation

shahzadlone
Copy link
Member

@shahzadlone shahzadlone commented Jun 8, 2023

Resolves #948

Description

Implements a new type of explain called debug which dumps all plan nodes (even non-explainable nodes) as a graph (has no attributes).

Usage is similar to other explain types, but would just do @explain(type: debug) instead of @explain(type: simple) or @explain(type: execute).

Example Request:

query @explain(type: debug) {
	Author (groupBy: [age]) {
		age
		_group {
			name
		}
	}
}

Response:

{
	"data": [
		"explain": {
			"selectTopNode": {
				"groupNode": {
					"selectNode": {
						"pipeNode": {
							"scanNode": {}
						}
					}
				}
			}
		}
	]
}

For reviewers

  • 2nd commit is the one that needs to be thoroughly reviewed, rest is all tests.

How has this been tested?

Integration tests

Specify the platform(s) on which this was tested:

  • WSL2 (Manjaro)

@shahzadlone shahzadlone added feature New feature or request code quality Related to improving code quality area/planner Related to the planner system labels Jun 8, 2023
@shahzadlone shahzadlone added this to the DefraDB v0.6 milestone Jun 8, 2023
@shahzadlone shahzadlone requested a review from a team June 8, 2023 16:14
@shahzadlone shahzadlone self-assigned this Jun 8, 2023
@shahzadlone shahzadlone changed the title feat: Add ability to explain all nodes (debug) feat: Add ability to explain-debug all nodes Jun 8, 2023
@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Patch coverage: 66.67% and project coverage change: -0.01 ⚠️

Comparison is base (ac5d7b8) 72.29% compared to head (1e186cc) 72.28%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1563      +/-   ##
===========================================
- Coverage    72.29%   72.28%   -0.01%     
===========================================
  Files          185      185              
  Lines        18389    18477      +88     
===========================================
+ Hits         13294    13355      +61     
- Misses        4055     4074      +19     
- Partials      1040     1048       +8     
Flag Coverage Δ
all-tests 72.28% <66.67%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
planner/type_join.go 74.87% <ø> (-0.07%) ⬇️
request/graphql/schema/types/types.go 100.00% <ø> (ø)
planner/explain.go 58.99% <65.91%> (+2.97%) ⬆️
request/graphql/parser/request.go 73.12% <100.00%> (+0.34%) ⬆️

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac5d7b8...1e186cc. Read the comment docs.

@AndrewSisley
Copy link
Contributor

thought: It feels quite odd to me that debug explain outputs less stuff than simple explain. Why would we not want to output the attributes for the nodes that have them?

@shahzadlone
Copy link
Member Author

thought: It feels quite odd to me that debug explain outputs less stuff than simple explain. Why would we not want to output the attributes for the nodes that have them?

We already have access to the attributes with the simple explain call. The debug explain (atleast the first iteration of it) should visualize the full plan graph nodes. i.e. the pipeNode and multiScanNode.

However this makes me think that similar to how we were gunna add an option to execute explain like showSimpleAttributes to enable showing simple explain attributes for execute explain nodes, we can in future do the same thing for debug as well.

@AndrewSisley
Copy link
Contributor

thought: It feels quite odd to me that debug explain outputs less stuff than simple explain. Why would we not want to output the attributes for the nodes that have them?

We already have access to the attributes with the simple explain call. The debug explain (atleast the first iteration of it) should visualize the full plan graph nodes. i.e. the pipeNode and multiScanNode.

However this makes me think that similar to how we were gunna add an option to execute explain like showSimpleAttributes to enable showing simple explain attributes for execute explain nodes, we can in future do the same thing for debug as well.

I'm not sure you are understanding me. Typically debug provides the same information as simple/info/default/etc, and more, additional info (never losing the simple info in the debug). It would also annoy me as a user if I couldnt get the full graph with attributes from a single explain call.

@shahzadlone
Copy link
Member Author

Typically debug provides the same information as simple/info/default/etc, and more, additional info (never losing the simple info in the debug).

Is "simple" an actual log level? I have never seen that, if it is then I can see the confusion. The different explain types aren't log/verbosity levels, they do different things. For example execute explain will return the execution information, simple will return the attributes and only the explain nodes. Upon thinking further I would be okay to name this to something else, maybe type: internal, this explain should be very rarely used by non-internal-devs as the graph includes nodes that are too into the weeds of defradb.

It would also annoy me as a user if I couldnt get the full graph with attributes from a single explain call.

That will be possible though for both execute and this explain with showSimpleAttributes.

@AndrewSisley
Copy link
Contributor

AndrewSisley commented Jun 12, 2023

Is "simple" an actual log level?

Simple explain is pretty analogous to info log levels. The split in both serves exactly the same purpose 99% of the time.

That will be possible though for both execute and this explain with showSimpleAttributes.

What is the point of multiple types of explain, if you have to decorate them all with attributes to make them useful? Why not have one type of explain with all the attributes?

@shahzadlone
Copy link
Member Author

@AndrewSisley made a ticket to reflect our standup discussion: #1570

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

Is a mad amount of tests that you have managed to write for this, I skimmed through them and they all appeared sensible to have - thanks a bunch for adding them all :)

Prod code looked good too, minus the feature-change requested RE type that we discussed in the standup. Just added an out of scope suggestion for the future that I spotted whilst reading.

idsLabel = "ids"
joinRootLabel = "root"
joinSubTypeLabel = "subType"
keysLabel = "_keys"
limitLabel = "limit"
offsetLabel = "offset"
sourcesLabel = "sources"
spansLabel = "spans"
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (out of scope): These are all public, and I think they should live in client/request/explain.go - might be worth adding a ticket if you agree.

Same also goes for the attribute tags and node names (if they are in planner atm)

Copy link
Member Author

Choose a reason for hiding this comment

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

I appreciate this suggestion! Would be much nicer. Will open a ticket.

Copy link
Member Author

Choose a reason for hiding this comment

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

ticket: #1571

@shahzadlone shahzadlone merged commit c9e4355 into sourcenetwork:develop Jun 13, 2023
@shahzadlone shahzadlone deleted the feat/debug-explain branch June 13, 2023 07:39
@islamaliev
Copy link
Contributor

bug bash result:
ran local defradb node, create different collection with relationships.
Used Altair GraphQL client to query many different types of queries and mutations (filters, groups, orders, limits and others).
For all queries got a corresponding explain graph

shahzadlone added a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
Resolves sourcenetwork#948 

## Description
Implements a new type of explain called `debug` which dumps all plan
nodes (even non-explainable nodes) as a graph (has no attributes).

Usage is similar to other explain types, but would just do
`@explain(type: debug)` instead of `@explain(type: simple)` or
`@explain(type: execute)`.

Example Request:
```
query @Explain(type: debug) {
	Author (groupBy: [age]) {
		age
		_group {
			name
		}
	}
}
```

Response:
```
{
	"data": [
		"explain": {
			"selectTopNode": {
				"groupNode": {
					"selectNode": {
						"pipeNode": {
							"scanNode": {}
						}
					}
				}
			}
		}
	]
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/planner Related to the planner system code quality Related to improving code quality feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explain Request - Debug
3 participants