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

opt(recurse): Optimise recurse and bring range iterators from sroar #7989

Merged
merged 9 commits into from
Aug 16, 2021

Conversation

ahsanbarkati
Copy link
Contributor

@ahsanbarkati ahsanbarkati commented Aug 16, 2021

Optimise recurse by using reached map with bitmap as the value, so a direct
bitmap AndNot can be done to get the list of unvisited edges. Also, use
range iterators and the fast iterator.


This change is Reviewable

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: Very nice! Got a few comments.

Reviewed 9 of 9 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ahsanbarkati)


codec/codec.go, line 69 at r2 (raw file):

		return 0
	}
	// TODO: Update GetCardinality to handle nil Bitmap.

can you tackle this TODO?


codec/codec.go, line 162 at r2 (raw file):

		return nil
	}
	return bm.ToBuffer()

bm.ToBuffer should deal with bm being empty. Can you make the change there? Then, we can just use ToBuffer or ToBufferWithCopy, I suppose.


codec/codec.go, line 173 at r2 (raw file):

		iw.SetMany(l.SortedUids)
	}
	if len(l.Bitmap) > 0 {

move l.Bitmap above l.SortedUids, and return immediately, instead of doing check for l.SortedUids too. I can't imagine a case where both would be set.


codec/codec.go, line 184 at r2 (raw file):

		return nil
	}
	if len(l.SortedUids) > 0 {

In my code, I had specifically moved this below l.Bitmap to avoid paying the code of check. The comment below says that we should optimize for l.Bitmap case. Can you move this below l.Bitmap? And add a comment to keep it that way.


query/recurse.go, line 146 at r2 (raw file):

					if len(sg.uidMatrix[mIdx].SortedUids) > 0 {
						// we will have to keep the order, so using ApplyFilter
						algo.ApplyFilter(sg.uidMatrix[mIdx], func(uid uint64, i int) bool {

Did you find a case where this is needed?

Copy link
Contributor Author

@ahsanbarkati ahsanbarkati 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: 3 of 14 files reviewed, 5 unresolved discussions (waiting on @manishrjain)


codec/codec.go, line 69 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

can you tackle this TODO?

Done.


codec/codec.go, line 162 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

bm.ToBuffer should deal with bm being empty. Can you make the change there? Then, we can just use ToBuffer or ToBufferWithCopy, I suppose.

Done.


codec/codec.go, line 173 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

move l.Bitmap above l.SortedUids, and return immediately, instead of doing check for l.SortedUids too. I can't imagine a case where both would be set.

Done.


codec/codec.go, line 184 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

In my code, I had specifically moved this below l.Bitmap to avoid paying the code of check. The comment below says that we should optimize for l.Bitmap case. Can you move this below l.Bitmap? And add a comment to keep it that way.

Done.


query/recurse.go, line 146 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Did you find a case where this is needed?

Yes for the case of recurse with order. Check TestRecurseQueryOrder.

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: Approved! Remember to add a task to also optimize AndNot.

Reviewed 11 of 11 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ahsanbarkati)


codec/codec.go, line 139 at r3 (raw file):

	for _, m := range matrix {
		bmc := FromListNoCopy(m)
		if bmc != nil {

can be put together in one line.

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.

2 participants