From d6f8c7b68ef4759a6d6ee8ac684532650c6d70c6 Mon Sep 17 00:00:00 2001 From: Cal Date: Fri, 9 Jun 2023 17:27:36 +0100 Subject: [PATCH 1/3] Add perf benchmarks --- Cargo.lock | 459 ++++++++++++++++++++++++++++++++++++- polybase/Cargo.toml | 7 + polybase/benches/bench.rs | 207 +++++++++++++++++ polybase/benches/bench.svg | 280 ++++++++++++++++++++++ polybase/src/db.rs | 2 +- 5 files changed, 949 insertions(+), 6 deletions(-) create mode 100644 polybase/benches/bench.rs create mode 100644 polybase/benches/bench.svg diff --git a/Cargo.lock b/Cargo.lock index 682c6890..541e1587 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,6 +441,15 @@ version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + [[package]] name = "arc-swap" version = "1.6.0" @@ -905,6 +914,12 @@ version = "3.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" + [[package]] name = "byteorder" version = "1.4.3" @@ -1161,6 +1176,21 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "colorchoice" version = "1.0.0" @@ -1186,6 +1216,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "const-cstr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6" + [[package]] name = "const-oid" version = "0.9.2" @@ -1231,6 +1267,43 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "core-graphics" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +dependencies = [ + "bitflags", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +dependencies = [ + "bitflags", + "core-foundation", + "foreign-types", + "libc", +] + +[[package]] +name = "core-text" +version = "19.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25" +dependencies = [ + "core-foundation", + "core-graphics", + "foreign-types", + "libc", +] + [[package]] name = "core2" version = "0.4.0" @@ -1621,7 +1694,7 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version", + "rustc_version 0.4.0", "syn 1.0.109", ] @@ -1703,6 +1776,27 @@ dependencies = [ "syn 2.0.16", ] +[[package]] +name = "dlib" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" +dependencies = [ + "libloading", +] + +[[package]] +name = "dwrote" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" +dependencies = [ + "lazy_static", + "libc", + "winapi", + "wio", +] + [[package]] name = "ecdsa" version = "0.14.8" @@ -1855,6 +1949,15 @@ dependencies = [ "instant", ] +[[package]] +name = "fdeflate" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +dependencies = [ + "simd-adler32", +] + [[package]] name = "ff" version = "0.12.1" @@ -1899,12 +2002,43 @@ dependencies = [ "miniz_oxide 0.7.1", ] +[[package]] +name = "float-ord" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "font-kit" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21fe28504d371085fae9ac7a3450f0b289ab71e07c8e57baa3fb68b9e57d6ce5" +dependencies = [ + "bitflags", + "byteorder", + "core-foundation", + "core-graphics", + "core-text", + "dirs-next", + "dwrote", + "float-ord", + "freetype", + "lazy_static", + "libc", + "log", + "pathfinder_geometry", + "pathfinder_simd", + "walkdir", + "winapi", + "yeslogic-fontconfig-sys", +] + [[package]] name = "foreign-types" version = "0.3.2" @@ -1929,6 +2063,27 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "freetype" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee38378a9e3db1cc693b4f88d166ae375338a0ff75cb8263e1c601d51f35dc6" +dependencies = [ + "freetype-sys", + "libc", +] + +[[package]] +name = "freetype-sys" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" +dependencies = [ + "cmake", + "libc", + "pkg-config", +] + [[package]] name = "fslock" version = "0.1.8" @@ -2130,6 +2285,16 @@ dependencies = [ "polyval 0.6.0", ] +[[package]] +name = "gif" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06" +dependencies = [ + "color_quant", + "weezl", +] + [[package]] name = "gimli" version = "0.27.2" @@ -2427,6 +2592,21 @@ dependencies = [ "windows 0.34.0", ] +[[package]] +name = "image" +version = "0.24.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527909aa81e20ac3a44803521443a765550f09b5130c2c2fa1ea59c2f8f50a3a" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "jpeg-decoder", + "num-rational", + "num-traits", + "png", +] + [[package]] name = "indexer" version = "0.6.2" @@ -2568,6 +2748,12 @@ dependencies = [ "libc", ] +[[package]] +name = "jpeg-decoder" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" + [[package]] name = "js-sys" version = "0.3.63" @@ -2657,6 +2843,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + [[package]] name = "libp2p" version = "0.51.3" @@ -3064,6 +3256,16 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" +[[package]] +name = "matrixmultiply" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" +dependencies = [ + "autocfg", + "rawpointer", +] + [[package]] name = "md-5" version = "0.10.5" @@ -3125,6 +3327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", + "simd-adler32", ] [[package]] @@ -3233,6 +3436,35 @@ dependencies = [ "unsigned-varint", ] +[[package]] +name = "nalgebra" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d506eb7e08d6329505faa8a3a00a5dcc6de9f76e0c77e4b75763ae3c770831ff" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational", + "num-traits", + "rand 0.8.5", + "rand_distr", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -3362,6 +3594,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-complex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +dependencies = [ + "num-traits", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -3372,6 +3613,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -3379,6 +3631,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", + "libm 0.2.7", ] [[package]] @@ -3535,7 +3788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" dependencies = [ "cfg-if", - "libm", + "libm 0.1.4", ] [[package]] @@ -3576,6 +3829,25 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +[[package]] +name = "pathfinder_geometry" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b7e7b4ea703700ce73ebf128e1450eb69c3a8329199ffbfb9b2a0418e5ad3" +dependencies = [ + "log", + "pathfinder_simd", +] + +[[package]] +name = "pathfinder_simd" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39fe46acc5503595e5949c17b818714d26fdf9b4920eacf3b2947f0199f4a6ff" +dependencies = [ + "rustc_version 0.3.3", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -3606,6 +3878,16 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +[[package]] +name = "pest" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" +dependencies = [ + "thiserror", + "ucd-trie", +] + [[package]] name = "petgraph" version = "0.6.3" @@ -3685,9 +3967,16 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ + "chrono", + "font-kit", + "image", + "lazy_static", "num-traits", + "pathfinder_geometry", "plotters-backend", + "plotters-bitmap", "plotters-svg", + "ttf-parser", "wasm-bindgen", "web-sys", ] @@ -3698,6 +3987,17 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" +[[package]] +name = "plotters-bitmap" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4a1f21490a6cf4a84c272ad20bd7844ed99a3178187a4c5ab7f2051295beef" +dependencies = [ + "gif", + "image", + "plotters-backend", +] + [[package]] name = "plotters-svg" version = "0.3.3" @@ -3707,6 +4007,19 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "png" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaeebc51f9e7d2c150d3f3bfeb667f2aa985db5ef1e3d212847bdedb488beeaa" +dependencies = [ + "bitflags", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.7.1", +] + [[package]] name = "polling" version = "2.8.0" @@ -3764,6 +4077,8 @@ dependencies = [ "libp2p-quic", "once_cell", "parking_lot", + "plotters", + "plotters-svg", "prost", "prost-build", "rand 0.8.5", @@ -3782,6 +4097,7 @@ dependencies = [ "slog-stdlog", "slog-term", "solid", + "statrs", "tempfile", "thiserror", "tokio", @@ -4092,6 +4408,16 @@ dependencies = [ "getrandom 0.2.9", ] +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -4101,6 +4427,12 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + [[package]] name = "rayon" version = "1.7.0" @@ -4343,13 +4675,22 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver", + "semver 1.0.17", ] [[package]] @@ -4423,6 +4764,15 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +[[package]] +name = "safe_arch" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62a7484307bd40f8f7ccbacccac730108f2cae119a3b11c74485b48aa9ea650f" +dependencies = [ + "bytemuck", +] + [[package]] name = "same-file" version = "1.0.6" @@ -4535,12 +4885,30 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + [[package]] name = "semver" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "sentry" version = "0.30.0" @@ -4580,7 +4948,7 @@ dependencies = [ "hostname", "libc", "os_info", - "rustc_version", + "rustc_version 0.4.0", "sentry-core", "uname", ] @@ -4790,6 +5158,25 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "simba" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0b7840f121a46d63066ee7a99fc81dcabbc6105e437cae43528cea199b5a05f" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] + +[[package]] +name = "simd-adler32" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" + [[package]] name = "siphasher" version = "0.3.10" @@ -4888,7 +5275,7 @@ dependencies = [ "curve25519-dalek 4.0.0-rc.1", "rand_core 0.6.4", "ring", - "rustc_version", + "rustc_version 0.4.0", "sha2 0.10.6", "subtle", ] @@ -4951,6 +5338,19 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "statrs" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d08e5e1748192713cc281da8b16924fb46be7b0c2431854eadc785823e5696e" +dependencies = [ + "approx", + "lazy_static", + "nalgebra", + "num-traits", + "rand 0.8.5", +] + [[package]] name = "string_cache" version = "0.8.7" @@ -5496,6 +5896,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "ttf-parser" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd" + [[package]] name = "turn" version = "0.6.1" @@ -5521,6 +5927,12 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "ucd-trie" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + [[package]] name = "uint" version = "0.9.5" @@ -6040,6 +6452,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "weezl" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + [[package]] name = "which" version = "4.4.0" @@ -6051,6 +6469,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "wide" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40018623e2dba2602a9790faba8d33f2ebdebf4b86561b83928db735f8784728" +dependencies = [ + "bytemuck", + "safe_arch", +] + [[package]] name = "widestring" version = "0.5.1" @@ -6323,6 +6751,15 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f0dbf7ca6aa5893b59928718bf1e7dbe7279bb277b5aa4c4898ddf5004f9417" +[[package]] +name = "wio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" +dependencies = [ + "winapi", +] + [[package]] name = "x25519-dalek" version = "1.1.1" @@ -6405,6 +6842,18 @@ dependencies = [ "time 0.3.21", ] +[[package]] +name = "yeslogic-fontconfig-sys" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2bbd69036d397ebbff671b1b8e4d918610c181c5a16073b96f984a38d08c386" +dependencies = [ + "const-cstr", + "dlib", + "once_cell", + "pkg-config", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/polybase/Cargo.toml b/polybase/Cargo.toml index d100e0f8..5d933697 100644 --- a/polybase/Cargo.toml +++ b/polybase/Cargo.toml @@ -73,8 +73,15 @@ url = "*" once_cell = "1" urlencoding = "2" base64 = "0.21" +plotters = "0.3.4" +plotters-svg = "0.3.3" +statrs = "0.16.0" [build-dependencies] tonic-build = "0.8.4" prost-build = "0.11.9" + +[[bench]] +name = "bench" +harness = false diff --git a/polybase/benches/bench.rs b/polybase/benches/bench.rs new file mode 100644 index 00000000..d4d3f25e --- /dev/null +++ b/polybase/benches/bench.rs @@ -0,0 +1,207 @@ +use futures::future::try_join_all; +use plotters::prelude::*; +// use reqwest::Client; +use serde_json::json; +use statrs::statistics::Statistics; +use std::fs; +use std::path::Path; +use std::sync::Arc; +use std::time::{Instant, SystemTime}; + +pub struct BenchResult { + total_duration: f64, + avg_duration: f64, + variance_duration: f64, + std_dev_duration: f64, + throughput: f64, + durations: Vec, +} + +#[tokio::main] +async fn main() { + let base_url = "http://localhost:8080"; + + // client hangs on 100k on MacOS + for n in [1, 10, 100, 1000] { + let BenchResult { + total_duration, + avg_duration, + variance_duration, + std_dev_duration, + throughput, + .. + } = create_records(n, base_url).await; + + println!("Took {}s to create {n} records", total_duration); + println!(" Average duration: {} seconds", avg_duration); + println!(" Variance deviation: {} seconds", variance_duration); + println!(" Standard deviation: {} seconds", std_dev_duration); + println!(" Throughput: {} requests per second", throughput); + } +} + +async fn create_records(n: u64, base_url: &str) -> BenchResult { + let client = reqwest::Client::builder() + // .http2_prior_knowledge() + .build() + .unwrap(); + + let collection_id = create_collection(base_url).await; + + let mut handles = Vec::new(); + let collection_id = Arc::new(collection_id.replace('/', "%2F")); + let base_url = Arc::new(base_url.to_string()); + let now = Arc::new( + SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs(), + ); + + for i in 0..n { + let client = client.clone(); + let base_url = Arc::clone(&base_url); + let collection_id = Arc::clone(&collection_id); + let now = Arc::clone(&now); + + let handle = tokio::spawn(async move { + let json_body = json!({ + "args": [format!("{}", *now + i)], + }); + + let url = format!("{}/v0/collections/{}/records", &base_url, &collection_id); + + let start = Instant::now(); + // let response = client.get("http://localhost:8080").send().await.unwrap(); + let response = client.post(url).json(&json_body).send().await.unwrap(); + let duration = start.elapsed(); + + // Make sure the request was successful + assert!(response.status().is_success()); + + duration.as_secs_f64() + }); + handles.push(handle); + } + + let all_start = std::time::Instant::now(); + let durations = try_join_all(handles).await.unwrap(); + let total_duration = all_start.elapsed(); + let varience = durations.clone().variance(); + + BenchResult { + total_duration: total_duration.as_secs_f64(), + avg_duration: durations.clone().mean(), + variance_duration: varience, + std_dev_duration: varience.sqrt(), + throughput: n as f64 / total_duration.as_secs_f64(), + durations, + } +} + +// async fn send_with_success(req: reqwest::RequestBuilder) -> Result<(), Box> { +// match req.send().await { +// Ok(x) if x.status().as_u16() < 300 => Ok(()), +// Ok(x) => Err(format!( +// "Unexpected status code: {}, body: {:?}", +// x.status(), +// x.text().await.unwrap() +// ) +// .into()), +// Err(e) => Err(e.into()), +// } +// } + +async fn create_collection(base_url: &str) -> String { + let client = reqwest::Client::builder().build().unwrap(); + + let random_id = rand::random::(); + let id = format!("polybase/bench/{}/SampleCollection", &random_id); + let req = client + .post(format!("{base_url}/v0/collections/Collection/records")) + .json(&serde_json::json!({ + "args": [&id, r#" + collection SampleCollection { + id: string; + + constructor (id: string) { + this.id = id; + } + } + "#], + })); + + req.send() + .await + .unwrap() + .json::() + .await + .unwrap(); + + id +} + +async fn generate_chart(name: String, durations: Vec, num_bins: usize) { + let current_file = file!(); + let project_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap(); + let absolute_current_file = fs::canonicalize(project_root.join(current_file)).unwrap(); + let current_dir = absolute_current_file.parent().unwrap(); + + let svg_path = current_dir.join(name); + + println!("Plotting histogram to {:?}", svg_path); + + // Plotting histogram + let root = SVGBackend::new(svg_path.to_str().unwrap(), (640, 480)).into_drawing_area(); + root.fill(&WHITE).unwrap(); + + let max_duration = *durations + .iter() + .max_by(|a, b| a.partial_cmp(b).unwrap()) + .unwrap(); + let min_duration = *durations + .iter() + .min_by(|a, b| a.partial_cmp(b).unwrap()) + .unwrap(); + + let mut chart = ChartBuilder::on(&root) + // .caption("Histogram of Request Durations", ("", 50).into_font()) + .margin(5) + .x_label_area_size(30) + .y_label_area_size(30) + .build_cartesian_2d(min_duration..max_duration, 0usize..400usize) + .unwrap(); + + chart.configure_mesh().draw().unwrap(); + + let histogram = durations.iter().fold(vec![0; num_bins], |mut acc, &v| { + let index = + ((v - min_duration) / (max_duration - min_duration) * (num_bins as f64) - 1.0) as usize; + acc[index] += 1; + acc + }); + + chart + .draw_series(histogram.into_iter().zip(0..).map(|(y, x)| { + Rectangle::new( + [ + ( + (x as f64 / num_bins as f64) * (max_duration - min_duration) + + min_duration + + 0.0001, + 0, + ), + ( + ((x + 1) as f64 / num_bins as f64) * (max_duration - min_duration) + + min_duration + - 0.0001, + y, + ), + ], + BLUE.filled(), + ) + })) + .unwrap(); + + root.present().unwrap(); +} diff --git a/polybase/benches/bench.svg b/polybase/benches/bench.svg new file mode 100644 index 00000000..2a5a3c43 --- /dev/null +++ b/polybase/benches/bench.svg @@ -0,0 +1,280 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 + + + +50 + + + +100 + + + +150 + + + +200 + + + +250 + + + +300 + + + +350 + + + +400 + + + + +0.03 + + + +0.04 + + + +0.05 + + + +0.06 + + + +0.07 + + + +0.08 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/polybase/src/db.rs b/polybase/src/db.rs index d3a36e48..2b6816c4 100644 --- a/polybase/src/db.rs +++ b/polybase/src/db.rs @@ -95,7 +95,7 @@ pub struct Db { impl Db { pub fn new(root_dir: String, logger: slog::Logger, config: DbConfig) -> Result { - let (sender, receiver) = mpsc::channel::(100); + let (sender, receiver) = mpsc::channel::(10000); // Create the indexer #[allow(clippy::unwrap_used)] From 3db56b7ee55d8a23a546ad3a12115223d5faf8fd Mon Sep 17 00:00:00 2001 From: Cal Date: Sun, 11 Jun 2023 13:37:44 +0100 Subject: [PATCH 2/3] Improve metrics output + charts --- .gitignore | 1 + polybase/benches/bench.rs | 38 +++-- polybase/benches/bench.svg | 280 ------------------------------------- 3 files changed, 26 insertions(+), 293 deletions(-) delete mode 100644 polybase/benches/bench.svg diff --git a/.gitignore b/.gitignore index 59c91f17..eab0f8ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target/ .DS_Store /.direnv/ +*/benches/results \ No newline at end of file diff --git a/polybase/benches/bench.rs b/polybase/benches/bench.rs index d4d3f25e..5c5f4e19 100644 --- a/polybase/benches/bench.rs +++ b/polybase/benches/bench.rs @@ -20,16 +20,17 @@ pub struct BenchResult { #[tokio::main] async fn main() { let base_url = "http://localhost:8080"; + // let base_url = "https://prenet.polybase.xyz"; // client hangs on 100k on MacOS - for n in [1, 10, 100, 1000] { + for n in [1, 10, 100, 1000, 5000] { let BenchResult { total_duration, avg_duration, variance_duration, std_dev_duration, throughput, - .. + durations, } = create_records(n, base_url).await; println!("Took {}s to create {n} records", total_duration); @@ -37,6 +38,8 @@ async fn main() { println!(" Variance deviation: {} seconds", variance_duration); println!(" Standard deviation: {} seconds", std_dev_duration); println!(" Throughput: {} requests per second", throughput); + + generate_chart(format!("results/create_records_{}.svg", n), durations, 50); } } @@ -77,7 +80,11 @@ async fn create_records(n: u64, base_url: &str) -> BenchResult { let duration = start.elapsed(); // Make sure the request was successful - assert!(response.status().is_success()); + assert!( + response.status().is_success(), + "Request failed: {:?}", + response.status() + ); duration.as_secs_f64() }); @@ -141,7 +148,7 @@ async fn create_collection(base_url: &str) -> String { id } -async fn generate_chart(name: String, durations: Vec, num_bins: usize) { +fn generate_chart(name: String, durations: Vec, num_bins: usize) { let current_file = file!(); let project_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap(); let absolute_current_file = fs::canonicalize(project_root.join(current_file)).unwrap(); @@ -164,22 +171,27 @@ async fn generate_chart(name: String, durations: Vec, num_bins: usize) { .min_by(|a, b| a.partial_cmp(b).unwrap()) .unwrap(); + let histogram = durations.iter().fold(vec![0; num_bins], |mut acc, &v| { + let index = + ((v - min_duration) / (max_duration - min_duration) * (num_bins as f64) - 1.0) as usize; + acc[index] += 1; + acc + }); + + let max: &usize = histogram.iter().max().unwrap(); + let height = max + max / 10; + let mut chart = ChartBuilder::on(&root) // .caption("Histogram of Request Durations", ("", 50).into_font()) .margin(5) .x_label_area_size(30) .y_label_area_size(30) - .build_cartesian_2d(min_duration..max_duration, 0usize..400usize) + .build_cartesian_2d(min_duration..max_duration, 0usize..height) .unwrap(); chart.configure_mesh().draw().unwrap(); - let histogram = durations.iter().fold(vec![0; num_bins], |mut acc, &v| { - let index = - ((v - min_duration) / (max_duration - min_duration) * (num_bins as f64) - 1.0) as usize; - acc[index] += 1; - acc - }); + let diff = max_duration - min_duration; chart .draw_series(histogram.into_iter().zip(0..).map(|(y, x)| { @@ -188,13 +200,13 @@ async fn generate_chart(name: String, durations: Vec, num_bins: usize) { ( (x as f64 / num_bins as f64) * (max_duration - min_duration) + min_duration - + 0.0001, + + (diff * 0.001), 0, ), ( ((x + 1) as f64 / num_bins as f64) * (max_duration - min_duration) + min_duration - - 0.0001, + - (diff * 0.001), y, ), ], diff --git a/polybase/benches/bench.svg b/polybase/benches/bench.svg deleted file mode 100644 index 2a5a3c43..00000000 --- a/polybase/benches/bench.svg +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0 - - - -50 - - - -100 - - - -150 - - - -200 - - - -250 - - - -300 - - - -350 - - - -400 - - - - -0.03 - - - -0.04 - - - -0.05 - - - -0.06 - - - -0.07 - - - -0.08 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 79a0cba7211aef3558cf6d061ad316a29ceb6d26 Mon Sep 17 00:00:00 2001 From: Cal Date: Sun, 11 Jun 2023 14:00:02 +0100 Subject: [PATCH 3/3] Add txn count to propose log --- polybase/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polybase/src/main.rs b/polybase/src/main.rs index 351cf2ea..d5564e75 100644 --- a/polybase/src/main.rs +++ b/polybase/src/main.rs @@ -492,6 +492,7 @@ async fn main() -> Result<()> { continue; } }; + let txns_len = txns.len(); // Create the proposl manfiest let manifest = ProposalManifest { @@ -506,7 +507,7 @@ async fn main() -> Result<()> { }; let proposal_hash = manifest.hash(); - info!(logger, "Propose"; "leader_id" => manifest.leader_id.prefix(), "hash" => proposal_hash.to_string(), "height" => height, "skips" => skips); + info!(logger, "Propose"; "leader_id" => manifest.leader_id.prefix(), "hash" => proposal_hash.to_string(), "height" => height, "skips" => skips, "txns" => txns_len); // Add proposal to own register, this will trigger an accept solid.receive_proposal(manifest.clone());