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(core): Add cache to dgraph.type predicate. #9068

Merged
merged 20 commits into from May 23, 2024

Conversation

harshil-goel
Copy link
Contributor

@harshil-goel harshil-goel commented Apr 8, 2024

Add cache to dgraph.type predicate. This would significantly help improve @filter(type) queries.
Live loader before took: 16mins 39 seconds for 21 million dataset.
Live loader now: 10mins 52 seconds.
Improvement: 38%

@harshil-goel harshil-goel requested a review from a team as a code owner April 8, 2024 15:54
@dgraph-bot dgraph-bot added area/testing Testing related issues area/core internal mechanisms go Pull requests that update Go code labels Apr 8, 2024
posting/mvcc.go Outdated
// corresponding to the key in the cache to nil. So, if we get some non-nil value from the cache
// then it means that no writes have happened after the last set of this key in the cache.
if l, ok := countMap.list[string(key)]; ok {
if l != nil && l.maxTs < readTs {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

l.minTs < readTs

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.

See whether we want to put this behind a feature flag just in case!

posting/list.go Show resolved Hide resolved
posting/mvcc.go Outdated
@@ -1,25 +1,24 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

undo this change

posting/mvcc.go Outdated
type GlobalCache struct {
sync.RWMutex

count map[string]int
Copy link
Contributor

Choose a reason for hiding this comment

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

use a struct instead! More maps => more memory unpredictability

@harshil-goel harshil-goel changed the title feat(core): Update caching mechanism of posting lists feat(core): Add cache to dgraph.type predicate. May 21, 2024
return int64(0)
}
return int64(l.DeepSize())
return 0
Copy link
Contributor

Choose a reason for hiding this comment

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

please make a comment to describe why the change

@mangalaman93 mangalaman93 merged commit d5d9373 into main May 23, 2024
12 checks passed
@mangalaman93 mangalaman93 deleted the harshil-goel/mem-cache branch May 23, 2024 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core internal mechanisms area/testing Testing related issues go Pull requests that update Go code
Development

Successfully merging this pull request may close these issues.

None yet

3 participants