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

perf(query): Improve Intersection with UID pack #8941

Merged
merged 6 commits into from
Aug 9, 2023

Conversation

harshil-goel
Copy link
Contributor

@harshil-goel harshil-goel commented Aug 9, 2023

This PR improves the performance of IntersectCompressedWithBin. LDBC09 Query went from 38 second -> 22 second. Benchmarks show up to 80% improvement in performance.

@dgraph-bot dgraph-bot added area/testing Testing related issues go Pull requests that update Go code labels Aug 9, 2023
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 add unit tests for these functions too

algo/uidlist.go Outdated Show resolved Hide resolved
algo/uidlist.go Outdated Show resolved Hide resolved
algo/uidlist.go Outdated Show resolved Hide resolved
all-seeing-code
all-seeing-code previously approved these changes Aug 9, 2023
algo/uidlist.go Outdated Show resolved Hide resolved
algo/uidlist.go Outdated Show resolved Hide resolved
@mangalaman93 mangalaman93 changed the title Updated Implementation of Intersect Compressed with perf(query): Improve Intersection with UID pack Aug 9, 2023
@mangalaman93
Copy link
Contributor

goos: linux
goarch: amd64
pkg: github.com/dgraph-io/dgraph/algo
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
len: 
                                                                                          │  in_updated  │
                                                                                          │    sec/op    │
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=100:overlap=0.01:-8       178.3n ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=100:overlap=0.01:-8        1.212µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=100:overlap=0.01:-8          2.447µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=100:overlap=0.01:-8         6.347µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=100:overlap=0.01:-8        45.10µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=1000:overlap=0.01:-8      799.4n ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=1000:overlap=0.01:-8       3.617µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=1000:overlap=0.01:-8         35.03µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=1000:overlap=0.01:-8        74.86µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=1000:overlap=0.01:-8       518.4µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=10000:overlap=0.01:-8     4.953µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=10000:overlap=0.01:-8      44.17µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=10000:overlap=0.01:-8        360.2µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=10000:overlap=0.01:-8       950.5µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=10000:overlap=0.01:-8      4.919m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=100000:overlap=0.01:-8    71.77µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=100000:overlap=0.01:-8     665.1µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=100000:overlap=0.01:-8       3.605m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=100000:overlap=0.01:-8      9.020m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=1000000:overlap=0.01:-8   1.161m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=1000000:overlap=0.01:-8    6.120m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=1000000:overlap=0.01:-8      31.15m ± ∞ ¹
geomean                                                                                     98.72µ
¹ need >= 6 samples for confidence interval at level 0.95

len: 1, compressed: 28, bytes/int: 28.000000
                                                                                          │    in_old    │
                                                                                          │    sec/op    │
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=100:overlap=0.01:-8       701.9n ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=100:overlap=0.01:-8        10.27µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=100:overlap=0.01:-8          62.22µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=100:overlap=0.01:-8         132.2µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=100:overlap=0.01:-8        125.2µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=1000:overlap=0.01:-8      535.6n ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=1000:overlap=0.01:-8       3.268µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=1000:overlap=0.01:-8         1.227m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=1000:overlap=0.01:-8        1.380m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=1000:overlap=0.01:-8       1.157m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=10000:overlap=0.01:-8     4.040µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=10000:overlap=0.01:-8      43.04µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=10000:overlap=0.01:-8        12.65m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=10000:overlap=0.01:-8       13.99m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=10000:overlap=0.01:-8      12.20m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=100000:overlap=0.01:-8    67.35µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=100000:overlap=0.01:-8     612.8µ ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=100000:overlap=0.01:-8       129.2m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=100000:overlap=0.01:-8      117.3m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=1000000:overlap=0.01:-8   1.061m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=1000000:overlap=0.01:-8    6.936m ± ∞ ¹
ListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=1000000:overlap=0.01:-8       1.076 ± ∞ ¹
geomean                                                                                     464.6µ

Old:

len: 1, compressed: 28, bytes/int: 28.000000
goos: linux
goarch: amd64
pkg: github.com/dgraph-io/dgraph/algo
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=100:overlap=0.01:-8           1698944               701.9 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=100:overlap=0.01:-8             112074             10272 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=100:overlap=0.01:-8                19785             62216 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=100:overlap=0.01:-8                8658            132173 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=100:overlap=0.01:-8               8427            125179 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=1000:overlap=0.01:-8          2230539               535.6 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=1000:overlap=0.01:-8            352585              3268 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=1000:overlap=0.01:-8                 962           1227124 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=1000:overlap=0.01:-8                879           1380495 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=1000:overlap=0.01:-8               962           1156982 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=10000:overlap=0.01:-8          268028              4040 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=10000:overlap=0.01:-8            27942             43035 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=10000:overlap=0.01:-8                 86          12651328 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=10000:overlap=0.01:-8                81          13986664 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=10000:overlap=0.01:-8               86          12201208 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=100000:overlap=0.01:-8          17497             67347 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=100000:overlap=0.01:-8            2047            612767 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=100000:overlap=0.01:-8                 8         129177514 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=100000:overlap=0.01:-8                9         117270228 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=1000000:overlap=0.01:-8           975           1060993 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=1000000:overlap=0.01:-8            172           6935648 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=1000000:overlap=0.01:-8                1        1075782785 ns/op

New:

goos: linux
goarch: amd64
pkg: github.com/dgraph-io/dgraph/algo
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=100:overlap=0.01:-8           6835880               178.3 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=100:overlap=0.01:-8             923196              1212 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=100:overlap=0.01:-8               458491              2447 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=100:overlap=0.01:-8              197617              6347 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=100:overlap=0.01:-8              27570             45098 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=1000:overlap=0.01:-8          1444035               799.4 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=1000:overlap=0.01:-8            330864              3617 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=1000:overlap=0.01:-8               36864             35029 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=1000:overlap=0.01:-8              14037             74856 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=1000:overlap=0.01:-8              2360            518358 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=10000:overlap=0.01:-8          238930              4953 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=10000:overlap=0.01:-8            35748             44166 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=10000:overlap=0.01:-8               3290            360233 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=10000:overlap=0.01:-8              1342            950549 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=100:size=10000:overlap=0.01:-8              238           4918652 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=100000:overlap=0.01:-8          15912             71766 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=100000:overlap=0.01:-8            1795            665127 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=100000:overlap=0.01:-8               330           3604814 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=10:size=100000:overlap=0.01:-8              133           9019788 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.01:size=1000000:overlap=0.01:-8          1020           1161000 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=0.1:size=1000000:overlap=0.01:-8            170           6119788 ns/op

BenchmarkListIntersectCompressBin/compressed:IntersectWith:ratio=1:size=1000000:overlap=0.01:-8               39          31154933 ns/op

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.

Great work @harshil-goel. This should improve our query performance too.

Copy link
Contributor

@all-seeing-code all-seeing-code left a comment

Choose a reason for hiding this comment

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

Lgtm

Copy link
Contributor

@joshua-goldstein joshua-goldstein left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@mangalaman93 mangalaman93 merged commit 0474a00 into main Aug 9, 2023
12 checks passed
@mangalaman93 mangalaman93 deleted the harshil-goel/compressed_with branch August 9, 2023 17:06
jbhamra1 pushed a commit that referenced this pull request Aug 17, 2023
This PR improves the performance of IntersectCompressedWithBin.
LDBC09 Query went from 38 second -> 22 second.
Benchmarks show up to 80% improvement in performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Testing related issues go Pull requests that update Go code
Development

Successfully merging this pull request may close these issues.

None yet

5 participants