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

Add support to show metrics #4033

Merged
merged 13 commits into from
Nov 7, 2019
Merged

Add support to show metrics #4033

merged 13 commits into from
Nov 7, 2019

Conversation

poonai
Copy link
Contributor

@poonai poonai commented Sep 20, 2019

  • Add metrics to show the number of nodes touched by each attribute
  • Add metrics to the response

Signed-off-by: பாலாஜி ஜின்னா [email protected]


This change is Reviewable

Sample output

{
  "data": {
    "me": [...
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 14530,
      "processing_ns": 4937092,
      "encoding_ns": 132441,
      "assign_timestamp_ns": 675662
    },
    "txn": {
      "start_ts": 83
    },
    "metrics": {
      "num_uids": {
        "age": 54,
        "friend": 48,
        "name": 54
      }
    }
  }
}

Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ A review job has been created and sent to the PullRequest network.


Check the status or cancel PullRequest code review here.

Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Copy link
Contributor

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

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

This is not enough, need two things -

  • Take an example dataset and show some results in the PR show that the results are what we are expecting
  • What is this metrics that you are computing in this PR?

Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @pawanrawal)

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Comments on some of the overall logic and naming.


Reviewed with ❤️ by PullRequest

query/outputnode.go Outdated Show resolved Hide resolved
query/outputnode.go Outdated Show resolved Hide resolved
// calculateMetrics populates the given map with the number of uids are gathered for each
// attributes.
func calculateMetrics(sg *SubGraph, metrics map[string]int) {
// we'll calcuate only destination because this are the uid gathered by this subgraph.
Copy link

Choose a reason for hiding this comment

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

  • calcuate -> calculate
  • are -> is

query/outputnode.go Outdated Show resolved Hide resolved
sgr.Children = append(sgr.Children, sg)
}
fmt.Println(metricsMap)
Copy link

Choose a reason for hiding this comment

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

Is this for logging purposes or to console to validate?

@@ -810,3 +814,29 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error {

return nil
}

// calculateMetrics populates the given map with the number of uids are gathered for each
Copy link

Choose a reason for hiding this comment

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

calculateMetrics populates the given map with the number of uids are gathered for each attributes

for _, filter := range sg.Filters {
calculateMetrics(filter, metrics)
}
// calculate metrics for the childres as well.
Copy link

Choose a reason for hiding this comment

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

children

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

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

Commented on the discuss post, this PR can be simplified. You just need to compute len(uidMatrix) to get an estimate of the number of disk seeks. Let me know if something isn't clear and we can discuss it.

Reviewable status: 0 of 1 files reviewed, 9 unresolved discussions (waiting on @balajijinnah and @pawanrawal)


query/outputnode.go, line 825 at r1 (raw file):

	// some results, because if any filters applied those uids are gone.
	prev := metrics[sg.Attr]
	// QUESTION: @manish @pawan: should I add destuid or length of posting list?.

If I understand correctly, the intention of this PR is to get an estimate of the number of disk seeks that we do?


query/outputnode.go, line 830 at r1 (raw file):

	// as well.
	for _, valList := range sg.valueMatrix {
		prev = prev + len(valList.GetValues())

Why are we adding this? To get a value list, we do one disk seek per uid and predicate combination which would be done at the parent SubGraph of this node.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Due to inactivity, PullRequest has cancelled this review job. You can reactivate the code review job from the PullRequest dashboard

Signed-off-by: balaji jinnah <[email protected]>
Copy link
Contributor

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 11 unresolved discussions (waiting on @balajijinnah)


query/outputnode.go, line 53 at r2 (raw file):

		}
		// calculate metrics for this query.
		calculateMetrics(sg, metricsMap)

Move this to Request.Process


query/outputnode.go, line 823 at r2 (raw file):

	// we'll calculate srcUid of the each attribute. because, these are number of uids
	// processed by this attribute.
	prev := metrics[sg.Attr]
  • What happens when Attr is uid.
  • Check for Internal(), that is O(1) computation for us

Copy link
Contributor

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

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

Please address all the comments and add the version of dgo so that I can run it locally.

Reviewable status: 0 of 1 files reviewed, 11 unresolved discussions (waiting on @balajijinnah)

Copy link
Contributor

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

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

@balajijinnah please add tests for this change too.

Reviewable status: 0 of 1 files reviewed, 11 unresolved discussions (waiting on @balajijinnah)

பாலாஜி added 4 commits October 14, 2019 16:55
Signed-off-by: பாலாஜி <[email protected]>
Signed-off-by: பாலாஜி <[email protected]>
Signed-off-by: பாலாஜி <[email protected]>
@poonai poonai requested review from manishrjain and a team as code owners October 22, 2019 11:01
Signed-off-by: balaji jinnah <[email protected]>
Signed-off-by: balaji jinnah <[email protected]>
Copy link
Contributor Author

@poonai poonai left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 8 files reviewed, 11 unresolved discussions (waiting on @balajijinnah, @mangalaman93, @manishrjain, @pawanrawal, and @pullrequest[bot])


query/outputnode.go, line 56 at r1 (raw file):

Previously, pullrequest[bot] wrote…

Is this for logging purposes or to console to validate?

Done.


query/outputnode.go, line 818 at r1 (raw file):

Previously, pullrequest[bot] wrote…

calculateMetrics populates the given map with the number of uids are gathered for each attributes

Done.


query/outputnode.go, line 821 at r1 (raw file):

Previously, pullrequest[bot] wrote…
  • calcuate -> calculate
  • are -> is

Done.


query/outputnode.go, line 825 at r1 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

If I understand correctly, the intention of this PR is to get an estimate of the number of disk seeks that we do?

Done.


query/outputnode.go, line 830 at r1 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

Why are we adding this? To get a value list, we do one disk seek per uid and predicate combination which would be done at the parent SubGraph of this node.

Done.


query/outputnode.go, line 832 at r1 (raw file):

Previously, pullrequest[bot] wrote…

It feels like the naming could be improved since we are writing to quite a generic field name Attr.

Done.


query/outputnode.go, line 834 at r1 (raw file):

Previously, pullrequest[bot] wrote…

It'd be interesting to have more insight into why Filters are included here.

Done.


query/outputnode.go, line 838 at r1 (raw file):

Previously, pullrequest[bot] wrote…

children

Done.


query/outputnode.go, line 53 at r2 (raw file):

Previously, mangalaman93 (Aman Mangal) wrote…

Move this to Request.Process

Done.


query/outputnode.go, line 823 at r2 (raw file):

Previously, mangalaman93 (Aman Mangal) wrote…
  • What happens when Attr is uid.
  • Check for Internal(), that is O(1) computation for us

Done.

Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

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

:lgtm: as a first pass. This would require more work for certain queries. The ones that I can think of are:

  1. Sorting at root isn't captured.
  2. Functions at root won't be captured because they don't have source uids.
  3. Filters would only capture SrcUids but most of the work that they do is by fetching index tokens.

Reviewed 7 of 8 files at r3, 1 of 1 files at r4.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @balajijinnah, @mangalaman93, @manishrjain, @pawanrawal, and @pullrequest[bot])

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

:lgtm: Add the caveats @pawanrawal mentioned in the PR description, so we can come back to this and improve it. Rest looks alright to me. Defer to @pawanrawal 's review.

Reviewed 7 of 8 files at r3, 1 of 1 files at r4.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @balajijinnah, @mangalaman93, @pawanrawal, and @pullrequest[bot])

@poonai poonai merged commit ab8984b into master Nov 7, 2019
@joshua-goldstein joshua-goldstein deleted the balaji/metrics branch August 11, 2022 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants