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

tools: Created benchmark suite #160

Merged
merged 68 commits into from
Feb 2, 2022
Merged

tools: Created benchmark suite #160

merged 68 commits into from
Feb 2, 2022

Conversation

jsimnz
Copy link
Member

@jsimnz jsimnz commented Feb 1, 2022

Closes #71 + Closes #70 + Closes #72
Create the initial benchmark suite to be used to track relative differences in performance between commits and PRs.

Currently, the following suites are implemented:

  • Collections API
    • Read (Sync/Async*)
    • Create (Sync/Async*)
    • CreateMany (Sync*)
  • Query API
    • Read
    • With filter
    • With limit/offset
    • With sort
  • Planner API
    • Query GQL parsing
    • Make plan
  • Raw Storage API (Datastore)
    • Get
    • Put
    • PutMany

The Raw Storate API is used as a base line reference for how the storage backend is performing relative to the higher level operations of Defra.

Theres a LOT of changes here, including several non benchmark related bugs that were found while implementing the benchmarks. Fixes #113

Unrelated, but I mentioned before that I got myself into git hell by accidentally forking this branch off of another major feat for the Time Travel queries. Turns out that was false, and this branch is clean from a older develop.

Additionally, this branch was recently rebased against the most recent develop changes, so it should be pretty clean. Only notable conflicts from the rebase was in db/tests/utils.go since both Andy and I made some changes for how test DBs are created, but I think I merged them pretty cleanly.

Todo after merge:

  • Update documentation on main readme for new benchmarks
  • Update root Makefile
  • Add readme to bench/ folder

*Sync/Async runs different benchmarks synchronously (waiting for each call to execute serially), and asynchronously (running each call concurrently)

BREAKING CHANGE: 1) Updates the CRDT Delta payloads, causing different CIDs to be associated for the same input compared to older version. 2) Updated client/core interfaces.

@jsimnz jsimnz added feature New feature or request perf Performance issue or suggestion area/testing Related to any test or testing suite labels Feb 1, 2022
@jsimnz jsimnz added this to the DefraDB v0.2 milestone Feb 1, 2022
@jsimnz jsimnz self-assigned this Feb 1, 2022
@codecov
Copy link

codecov bot commented Feb 1, 2022

Codecov Report

Merging #160 (c95ec57) into develop (2100f51) will decrease coverage by 3.79%.
The diff coverage is 14.12%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #160      +/-   ##
===========================================
- Coverage    62.85%   59.06%   -3.80%     
===========================================
  Files           81       87       +6     
  Lines         7737     8344     +607     
===========================================
+ Hits          4863     4928      +65     
- Misses        2351     2890     +539     
- Partials       523      526       +3     
Impacted Files Coverage Δ
bench/collection/utils.go 0.00% <0.00%> (ø)
bench/fixtures/fixtures.go 0.00% <0.00%> (ø)
bench/query/planner/utils.go 0.00% <0.00%> (ø)
bench/query/simple/utils.go 0.00% <0.00%> (ø)
bench/storage/utils.go 0.00% <0.00%> (ø)
db/db.go 49.53% <0.00%> (-0.95%) ⬇️
query/graphql/planner/dagscan.go 72.28% <ø> (ø)
query/graphql/planner/datasource.go 55.88% <0.00%> (ø)
query/graphql/planner/scan.go 80.59% <ø> (-0.29%) ⬇️
bench/bench_util.go 9.23% <9.23%> (ø)
... and 14 more

@orpheuslummis
Copy link
Contributor

I suggest adding to the main Makefile:

.PHONY: bench
bench:
	$(MAKE) -C bench

Posted here as I'm unsure of what's the process to contribute a small change like this to the branch.

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.

Looks good, with lots small comments and nothing too serious. Would however suggest that this could have been a series of much smaller PRs and bits could have been merged earlier - even if it meant a bit of extra reviewing due to changes you will have made after any hypothetical early merges.

bench/README.md Show resolved Hide resolved
bench/bench_util.go Show resolved Hide resolved
bench/collection/utils.go Show resolved Hide resolved
bench/collection/utils.go Outdated Show resolved Hide resolved
bench/collection/utils.go Outdated Show resolved Hide resolved
go.mod Show resolved Hide resolved
query/graphql/planner/planner.go Outdated Show resolved Hide resolved
query/graphql/planner/scan.go Show resolved Hide resolved
query/graphql/schema/descriptions.go Outdated Show resolved Hide resolved
query/graphql/schema/generate.go Outdated Show resolved Hide resolved
@AndrewSisley
Copy link
Contributor

AndrewSisley commented Feb 1, 2022

Also - outputted metrics seem either confused, or we have an embedded time machine?

Benchmark_Collection_UserSimple_CreateMany_Sync_0_10-8    	       9	 221265691 ns/op
Benchmark_Collection_UserSimple_CreateMany_Sync_0_100-8   	       1	2556931455 ns/op
Benchmark_Collection_UserSimple_Create_Sync_0_1-8         	      68	  19171976 ns/op
Benchmark_Collection_UserSimple_Create_Sync_0_10-8        	       9	 223102226 ns/op
Benchmark_Collection_UserSimple_Create_Sync_0_100-8       	       1	2380119361 ns/op
Benchmark_Collection_UserSimple_Create_Sync_0_1000-8      	       1	29547083617 ns/op
Benchmark_Collection_UserSimple_Create_Async_0_1-8        	      70	  21828818 ns/op
Benchmark_Collection_UserSimple_Create_Async_0_100-8      	       2	1242092956 ns/op
Benchmark_Collection_UserSimple_Create_Async_0_1000-8     	       1	17967581827 ns/op

29547083617 ns/op is 29 seconds per operation, and I don't think it took that long to run lol

EDIT: I guess this is default output from go.bench - hopefully we can find a way to override that.

@jsimnz jsimnz force-pushed the jsimnz/feat/benchmark-suite branch from 97febc0 to bfe35dd Compare February 1, 2022 22:17
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.

Looks good, happy with your replies and thanks for the extra tweaks :) Looking forward to having this in

@jsimnz jsimnz force-pushed the jsimnz/feat/benchmark-suite branch from bfe35dd to f6e06d0 Compare February 2, 2022 04:42
@jsimnz jsimnz merged commit 846122b into develop Feb 2, 2022
@jsimnz jsimnz deleted the jsimnz/feat/benchmark-suite branch February 2, 2022 05:05
@jsimnz jsimnz mentioned this pull request Feb 4, 2022
jsimnz added a commit that referenced this pull request Feb 7, 2022
* Added bench readme

* Started fixture framework to generate doc data

* basic bench runner script.

* started collection benchmark outline

* Updated DB Collection client interface API

* Added db cleanup routines

* Switched from ResetTimer, to Start/Stop so it can be composable

* Updated collection client API to include new context arg

* updated gitignore to ignore benchmark artifacts

* Updated test suite structure

* Renamed bench file, added sync/async benchmarks

* Reorganized benchmark folder to match db/tests structure. Removed old db-init files for benchmark

* Reorganized collection tests into smaller units. Added async read tests. WIP: async backfill writes

* Updated fixture data

* Renamed get bench tests to read

* Added Create/Write tests, updated utils structure, implemented async backfilling for benchmarks

* Added CreateMany tests

* Fixed issue where discarded transactions we're causing side-effect mutation on the document object

* Fixed async transaction conflict issue

* Started underlying storage engine benchmarks

* Started put tests on storage, added more get tests

* Updated collection benchmark utilities, extracted into dedicated package

* Added new FieldDescription Meta data entry to indicate 'synthetic' internal IDs for managed related types

* Added more query benchmarks, added query generation to fixtures package

* Fixed tests from BREAKING change resulted from IPLD delta payload restructure

* Removed auto query generation for fixtures, manual for now

* Restructured benchmarks to further match db test structure. Removed opcount

* Added filter query benchmarks

* Added offset/limit + sort benchmarks. Removed old untracked deleted benchmark files

* Updated DB and planner to expose make plan functions as public

* Added benchmarks for planner/parser

* Added query formatting with dockey replacement from inserted set

* Added benchmarks for single and multi point lookups by dockey(s)

* Fixed missing func args resulting from rebase

* Added makefile

* Added some comments to the async implementations. Also added a deterministic seed for the RNG system to produce consistent results

* Updated CIDs from tests based on breaking change of IPLD format

* Added put and put many benchmarks to storage

* updated dependencies required via go mod tidy (CI issue)

* Removing deadcode or useless comments

* Replaced WithSchema with ForSchema

* Renamed fixture.Context to fixture.Generator

* Updated benchmark runner utils to take a context instead of creating a new one

* Updated all references to benchmark runners for new context arg

* Refactored StartTimer() calls and numType arg

* removed dead/commented code

* Updated public API for query planner

* Added StopTimer() calls to add accuracy to the benchmarks

* Updated benchmark loop to use ResetTimer for more accuracy

* Moved valueSize array out

* Replaced custom interface for TempDir with proper testing.TB interface

* Minor comments and stuff

* Moved the testutil NewDB related funcs from /tests to /bench

* Removed rando comment

* fixed linter errors

BREAKING CHANGE: Changes internal IPLD format and resulting delta CIDs.
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
* Added bench readme

* Started fixture framework to generate doc data

* basic bench runner script.

* started collection benchmark outline

* Updated DB Collection client interface API

* Added db cleanup routines

* Switched from ResetTimer, to Start/Stop so it can be composable

* Updated collection client API to include new context arg

* updated gitignore to ignore benchmark artifacts

* Updated test suite structure

* Renamed bench file, added sync/async benchmarks

* Reorganized benchmark folder to match db/tests structure. Removed old db-init files for benchmark

* Reorganized collection tests into smaller units. Added async read tests. WIP: async backfill writes

* Updated fixture data

* Renamed get bench tests to read

* Added Create/Write tests, updated utils structure, implemented async backfilling for benchmarks

* Added CreateMany tests

* Fixed issue where discarded transactions we're causing side-effect mutation on the document object

* Fixed async transaction conflict issue

* Started underlying storage engine benchmarks

* Started put tests on storage, added more get tests

* Updated collection benchmark utilities, extracted into dedicated package

* Added new FieldDescription Meta data entry to indicate 'synthetic' internal IDs for managed related types

* Added more query benchmarks, added query generation to fixtures package

* Fixed tests from BREAKING change resulted from IPLD delta payload restructure

* Removed auto query generation for fixtures, manual for now

* Restructured benchmarks to further match db test structure. Removed opcount

* Added filter query benchmarks

* Added offset/limit + sort benchmarks. Removed old untracked deleted benchmark files

* Updated DB and planner to expose make plan functions as public

* Added benchmarks for planner/parser

* Added query formatting with dockey replacement from inserted set

* Added benchmarks for single and multi point lookups by dockey(s)

* Fixed missing func args resulting from rebase

* Added makefile

* Added some comments to the async implementations. Also added a deterministic seed for the RNG system to produce consistent results

* Updated CIDs from tests based on breaking change of IPLD format

* Added put and put many benchmarks to storage

* updated dependencies required via go mod tidy (CI issue)

* Removing deadcode or useless comments

* Replaced WithSchema with ForSchema

* Renamed fixture.Context to fixture.Generator

* Updated benchmark runner utils to take a context instead of creating a new one

* Updated all references to benchmark runners for new context arg

* Refactored StartTimer() calls and numType arg

* removed dead/commented code

* Updated public API for query planner

* Added StopTimer() calls to add accuracy to the benchmarks

* Updated benchmark loop to use ResetTimer for more accuracy

* Moved valueSize array out

* Replaced custom interface for TempDir with proper testing.TB interface

* Minor comments and stuff

* Moved the testutil NewDB related funcs from /tests to /bench

* Removed rando comment

* fixed linter errors

BREAKING CHANGE: Changes internal IPLD format and resulting delta CIDs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Related to any test or testing suite feature New feature or request perf Performance issue or suggestion
Projects
None yet
3 participants