From 0f1264d312f5f8ccdc66bf7493725846658f2a13 Mon Sep 17 00:00:00 2001 From: Sayan Nandan Date: Fri, 18 Jun 2021 19:35:59 +0530 Subject: [PATCH] Decompose linearity tests and utils into modules Also fixed license headers --- actions.jsonc | 2 +- cli/src/argparse.rs | 2 +- cli/src/cli.yml | 2 +- cli/src/main.rs | 2 +- cli/src/runner.rs | 2 +- libsky/src/lib.rs | 2 +- libsky/src/util.rs | 2 +- libstress/src/lib.rs | 2 +- libstress/src/traits.rs | 2 +- server/native/flock-posix.c | 2 +- server/src/actions/dbsize.rs | 2 +- server/src/actions/del.rs | 2 +- server/src/actions/exists.rs | 2 +- server/src/actions/flushdb.rs | 2 +- server/src/actions/get.rs | 2 +- server/src/actions/jget.rs | 2 +- server/src/actions/keylen.rs | 2 +- server/src/actions/lskeys.rs | 2 +- server/src/actions/mget.rs | 2 +- server/src/actions/mod.rs | 2 +- server/src/actions/mset.rs | 2 +- server/src/actions/mupdate.rs | 2 +- server/src/actions/pop.rs | 2 +- server/src/actions/set.rs | 2 +- server/src/actions/strong.rs | 2 +- server/src/actions/update.rs | 2 +- server/src/actions/uset.rs | 2 +- server/src/admin/mksnap.rs | 2 +- server/src/admin/mod.rs | 2 +- server/src/compat/mod.rs | 2 +- server/src/config/mod.rs | 2 +- server/src/coredb/htable.rs | 2 +- server/src/coredb/mod.rs | 2 +- server/src/dbnet/connection.rs | 2 +- server/src/dbnet/mod.rs | 2 +- server/src/dbnet/tcp.rs | 2 +- server/src/dbnet/tls.rs | 2 +- server/src/diskstore/flock.rs | 2 +- server/src/diskstore/mod.rs | 2 +- server/src/diskstore/snapshot.rs | 2 +- server/src/diskstore/snapstore.rs | 2 +- server/src/main.rs | 2 +- server/src/protocol/element.rs | 2 +- server/src/protocol/mod.rs | 2 +- server/src/protocol/responses.rs | 2 +- server/src/queryengine/mod.rs | 2 +- server/src/resp/mod.rs | 2 +- server/src/services/bgsave.rs | 2 +- server/src/services/mod.rs | 2 +- server/src/services/snapshot.rs | 2 +- server/src/tests/kvengine.rs | 2 +- server/src/tests/mod.rs | 2 +- sky-bench/src/benchtool.rs | 2 +- sky-bench/src/cli.yml | 2 +- sky-bench/src/main.rs | 2 +- sky-bench/src/testkey.rs | 2 +- sky-bench/src/util.rs | 2 +- sky-macros/src/lib.rs | 2 +- stress-test/src/linearity_client.rs | 187 +++++++++++++++++++++++++ stress-test/src/main.rs | 208 +++------------------------- stress-test/src/utils.rs | 60 ++++++++ 61 files changed, 324 insertions(+), 247 deletions(-) create mode 100644 stress-test/src/linearity_client.rs create mode 100644 stress-test/src/utils.rs diff --git a/actions.jsonc b/actions.jsonc index a3d8e020..141f08ba 100644 --- a/actions.jsonc +++ b/actions.jsonc @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/cli/src/argparse.rs b/cli/src/argparse.rs index c4ee77ea..e1bc6753 100644 --- a/cli/src/argparse.rs +++ b/cli/src/argparse.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/cli/src/cli.yml b/cli/src/cli.yml index e7169d82..4e87e9a3 100644 --- a/cli/src/cli.yml +++ b/cli/src/cli.yml @@ -11,7 +11,7 @@ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License diff --git a/cli/src/main.rs b/cli/src/main.rs index c7eed935..d80312b6 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/cli/src/runner.rs b/cli/src/runner.rs index 42e8170d..5b6d2320 100644 --- a/cli/src/runner.rs +++ b/cli/src/runner.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/libsky/src/lib.rs b/libsky/src/lib.rs index 0ef08546..850f2e6d 100644 --- a/libsky/src/lib.rs +++ b/libsky/src/lib.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/libsky/src/util.rs b/libsky/src/util.rs index 204a2bdb..997c7500 100644 --- a/libsky/src/util.rs +++ b/libsky/src/util.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/libstress/src/lib.rs b/libstress/src/lib.rs index 390dbb45..4f59cc27 100644 --- a/libstress/src/lib.rs +++ b/libstress/src/lib.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/libstress/src/traits.rs b/libstress/src/traits.rs index 890dbba5..e15cdeb9 100644 --- a/libstress/src/traits.rs +++ b/libstress/src/traits.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/native/flock-posix.c b/server/native/flock-posix.c index f8f4cae0..f4e33a9c 100644 --- a/server/native/flock-posix.c +++ b/server/native/flock-posix.c @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/dbsize.rs b/server/src/actions/dbsize.rs index 8f58a5b8..9cb02abe 100644 --- a/server/src/actions/dbsize.rs +++ b/server/src/actions/dbsize.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/del.rs b/server/src/actions/del.rs index f0420c11..4fee4bfa 100644 --- a/server/src/actions/del.rs +++ b/server/src/actions/del.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/exists.rs b/server/src/actions/exists.rs index 36976204..53e4afdb 100644 --- a/server/src/actions/exists.rs +++ b/server/src/actions/exists.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/flushdb.rs b/server/src/actions/flushdb.rs index 00754185..798a5e4b 100644 --- a/server/src/actions/flushdb.rs +++ b/server/src/actions/flushdb.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/get.rs b/server/src/actions/get.rs index 335fbe40..abcb70fe 100644 --- a/server/src/actions/get.rs +++ b/server/src/actions/get.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/jget.rs b/server/src/actions/jget.rs index 4ebce9e2..43338ca9 100644 --- a/server/src/actions/jget.rs +++ b/server/src/actions/jget.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/keylen.rs b/server/src/actions/keylen.rs index daf43e90..ab8b3726 100644 --- a/server/src/actions/keylen.rs +++ b/server/src/actions/keylen.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/lskeys.rs b/server/src/actions/lskeys.rs index 0afe26c5..6d4f7100 100644 --- a/server/src/actions/lskeys.rs +++ b/server/src/actions/lskeys.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/mget.rs b/server/src/actions/mget.rs index 0937e285..daae85d0 100644 --- a/server/src/actions/mget.rs +++ b/server/src/actions/mget.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/mod.rs b/server/src/actions/mod.rs index 6abf1243..32d25c4a 100644 --- a/server/src/actions/mod.rs +++ b/server/src/actions/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/mset.rs b/server/src/actions/mset.rs index b511e9cf..3461d82c 100644 --- a/server/src/actions/mset.rs +++ b/server/src/actions/mset.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/mupdate.rs b/server/src/actions/mupdate.rs index b17e9d54..ac27215c 100644 --- a/server/src/actions/mupdate.rs +++ b/server/src/actions/mupdate.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/pop.rs b/server/src/actions/pop.rs index 9beba1cc..5f69567e 100644 --- a/server/src/actions/pop.rs +++ b/server/src/actions/pop.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/set.rs b/server/src/actions/set.rs index 55894b17..283873f1 100644 --- a/server/src/actions/set.rs +++ b/server/src/actions/set.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/strong.rs b/server/src/actions/strong.rs index 5dc07f43..4b002be7 100644 --- a/server/src/actions/strong.rs +++ b/server/src/actions/strong.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/update.rs b/server/src/actions/update.rs index c7c4a0e3..b6264758 100644 --- a/server/src/actions/update.rs +++ b/server/src/actions/update.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/actions/uset.rs b/server/src/actions/uset.rs index 2e4aaa6b..cea4968f 100644 --- a/server/src/actions/uset.rs +++ b/server/src/actions/uset.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/admin/mksnap.rs b/server/src/admin/mksnap.rs index f18c3f67..2208e87e 100644 --- a/server/src/admin/mksnap.rs +++ b/server/src/admin/mksnap.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/admin/mod.rs b/server/src/admin/mod.rs index fd04d0d6..12fb30a0 100644 --- a/server/src/admin/mod.rs +++ b/server/src/admin/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/compat/mod.rs b/server/src/compat/mod.rs index 85212f75..6ebed87d 100644 --- a/server/src/compat/mod.rs +++ b/server/src/compat/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/config/mod.rs b/server/src/config/mod.rs index e9e640b1..a07a0cd1 100644 --- a/server/src/config/mod.rs +++ b/server/src/config/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/coredb/htable.rs b/server/src/coredb/htable.rs index 7b4b86fc..6bb4f354 100644 --- a/server/src/coredb/htable.rs +++ b/server/src/coredb/htable.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/coredb/mod.rs b/server/src/coredb/mod.rs index 4c00af0d..e0c57d9c 100644 --- a/server/src/coredb/mod.rs +++ b/server/src/coredb/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/dbnet/connection.rs b/server/src/dbnet/connection.rs index b5fa6222..f504227d 100644 --- a/server/src/dbnet/connection.rs +++ b/server/src/dbnet/connection.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/dbnet/mod.rs b/server/src/dbnet/mod.rs index 91112b01..d29547c6 100644 --- a/server/src/dbnet/mod.rs +++ b/server/src/dbnet/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/dbnet/tcp.rs b/server/src/dbnet/tcp.rs index e5602b71..59b97cb0 100644 --- a/server/src/dbnet/tcp.rs +++ b/server/src/dbnet/tcp.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/dbnet/tls.rs b/server/src/dbnet/tls.rs index 3dbfa2f5..5eaf10f9 100644 --- a/server/src/dbnet/tls.rs +++ b/server/src/dbnet/tls.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/diskstore/flock.rs b/server/src/diskstore/flock.rs index ad4e2256..242628d4 100644 --- a/server/src/diskstore/flock.rs +++ b/server/src/diskstore/flock.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/diskstore/mod.rs b/server/src/diskstore/mod.rs index dafff487..2a7f635b 100644 --- a/server/src/diskstore/mod.rs +++ b/server/src/diskstore/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/diskstore/snapshot.rs b/server/src/diskstore/snapshot.rs index 82b77ae8..040a659d 100644 --- a/server/src/diskstore/snapshot.rs +++ b/server/src/diskstore/snapshot.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/diskstore/snapstore.rs b/server/src/diskstore/snapstore.rs index 82bd2fd5..5bcab59d 100644 --- a/server/src/diskstore/snapstore.rs +++ b/server/src/diskstore/snapstore.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/main.rs b/server/src/main.rs index e8f8339b..a9c0275d 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/protocol/element.rs b/server/src/protocol/element.rs index 7c5b0aad..fa75c8cb 100644 --- a/server/src/protocol/element.rs +++ b/server/src/protocol/element.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/protocol/mod.rs b/server/src/protocol/mod.rs index 2afca976..5644eeb1 100644 --- a/server/src/protocol/mod.rs +++ b/server/src/protocol/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/protocol/responses.rs b/server/src/protocol/responses.rs index 95a5b6b1..173d8195 100644 --- a/server/src/protocol/responses.rs +++ b/server/src/protocol/responses.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/queryengine/mod.rs b/server/src/queryengine/mod.rs index eecc929f..aa931fe5 100644 --- a/server/src/queryengine/mod.rs +++ b/server/src/queryengine/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/resp/mod.rs b/server/src/resp/mod.rs index 154986ee..86ea7519 100644 --- a/server/src/resp/mod.rs +++ b/server/src/resp/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/services/bgsave.rs b/server/src/services/bgsave.rs index 04907501..91737ff8 100644 --- a/server/src/services/bgsave.rs +++ b/server/src/services/bgsave.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/services/mod.rs b/server/src/services/mod.rs index 6e0c0668..cb04fcde 100644 --- a/server/src/services/mod.rs +++ b/server/src/services/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/services/snapshot.rs b/server/src/services/snapshot.rs index 3bb7d26e..6f820986 100644 --- a/server/src/services/snapshot.rs +++ b/server/src/services/snapshot.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/tests/kvengine.rs b/server/src/tests/kvengine.rs index 1b49f582..5bb9fed3 100644 --- a/server/src/tests/kvengine.rs +++ b/server/src/tests/kvengine.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/server/src/tests/mod.rs b/server/src/tests/mod.rs index 004e321e..01d84e91 100644 --- a/server/src/tests/mod.rs +++ b/server/src/tests/mod.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/sky-bench/src/benchtool.rs b/sky-bench/src/benchtool.rs index c1b6af56..d8d57f02 100644 --- a/sky-bench/src/benchtool.rs +++ b/sky-bench/src/benchtool.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/sky-bench/src/cli.yml b/sky-bench/src/cli.yml index 972a3cef..3cef6256 100644 --- a/sky-bench/src/cli.yml +++ b/sky-bench/src/cli.yml @@ -11,7 +11,7 @@ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License diff --git a/sky-bench/src/main.rs b/sky-bench/src/main.rs index e5925823..32d85a9f 100644 --- a/sky-bench/src/main.rs +++ b/sky-bench/src/main.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/sky-bench/src/testkey.rs b/sky-bench/src/testkey.rs index 74a19f4f..aa9205c7 100644 --- a/sky-bench/src/testkey.rs +++ b/sky-bench/src/testkey.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/sky-bench/src/util.rs b/sky-bench/src/util.rs index c2bdd8f1..12905299 100644 --- a/sky-bench/src/util.rs +++ b/sky-bench/src/util.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/sky-macros/src/lib.rs b/sky-macros/src/lib.rs index 8e9ab4cc..574000b4 100644 --- a/sky-macros/src/lib.rs +++ b/sky-macros/src/lib.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License diff --git a/stress-test/src/linearity_client.rs b/stress-test/src/linearity_client.rs new file mode 100644 index 00000000..77c0f3c5 --- /dev/null +++ b/stress-test/src/linearity_client.rs @@ -0,0 +1,187 @@ +/* + * Created on Fri Jun 18 2021 + * + * This file is a part of Skytable + * Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source + * NoSQL database written by Sayan Nandan ("the Author") with the + * vision to provide flexibility in data modelling without compromising + * on performance, queryability or scalability. + * + * Copyright (c) 2021, Sayan Nandan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * +*/ + +//! # Client linearity tests +//! +//! This module contains functions to test the linearity of the database with increasing number +//! of clients, i.e how the number of queries scale with increasing clients. These functions +//! however, DO NOT focus on benchmarking and instead focus on correctness under load from +//! concurrent clients. +//! + +use crate::logstress; +use crate::{DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV}; +use crossbeam_channel::bounded; +use libstress::rayon::prelude::*; +use libstress::utils::generate_random_string_vector; +use libstress::Workpool; +use skytable::actions::Actions; +use skytable::query; +use skytable::Connection; +use skytable::{Element, Query, RespCode, Response}; + +macro_rules! log_client_linearity { + ($stressid:expr, $counter:expr, $what:expr) => { + log::info!( + "Stress ({}{}) [{}]: Clients: {}; K/V size: {}; Queries: {}", + $stressid, + $counter, + $what, + $counter, + DEFAULT_SIZE_KV, + DEFAULT_QUERY_COUNT + ); + }; +} + +pub fn stress_linearity_concurrent_clients_set( + mut rng: &mut impl rand::Rng, + max_workers: usize, + temp_con: &mut Connection, +) { + logstress!( + "A [SET]", + "Linearity test with monotonically increasing clients" + ); + let mut current_thread_count = 1usize; + + // generate the random k/v pairs + let keys = generate_random_string_vector(DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV, &mut rng, true); + let values: Vec = + generate_random_string_vector(DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV, &mut rng, false); + + // make sure the database is empty + temp_con.flushdb().unwrap(); + while current_thread_count <= max_workers { + log_client_linearity!("A", current_thread_count, "SET"); + // generate the set packets + let set_packs: Vec = keys + .par_iter() + .zip(values.par_iter()) + .map(|(k, v)| query!("SET", k, v)) + .collect(); + let workpool = Workpool::new( + current_thread_count, + || Connection::new("127.0.0.1", 2003).unwrap(), + move |sock, query| { + assert_eq!( + sock.run_simple_query(&query).unwrap(), + Response::Item(Element::RespCode(RespCode::Okay)) + ); + }, + |_| {}, + true, + ); + workpool.execute_and_finish_iter(set_packs); + // clean up the database + temp_con.flushdb().unwrap(); + current_thread_count += 1; + } +} + +pub fn stress_linearity_concurrent_clients_get( + mut rng: &mut impl rand::Rng, + max_workers: usize, + temp_con: &mut Connection, +) { + logstress!( + "A [GET]", + "Linearity test with monotonically increasing clients" + ); + let mut current_thread_count = 1usize; + + // Generate the random k/v pairs + let keys = generate_random_string_vector(DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV, &mut rng, true); + let values: Vec = + generate_random_string_vector(DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV, &mut rng, false); + + // Make sure that the database is empty + temp_con.flushdb().unwrap(); + + // First set the keys + let set_packs: Vec = keys + .par_iter() + .zip(values.par_iter()) + .map(|(k, v)| query!("SET", k, v)) + .collect(); + let workpool = Workpool::new_default_threads( + || Connection::new("127.0.0.1", 2003).unwrap(), + move |sock, query| { + assert_eq!( + sock.run_simple_query(&query).unwrap(), + Response::Item(Element::RespCode(RespCode::Okay)) + ); + }, + |_| {}, + true, + ); + workpool.execute_and_finish_iter(set_packs); + while current_thread_count <= max_workers { + log_client_linearity!("A", current_thread_count, "GET"); + /* + We create a mpmc to receive the results returned. This avoids us using + any kind of locking on the surface which can slow down things + */ + let (tx, rx) = bounded::(DEFAULT_QUERY_COUNT); + + // generate the get packets + let get_packs: Vec = keys.iter().map(|k| query!("GET", k)).collect(); + let wp = Workpool::new( + current_thread_count, + || Connection::new("127.0.0.1", 2003).unwrap(), + move |sock, query| { + let tx = tx.clone(); + tx.send(sock.run_simple_query(&query).unwrap()).unwrap(); + }, + |_| {}, + true, + ); + wp.execute_and_finish_iter(get_packs); + let rets: Vec = rx + .into_iter() + .map(|v| { + if let Response::Item(Element::String(val)) = v { + val + } else { + panic!("Unexpected response from server"); + } + }) + .collect(); + assert_eq!( + rets.len(), + values.len(), + "Incorrect number of values returned by server" + ); + + // now evaluate them + assert!( + rets.into_par_iter().all(|v| values.contains(&v)), + "Values returned by the server don't match what was sent" + ); + current_thread_count += 1; + } + temp_con.flushdb().unwrap(); +} diff --git a/stress-test/src/main.rs b/stress-test/src/main.rs index 59eeb9bb..ebbaa9d0 100644 --- a/stress-test/src/main.rs +++ b/stress-test/src/main.rs @@ -16,7 +16,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License @@ -27,19 +27,14 @@ #![deny(unused_crate_dependencies)] #![deny(unused_imports)] -use crossbeam_channel::bounded; -use libstress::rayon::prelude::*; use libstress::traits::ExitError; -use libstress::utils::generate_random_string_vector; -use libstress::Workpool; use log::{info, trace, warn}; use rand::thread_rng; -use skytable::actions::Actions; -use skytable::query; use skytable::Connection; -use skytable::{Element, Query, RespCode, Response}; use std::env; use sysinfo::{RefreshKind, System, SystemExt}; +mod linearity_client; +mod utils; pub const DEFAULT_SIZE_KV: usize = 4; pub const DEFAULT_QUERY_COUNT: usize = 100_000_usize; @@ -51,27 +46,16 @@ macro_rules! logstress { }; } -#[macro_export] -macro_rules! log_client_linearity { - ($stressid:expr, $counter:expr, $what:expr) => { - log::info!( - "Stress ({}{}) [{}]: Clients: {}; K/V size: {}; Queries: {}", - $stressid, - $counter, - $what, - $counter, - DEFAULT_SIZE_KV, - DEFAULT_QUERY_COUNT - ); - }; -} - fn main() { + // Build the logger env_logger::Builder::new() - .parse_filters(&env::var("SKY_LOG").unwrap_or_else(|_| "trace".to_owned())) + .parse_filters(&env::var("SKY_STRESS_LOG").unwrap_or_else(|_| "trace".to_owned())) .init(); warn!("The stress test checks correctness under load and DOES NOT show the true throughput"); + + // get the rng and refresh sysinfo let mut rng = thread_rng(); + // we only need to refresh memory and CPU info; don't waste time syncing other things let to_refresh = RefreshKind::new().with_memory().with_cpu(); let mut sys = System::new_with_specifics(to_refresh); sys.refresh_specifics(to_refresh); @@ -80,179 +64,25 @@ fn main() { .exit_error("Failed to get physical core count"); let max_workers = core_count * 2; trace!( - "This host has {} logical cores. Will spawn a maximum of {} workers", + "This host has {} logical cores. Will spawn a maximum of {} threads", core_count, max_workers * 2 ); + + // establish a connection to ensure sanity let mut temp_con = Connection::new("127.0.0.1", 2003).exit_error("Failed to connect to server"); - stress_linearity_concurrent_clients_set(&mut rng, max_workers, &mut temp_con); - stress_linearity_concurrent_clients_get(&mut rng, max_workers, &mut temp_con); - let max_keylen = calculate_max_keylen(DEFAULT_QUERY_COUNT, &mut sys); + + // calculate the maximum keylen + let max_keylen = utils::calculate_max_keylen(DEFAULT_QUERY_COUNT, &mut sys); info!( "This host can support a maximum theoretical keylen of: {}", max_keylen ); - info!("SUCCESS. Stress test complete!"); -} - -fn stress_linearity_concurrent_clients_set( - mut rng: &mut impl rand::Rng, - max_workers: usize, - temp_con: &mut Connection, -) { - logstress!( - "A [SET]", - "Linearity test with monotonically increasing clients" - ); - - // generate the random k/v pairs - let keys = generate_random_string_vector(DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV, &mut rng, true); - let values: Vec = - generate_random_string_vector(DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV, &mut rng, false); - let mut current_thread_count = 1usize; - - // make sure the database is empty - temp_con.flushdb().unwrap(); - while current_thread_count <= max_workers { - log_client_linearity!("A", current_thread_count, "SET"); - - // generate the set packets - let set_packs: Vec = keys - .par_iter() - .zip(values.par_iter()) - .map(|(k, v)| query!("SET", k, v)) - .collect(); - let workpool = Workpool::new( - current_thread_count, - || Connection::new("127.0.0.1", 2003).unwrap(), - move |sock, query| { - assert_eq!( - sock.run_simple_query(&query).unwrap(), - Response::Item(Element::RespCode(RespCode::Okay)) - ); - }, - |_| {}, - true, - ); - workpool.execute_and_finish_iter(set_packs); - // clean up the database - temp_con.flushdb().unwrap(); - current_thread_count += 1; - } -} - -fn stress_linearity_concurrent_clients_get( - mut rng: &mut impl rand::Rng, - max_workers: usize, - temp_con: &mut Connection, -) { - logstress!( - "A [GET]", - "Linearity test with monotonically increasing clients" - ); - let mut current_thread_count = 1usize; - // Generate the random k/v pairs - let keys = generate_random_string_vector(DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV, &mut rng, true); - let values: Vec = - generate_random_string_vector(DEFAULT_QUERY_COUNT, DEFAULT_SIZE_KV, &mut rng, false); - - // Make sure that the database is empty - temp_con.flushdb().unwrap(); - - // First set the keys - let set_packs: Vec = keys - .par_iter() - .zip(values.par_iter()) - .map(|(k, v)| query!("SET", k, v)) - .collect(); - let workpool = Workpool::new_default_threads( - || Connection::new("127.0.0.1", 2003).unwrap(), - move |sock, query| { - assert_eq!( - sock.run_simple_query(&query).unwrap(), - Response::Item(Element::RespCode(RespCode::Okay)) - ); - }, - |_| {}, - true, - ); - workpool.execute_and_finish_iter(set_packs); - while current_thread_count <= max_workers { - log_client_linearity!("A", current_thread_count, "GET"); - /* - We create a mpmc to receive the results returned. This avoids us using - any kind of locking on the surface which can slow down things - */ - let (tx, rx) = bounded::(DEFAULT_QUERY_COUNT); + // run the actual stress tests + linearity_client::stress_linearity_concurrent_clients_set(&mut rng, max_workers, &mut temp_con); + linearity_client::stress_linearity_concurrent_clients_get(&mut rng, max_workers, &mut temp_con); - // generate the get packets - let get_packs: Vec = keys.iter().map(|k| query!("GET", k)).collect(); - let wp = Workpool::new( - current_thread_count, - || Connection::new("127.0.0.1", 2003).unwrap(), - move |sock, query| { - let tx = tx.clone(); - tx.send(sock.run_simple_query(&query).unwrap()).unwrap(); - }, - |_| {}, - true, - ); - wp.execute_and_finish_iter(get_packs); - let rets: Vec = rx - .into_iter() - .map(|v| { - if let Response::Item(Element::String(val)) = v { - val - } else { - panic!("Unexpected response from server"); - } - }) - .collect(); - assert_eq!( - rets.len(), - values.len(), - "Incorrect number of values returned by server" - ); - - // now evaluate them - assert!( - rets.into_par_iter().all(|v| values.contains(&v)), - "Values returned by the server don't match what was sent" - ); - current_thread_count += 1; - } - temp_con.flushdb().unwrap(); -} - -fn calculate_max_keylen(expected_queries: usize, sys: &mut System) -> usize { - let total_mem_in_bytes = (sys.get_total_memory() * 1024) as usize; - trace!( - "This host has a total memory of: {} Bytes", - total_mem_in_bytes - ); - // av_mem gives us 90% of the memory size - let ninety_percent_of_memory = (0.90_f32 * total_mem_in_bytes as f32) as usize; - let mut highest_len = 1usize; - loop { - let set_pack_len = Query::array_packet_size_hint(vec![3, highest_len, highest_len]); - let get_pack_len = Query::array_packet_size_hint(vec![3, highest_len]); - let resulting_size = expected_queries - * ( - // for the set packets - set_pack_len + - // for the get packets - get_pack_len + - // for the keys themselves - highest_len - ); - if resulting_size >= ninety_percent_of_memory as usize { - break; - } - // increase the length by 5% every time to get the maximum possible length - // now this 5% increment is a tradeoff, but it's worth it to not wait for - // so long - highest_len = (highest_len as f32 * 1.05_f32).ceil() as usize; - } - highest_len + // done, exit + info!("SUCCESS. Stress test complete!"); } diff --git a/stress-test/src/utils.rs b/stress-test/src/utils.rs new file mode 100644 index 00000000..b54aa59f --- /dev/null +++ b/stress-test/src/utils.rs @@ -0,0 +1,60 @@ +/* + * Created on Fri Jun 18 2021 + * + * This file is a part of Skytable + * Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source + * NoSQL database written by Sayan Nandan ("the Author") with the + * vision to provide flexibility in data modelling without compromising + * on performance, queryability or scalability. + * + * Copyright (c) 2021, Sayan Nandan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * +*/ +use log::trace; +use skytable::Query; +use sysinfo::{System, SystemExt}; + +pub fn calculate_max_keylen(expected_queries: usize, sys: &mut System) -> usize { + let total_mem_in_bytes = (sys.get_total_memory() * 1024) as usize; + trace!( + "This host has a total memory of: {} Bytes", + total_mem_in_bytes + ); + // av_mem gives us 90% of the memory size + let ninety_percent_of_memory = (0.90_f32 * total_mem_in_bytes as f32) as usize; + let mut highest_len = 1usize; + loop { + let set_pack_len = Query::array_packet_size_hint(vec![3, highest_len, highest_len]); + let get_pack_len = Query::array_packet_size_hint(vec![3, highest_len]); + let resulting_size = expected_queries + * ( + // for the set packets + set_pack_len + + // for the get packets + get_pack_len + + // for the keys themselves + highest_len + ); + if resulting_size >= ninety_percent_of_memory as usize { + break; + } + // increase the length by 5% every time to get the maximum possible length + // now this 5% increment is a tradeoff, but it's worth it to not wait for + // so long + highest_len = (highest_len as f32 * 1.05_f32).ceil() as usize; + } + highest_len +}