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

fix(server): use spawn_blocking when moving from async to sync contexts to prevent threadool deadlock #235

Merged
merged 3 commits into from
Feb 14, 2022

Conversation

jasongoodwin
Copy link
Contributor

@jasongoodwin jasongoodwin commented Feb 9, 2022

Issue resolved here: the Datastore's methods are sync calls from async context w/ tokio runtime.
These should be called w/ block_on, not sync, as there is IO and you want to give the option to the implementor to use async themselves. You need to spawn_blocking on these async/sync barriers!
Any place that you're handing off from the runtime into a synchronous that may potentially block, you need to throw that into spawn_blocking. If the consumers of the Datastore api would ever do any concurrent/async work that needs to block to return to the sync api, then the threadpool can deadlock (eg futures::executor::block_on) or tokio will otherwise panic (eg Handle::block_on).

This change will allow concurrency/asynchronous code to be executed within the Datastore without forcing async trait on the consumer of the api.

For context, see: tokio-rs/tokio#2376
#235 (comment)

Checks run, the benches look marginally worse due to the overhead I think, but i only ran em once and who knows.

@CLAassistant
Copy link

CLAassistant commented Feb 9, 2022

CLA assistant check
All committers have signed the CLA.

proto/src/server.rs Outdated Show resolved Hide resolved
proto/src/server.rs Outdated Show resolved Hide resolved
@jasongoodwin jasongoodwin changed the title DRAFT - fix(server): use spawn_blocking when moving from async to sync contexts to prevent threadool deadlock fix(server): use spawn_blocking when moving from async to sync contexts to prevent threadool deadlock Feb 11, 2022
@jasongoodwin
Copy link
Contributor Author

jasongoodwin commented Feb 11, 2022

Checks pass.

Bench on this branch vs master looks okay despite the small overhead of spawning extra resources into the secondary execution pool. Might be a small cost in the overhead but it's not large and a few runs I'm sure would show a pretty small delta in the average. I suspect ditching the mpsc would yield a better bench on this code. Will try it out.

this:


running 20 tests
test models::edges::tests::should_create_edge_with_current_datetime ... ignored
test models::identifiers::tests::should_convert_str_to_identifier ... ignored
test models::identifiers::tests::should_fail_for_invalid_identifiers ... ignored
test models::queries::tests::should_convert_edge_direction_to_string ... ignored
test models::queries::tests::should_convert_str_to_edge_direction ... ignored
test util::tests::should_generate_nanos_since_epoch ... ignored
test util::tests::should_generate_new_uuid_v1 ... ignored
test util::tests::should_generate_next_uuid ... ignored
test memory::bench_bulk_insert    ... bench:  27,912,554 ns/iter (+/- 2,588,462)
test memory::bench_create_edge    ... bench:         314 ns/iter (+/- 131)
test memory::bench_create_vertex  ... bench:         404 ns/iter (+/- 32)
test memory::bench_get_edge_count ... bench:         112 ns/iter (+/- 12)
test memory::bench_get_edges      ... bench:         352 ns/iter (+/- 42)
test memory::bench_get_vertices   ... bench:         246 ns/iter (+/- 25)
test rdb::bench_bulk_insert       ... bench: 125,513,960 ns/iter (+/- 27,113,742)
test rdb::bench_create_edge       ... bench:      14,785 ns/iter (+/- 6,332)
test rdb::bench_create_vertex     ... bench:       7,347 ns/iter (+/- 2,585)
test rdb::bench_get_edge_count    ... bench:       1,775 ns/iter (+/- 196)
test rdb::bench_get_edges         ... bench:       1,000 ns/iter (+/- 170)
test rdb::bench_get_vertices      ... bench:         786 ns/iter (+/- 119)

test result: ok. 0 passed; 0 failed; 8 ignored; 12 measured; 0 filtered out; finished in 80.11s

cd proto && cargo +nightly bench --features=bench-suite
   Compiling syn v1.0.82
   Compiling log v0.4.14
   Compiling either v1.6.1
   Compiling bytes v1.1.0
   Compiling pin-project-lite v0.2.7
   Compiling futures-core v0.3.18
   Compiling anyhow v1.0.51
   Compiling memchr v2.4.1
   Compiling itoa v0.4.8
   Compiling futures-task v0.3.18
   Compiling futures-util v0.3.18
   Compiling ppv-lite86 v0.2.15
   Compiling futures-sink v0.3.18
   Compiling pin-utils v0.1.0
   Compiling hashbrown v0.11.2
   Compiling fnv v1.0.7
   Compiling semver v1.0.4
   Compiling unicode-segmentation v1.8.0
   Compiling fixedbitset v0.2.0
   Compiling httparse v1.5.1
   Compiling slab v0.4.5
   Compiling futures-channel v0.3.18
   Compiling remove_dir_all v0.5.3
   Compiling tower-service v0.3.1
   Compiling multimap v0.8.3
   Compiling try-lock v0.2.3
   Compiling httpdate v1.0.2
   Compiling async-trait v0.1.51
   Compiling tower-layer v0.3.1
   Compiling base64 v0.13.0
   Compiling percent-encoding v2.1.0
   Compiling glob v0.3.0
   Compiling indexmap v1.7.0
   Compiling tokio v1.14.0
   Compiling libloading v0.7.2
   Compiling tracing-core v0.1.21
   Compiling itertools v0.10.3
   Compiling http v0.2.5
   Compiling heck v0.3.3
   Compiling num_cpus v1.13.0
   Compiling socket2 v0.4.2
   Compiling getrandom v0.2.3
   Compiling which v4.2.2
   Compiling mio v0.7.14
   Compiling want v0.3.0
   Compiling threadpool v1.8.1
   Compiling rand_core v0.6.3
   Compiling prost-build v0.8.0
   Compiling rustc_version v0.4.0
   Compiling petgraph v0.5.1
   Compiling rand_chacha v0.3.1
   Compiling http-body v0.4.4
   Compiling rand v0.8.4
   Compiling indradb-plugin-host v0.1.0 (/Users/jasongoodwin/Development/src/indradb/plugins/host)
   Compiling tempfile v3.2.0
   Compiling tokio-macros v1.6.0
   Compiling prost-derive v0.8.0
   Compiling serde_derive v1.0.130
   Compiling tracing-attributes v0.1.18
   Compiling pin-project-internal v1.0.8
   Compiling async-stream-impl v0.3.2
   Compiling async-stream v0.3.2
   Compiling tracing v0.1.29
   Compiling pin-project v1.0.8
   Compiling tracing-futures v0.2.5
   Compiling prost v0.8.0
   Compiling prost-types v0.8.0
   Compiling serde v1.0.130
   Compiling tonic-build v0.5.2
   Compiling tokio-util v0.6.9
   Compiling tokio-stream v0.1.8
   Compiling tokio-io-timeout v1.1.1
   Compiling h2 v0.3.7
   Compiling tower v0.4.11
   Compiling indradb-proto v3.0.0 (/Users/jasongoodwin/Development/src/indradb/proto)
   Compiling chrono v0.4.19
   Compiling serde_json v1.0.72
   Compiling bincode v1.3.3
   Compiling uuid v0.8.2
   Compiling indradb-lib v3.0.0 (/Users/jasongoodwin/Development/src/indradb/lib)
   Compiling hyper v0.14.15
   Compiling hyper-timeout v0.4.1
   Compiling tonic v0.5.2
    Finished bench [optimized] target(s) in 2m 51s
     Running unittests (/Users/jasongoodwin/Development/src/indradb/target/release/deps/indradb_proto-c50e7df8999a477c)

running 54 tests
test tests::should_bulk_insert ... ignored
test tests::should_bulk_insert_a_redundant_vertex ... ignored
test tests::should_bulk_insert_an_invalid_edge ... ignored
test tests::should_create_a_valid_edge ... ignored
test tests::should_create_vertex_from_type ... ignored
test tests::should_delete_a_valid_edge ... ignored
test tests::should_delete_a_valid_inbound_vertex ... ignored
test tests::should_delete_a_valid_outbound_vertex ... ignored
test tests::should_delete_indexed_edge_property ... ignored
test tests::should_delete_indexed_vertex_property ... ignored
test tests::should_get_a_valid_edge ... ignored
test tests::should_get_a_vertex_count ... ignored
test tests::should_get_all_edge_properties ... ignored
test tests::should_get_all_vertex_properties ... ignored
test tests::should_get_an_edge_count ... ignored
test tests::should_get_an_edge_count_for_an_invalid_edge ... ignored
test tests::should_get_an_edge_count_with_no_type ... ignored
test tests::should_get_an_edge_range ... ignored
test tests::should_get_an_inbound_edge_count ... ignored
test tests::should_get_edges ... ignored
test tests::should_get_edges_piped ... ignored
test tests::should_get_edges_with_no_high ... ignored
test tests::should_get_edges_with_no_low ... ignored
test tests::should_get_edges_with_no_time ... ignored
test tests::should_get_edges_with_no_type ... ignored
test tests::should_get_no_edges_for_an_invalid_range ... ignored
test tests::should_get_no_edges_for_reversed_time ... ignored
test tests::should_get_no_vertices_with_type_filter ... ignored
test tests::should_get_no_vertices_with_zero_limit ... ignored
test tests::should_get_range_vertices ... ignored
test tests::should_get_range_vertices_out_of_range ... ignored
test tests::should_get_single_vertex ... ignored
test tests::should_get_single_vertex_nonexisting ... ignored
test tests::should_get_vertices ... ignored
test tests::should_get_vertices_piped ... ignored
test tests::should_handle_edge_properties ... ignored
test tests::should_handle_vertex_properties ... ignored
test tests::should_index_existing_edge_property ... ignored
test tests::should_index_existing_vertex_property ... ignored
test tests::should_not_create_an_invalid_edge ... ignored
test tests::should_not_delete_an_invalid_edge ... ignored
test tests::should_not_delete_an_invalid_vertex ... ignored
test tests::should_not_delete_invalid_edge_properties ... ignored
test tests::should_not_delete_invalid_vertex_properties ... ignored
test tests::should_not_get_an_invalid_edge ... ignored
test tests::should_not_query_unindexed_edge_property ... ignored
test tests::should_not_query_unindexed_vertex_property ... ignored
test tests::should_not_set_invalid_edge_properties ... ignored
test tests::should_not_set_invalid_vertex_properties ... ignored
test tests::should_query_indexed_edge_property_empty ... ignored
test tests::should_query_indexed_vertex_property_empty ... ignored
test tests::should_sync ... ignored
test tests::should_update_indexed_edge_property ... ignored
test tests::should_update_indexed_vertex_property ... ignored

test result: ok. 0 passed; 0 failed; 54 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests (/Users/jasongoodwin/Development/src/indradb/target/release/deps/api-3b5f57734902791e)

running 6 tests
test bench_bulk_insert    ... bench:  97,599,972 ns/iter (+/- 14,962,092)
test bench_create_edge    ... bench:     158,805 ns/iter (+/- 70,850)
test bench_create_vertex  ... bench:     153,887 ns/iter (+/- 101,325)
test bench_get_edge_count ... bench:     145,608 ns/iter (+/- 23,099)
test bench_get_edges      ... bench:     158,617 ns/iter (+/- 76,222)
test bench_get_vertices   ... bench:     161,664 ns/iter (+/- 78,899)

test result: ok. 0 passed; 0 failed; 0 ignored; 6 measured; 0 filtered out; finished in 47.32s

master:


running 20 tests
test models::edges::tests::should_create_edge_with_current_datetime ... ignored
test models::identifiers::tests::should_convert_str_to_identifier ... ignored
test models::identifiers::tests::should_fail_for_invalid_identifiers ... ignored
test models::queries::tests::should_convert_edge_direction_to_string ... ignored
test models::queries::tests::should_convert_str_to_edge_direction ... ignored
test util::tests::should_generate_nanos_since_epoch ... ignored
test util::tests::should_generate_new_uuid_v1 ... ignored
test util::tests::should_generate_next_uuid ... ignored
test memory::bench_bulk_insert    ... bench:  29,729,578 ns/iter (+/- 8,320,569)
test memory::bench_create_edge    ... bench:         317 ns/iter (+/- 60)
test memory::bench_create_vertex  ... bench:         409 ns/iter (+/- 107)
test memory::bench_get_edge_count ... bench:         118 ns/iter (+/- 21)
test memory::bench_get_edges      ... bench:         344 ns/iter (+/- 37)
test memory::bench_get_vertices   ... bench:         255 ns/iter (+/- 134)
test rdb::bench_bulk_insert       ... bench: 126,908,584 ns/iter (+/- 34,812,573)
test rdb::bench_create_edge       ... bench:      12,773 ns/iter (+/- 4,132)
test rdb::bench_create_vertex     ... bench:       6,965 ns/iter (+/- 2,340)
test rdb::bench_get_edge_count    ... bench:       1,886 ns/iter (+/- 232)
test rdb::bench_get_edges         ... bench:         973 ns/iter (+/- 453)
test rdb::bench_get_vertices      ... bench:         795 ns/iter (+/- 149)

test result: ok. 0 passed; 0 failed; 8 ignored; 12 measured; 0 filtered out; finished in 90.88s

cd proto && cargo +nightly bench --features=bench-suite
   Compiling indradb-plugin-host v0.1.0 (/Users/jasongoodwin/Development/src/indradb/plugins/host)
   Compiling indradb-proto v3.0.0 (/Users/jasongoodwin/Development/src/indradb/proto)
    Finished bench [optimized] target(s) in 1m 27s
     Running unittests (/Users/jasongoodwin/Development/src/indradb/target/release/deps/indradb_proto-c50e7df8999a477c)

running 54 tests
test tests::should_bulk_insert ... ignored
test tests::should_bulk_insert_a_redundant_vertex ... ignored
test tests::should_bulk_insert_an_invalid_edge ... ignored
test tests::should_create_a_valid_edge ... ignored
test tests::should_create_vertex_from_type ... ignored
test tests::should_delete_a_valid_edge ... ignored
test tests::should_delete_a_valid_inbound_vertex ... ignored
test tests::should_delete_a_valid_outbound_vertex ... ignored
test tests::should_delete_indexed_edge_property ... ignored
test tests::should_delete_indexed_vertex_property ... ignored
test tests::should_get_a_valid_edge ... ignored
test tests::should_get_a_vertex_count ... ignored
test tests::should_get_all_edge_properties ... ignored
test tests::should_get_all_vertex_properties ... ignored
test tests::should_get_an_edge_count ... ignored
test tests::should_get_an_edge_count_for_an_invalid_edge ... ignored
test tests::should_get_an_edge_count_with_no_type ... ignored
test tests::should_get_an_edge_range ... ignored
test tests::should_get_an_inbound_edge_count ... ignored
test tests::should_get_edges ... ignored
test tests::should_get_edges_piped ... ignored
test tests::should_get_edges_with_no_high ... ignored
test tests::should_get_edges_with_no_low ... ignored
test tests::should_get_edges_with_no_time ... ignored
test tests::should_get_edges_with_no_type ... ignored
test tests::should_get_no_edges_for_an_invalid_range ... ignored
test tests::should_get_no_edges_for_reversed_time ... ignored
test tests::should_get_no_vertices_with_type_filter ... ignored
test tests::should_get_no_vertices_with_zero_limit ... ignored
test tests::should_get_range_vertices ... ignored
test tests::should_get_range_vertices_out_of_range ... ignored
test tests::should_get_single_vertex ... ignored
test tests::should_get_single_vertex_nonexisting ... ignored
test tests::should_get_vertices ... ignored
test tests::should_get_vertices_piped ... ignored
test tests::should_handle_edge_properties ... ignored
test tests::should_handle_vertex_properties ... ignored
test tests::should_index_existing_edge_property ... ignored
test tests::should_index_existing_vertex_property ... ignored
test tests::should_not_create_an_invalid_edge ... ignored
test tests::should_not_delete_an_invalid_edge ... ignored
test tests::should_not_delete_an_invalid_vertex ... ignored
test tests::should_not_delete_invalid_edge_properties ... ignored
test tests::should_not_delete_invalid_vertex_properties ... ignored
test tests::should_not_get_an_invalid_edge ... ignored
test tests::should_not_query_unindexed_edge_property ... ignored
test tests::should_not_query_unindexed_vertex_property ... ignored
test tests::should_not_set_invalid_edge_properties ... ignored
test tests::should_not_set_invalid_vertex_properties ... ignored
test tests::should_query_indexed_edge_property_empty ... ignored
test tests::should_query_indexed_vertex_property_empty ... ignored
test tests::should_sync ... ignored
test tests::should_update_indexed_edge_property ... ignored
test tests::should_update_indexed_vertex_property ... ignored

test result: ok. 0 passed; 0 failed; 54 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests (/Users/jasongoodwin/Development/src/indradb/target/release/deps/api-3b5f57734902791e)

running 6 tests
test bench_bulk_insert    ... bench: 102,958,540 ns/iter (+/- 30,606,505)
test bench_create_edge    ... bench:     132,912 ns/iter (+/- 77,050)
test bench_create_vertex  ... bench:     133,298 ns/iter (+/- 53,244)
test bench_get_edge_count ... bench:     133,741 ns/iter (+/- 123,292)
test bench_get_edges      ... bench:     155,838 ns/iter (+/- 37,359)
test bench_get_vertices   ... bench:     158,113 ns/iter (+/- 43,011)

@jasongoodwin
Copy link
Contributor Author

jasongoodwin commented Feb 11, 2022

Was able to simplify/improve this a good deal. Pushed a change. Removes any dependency changes as well (preserve lock file etc.)
Here are the updated benchmarks and a run on master as well as my system has more load on it today.
One of the interesting perf characteristics is that running the benches often shows a smaller standard deviation than master. I've run it quite a few times and see that fairly consistently.
It performs better with this likely, generally feel pretty good about what's there at this point.

This pr:


running 20 tests
test models::edges::tests::should_create_edge_with_current_datetime ... ignored
test models::identifiers::tests::should_convert_str_to_identifier ... ignored
test models::identifiers::tests::should_fail_for_invalid_identifiers ... ignored
test models::queries::tests::should_convert_edge_direction_to_string ... ignored
test models::queries::tests::should_convert_str_to_edge_direction ... ignored
test util::tests::should_generate_nanos_since_epoch ... ignored
test util::tests::should_generate_new_uuid_v1 ... ignored
test util::tests::should_generate_next_uuid ... ignored
test memory::bench_bulk_insert    ... bench:  24,959,586 ns/iter (+/- 823,870)
test memory::bench_create_edge    ... bench:         310 ns/iter (+/- 18)
test memory::bench_create_vertex  ... bench:         412 ns/iter (+/- 74)
test memory::bench_get_edge_count ... bench:         128 ns/iter (+/- 113)
test memory::bench_get_edges      ... bench:         350 ns/iter (+/- 64)
test memory::bench_get_vertices   ... bench:         252 ns/iter (+/- 25)
test rdb::bench_bulk_insert       ... bench: 114,459,449 ns/iter (+/- 22,555,909)
test rdb::bench_create_edge       ... bench:      13,290 ns/iter (+/- 3,160)
test rdb::bench_create_vertex     ... bench:       6,572 ns/iter (+/- 2,735)
test rdb::bench_get_edge_count    ... bench:       1,734 ns/iter (+/- 177)
test rdb::bench_get_edges         ... bench:         962 ns/iter (+/- 90)
test rdb::bench_get_vertices      ... bench:         742 ns/iter (+/- 46)

test result: ok. 0 passed; 0 failed; 8 ignored; 12 measured; 0 filtered out; finished in 86.52s

cd proto && cargo +nightly bench --features=bench-suite
   Compiling futures-core v0.3.21
   Compiling futures-channel v0.3.21
   Compiling futures-task v0.3.21
   Compiling futures-sink v0.3.21
   Compiling futures-util v0.3.21
   Compiling futures-io v0.3.21
   Compiling futures-macro v0.3.21
   Compiling indradb-plugin-host v0.1.0 (/Users/jasongoodwin/Development/src/indradb/plugins/host)
   Compiling indradb-proto v3.0.0 (/Users/jasongoodwin/Development/src/indradb/proto)
   Compiling tokio-util v0.6.9
   Compiling tokio-stream v0.1.8
   Compiling async-stream v0.3.2
   Compiling h2 v0.3.7
   Compiling tower v0.4.11
   Compiling futures-executor v0.3.21
   Compiling futures v0.3.21
   Compiling hyper v0.14.15
   Compiling hyper-timeout v0.4.1
   Compiling tonic v0.5.2
    Finished bench [optimized] target(s) in 2m 25s
     Running unittests (/Users/jasongoodwin/Development/src/indradb/target/release/deps/indradb_proto-96fc6b0a6f4d769c)

running 54 tests
test tests::should_bulk_insert ... ignored
test tests::should_bulk_insert_a_redundant_vertex ... ignored
test tests::should_bulk_insert_an_invalid_edge ... ignored
test tests::should_create_a_valid_edge ... ignored
test tests::should_create_vertex_from_type ... ignored
test tests::should_delete_a_valid_edge ... ignored
test tests::should_delete_a_valid_inbound_vertex ... ignored
test tests::should_delete_a_valid_outbound_vertex ... ignored
test tests::should_delete_indexed_edge_property ... ignored
test tests::should_delete_indexed_vertex_property ... ignored
test tests::should_get_a_valid_edge ... ignored
test tests::should_get_a_vertex_count ... ignored
test tests::should_get_all_edge_properties ... ignored
test tests::should_get_all_vertex_properties ... ignored
test tests::should_get_an_edge_count ... ignored
test tests::should_get_an_edge_count_for_an_invalid_edge ... ignored
test tests::should_get_an_edge_count_with_no_type ... ignored
test tests::should_get_an_edge_range ... ignored
test tests::should_get_an_inbound_edge_count ... ignored
test tests::should_get_edges ... ignored
test tests::should_get_edges_piped ... ignored
test tests::should_get_edges_with_no_high ... ignored
test tests::should_get_edges_with_no_low ... ignored
test tests::should_get_edges_with_no_time ... ignored
test tests::should_get_edges_with_no_type ... ignored
test tests::should_get_no_edges_for_an_invalid_range ... ignored
test tests::should_get_no_edges_for_reversed_time ... ignored
test tests::should_get_no_vertices_with_type_filter ... ignored
test tests::should_get_no_vertices_with_zero_limit ... ignored
test tests::should_get_range_vertices ... ignored
test tests::should_get_range_vertices_out_of_range ... ignored
test tests::should_get_single_vertex ... ignored
test tests::should_get_single_vertex_nonexisting ... ignored
test tests::should_get_vertices ... ignored
test tests::should_get_vertices_piped ... ignored
test tests::should_handle_edge_properties ... ignored
test tests::should_handle_vertex_properties ... ignored
test tests::should_index_existing_edge_property ... ignored
test tests::should_index_existing_vertex_property ... ignored
test tests::should_not_create_an_invalid_edge ... ignored
test tests::should_not_delete_an_invalid_edge ... ignored
test tests::should_not_delete_an_invalid_vertex ... ignored
test tests::should_not_delete_invalid_edge_properties ... ignored
test tests::should_not_delete_invalid_vertex_properties ... ignored
test tests::should_not_get_an_invalid_edge ... ignored
test tests::should_not_query_unindexed_edge_property ... ignored
test tests::should_not_query_unindexed_vertex_property ... ignored
test tests::should_not_set_invalid_edge_properties ... ignored
test tests::should_not_set_invalid_vertex_properties ... ignored
test tests::should_query_indexed_edge_property_empty ... ignored
test tests::should_query_indexed_vertex_property_empty ... ignored
test tests::should_sync ... ignored
test tests::should_update_indexed_edge_property ... ignored
test tests::should_update_indexed_vertex_property ... ignored

test result: ok. 0 passed; 0 failed; 54 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests (/Users/jasongoodwin/Development/src/indradb/target/release/deps/api-f54096e5f5e23ea3)

running 6 tests
test bench_bulk_insert    ... bench: 104,566,578 ns/iter (+/- 19,864,489)
test bench_create_edge    ... bench:     171,263 ns/iter (+/- 117,464)
test bench_create_vertex  ... bench:     168,362 ns/iter (+/- 37,990)
test bench_get_edge_count ... bench:     156,734 ns/iter (+/- 38,502)
test bench_get_edges      ... bench:     151,613 ns/iter (+/- 20,964)
test bench_get_vertices   ... bench:     154,948 ns/iter (+/- 63,199)

test result: ok. 0 passed; 0 failed; 0 ignored; 6 measured; 0 filtered out; finished in 58.26s

master:


running 20 tests
test models::edges::tests::should_create_edge_with_current_datetime ... ignored
test models::identifiers::tests::should_convert_str_to_identifier ... ignored
test models::identifiers::tests::should_fail_for_invalid_identifiers ... ignored
test models::queries::tests::should_convert_edge_direction_to_string ... ignored
test models::queries::tests::should_convert_str_to_edge_direction ... ignored
test util::tests::should_generate_nanos_since_epoch ... ignored
test util::tests::should_generate_new_uuid_v1 ... ignored
test util::tests::should_generate_next_uuid ... ignored
test memory::bench_bulk_insert    ... bench:  26,142,771 ns/iter (+/- 4,141,073)
test memory::bench_create_edge    ... bench:         305 ns/iter (+/- 16)
test memory::bench_create_vertex  ... bench:         390 ns/iter (+/- 38)
test memory::bench_get_edge_count ... bench:         111 ns/iter (+/- 8)
test memory::bench_get_edges      ... bench:         338 ns/iter (+/- 29)
test memory::bench_get_vertices   ... bench:         244 ns/iter (+/- 22)
test rdb::bench_bulk_insert       ... bench: 111,842,546 ns/iter (+/- 29,408,929)
test rdb::bench_create_edge       ... bench:      13,260 ns/iter (+/- 4,822)
test rdb::bench_create_vertex     ... bench:       6,651 ns/iter (+/- 2,574)
test rdb::bench_get_edge_count    ... bench:       2,356 ns/iter (+/- 3,135)
test rdb::bench_get_edges         ... bench:       2,181 ns/iter (+/- 14,140)
test rdb::bench_get_vertices      ... bench:         767 ns/iter (+/- 67)

test result: ok. 0 passed; 0 failed; 8 ignored; 12 measured; 0 filtered out; finished in 90.46s

cd proto && cargo +nightly bench --features=bench-suite
   Compiling indradb-plugin-host v0.1.0 (/Users/jasongoodwin/Development/src/indradb/plugins/host)
   Compiling indradb-proto v3.0.0 (/Users/jasongoodwin/Development/src/indradb/proto)
    Finished bench [optimized] target(s) in 1m 26s
     Running unittests (/Users/jasongoodwin/Development/src/indradb/target/release/deps/indradb_proto-c50e7df8999a477c)

running 54 tests
test tests::should_bulk_insert ... ignored
test tests::should_bulk_insert_a_redundant_vertex ... ignored
test tests::should_bulk_insert_an_invalid_edge ... ignored
test tests::should_create_a_valid_edge ... ignored
test tests::should_create_vertex_from_type ... ignored
test tests::should_delete_a_valid_edge ... ignored
test tests::should_delete_a_valid_inbound_vertex ... ignored
test tests::should_delete_a_valid_outbound_vertex ... ignored
test tests::should_delete_indexed_edge_property ... ignored
test tests::should_delete_indexed_vertex_property ... ignored
test tests::should_get_a_valid_edge ... ignored
test tests::should_get_a_vertex_count ... ignored
test tests::should_get_all_edge_properties ... ignored
test tests::should_get_all_vertex_properties ... ignored
test tests::should_get_an_edge_count ... ignored
test tests::should_get_an_edge_count_for_an_invalid_edge ... ignored
test tests::should_get_an_edge_count_with_no_type ... ignored
test tests::should_get_an_edge_range ... ignored
test tests::should_get_an_inbound_edge_count ... ignored
test tests::should_get_edges ... ignored
test tests::should_get_edges_piped ... ignored
test tests::should_get_edges_with_no_high ... ignored
test tests::should_get_edges_with_no_low ... ignored
test tests::should_get_edges_with_no_time ... ignored
test tests::should_get_edges_with_no_type ... ignored
test tests::should_get_no_edges_for_an_invalid_range ... ignored
test tests::should_get_no_edges_for_reversed_time ... ignored
test tests::should_get_no_vertices_with_type_filter ... ignored
test tests::should_get_no_vertices_with_zero_limit ... ignored
test tests::should_get_range_vertices ... ignored
test tests::should_get_range_vertices_out_of_range ... ignored
test tests::should_get_single_vertex ... ignored
test tests::should_get_single_vertex_nonexisting ... ignored
test tests::should_get_vertices ... ignored
test tests::should_get_vertices_piped ... ignored
test tests::should_handle_edge_properties ... ignored
test tests::should_handle_vertex_properties ... ignored
test tests::should_index_existing_edge_property ... ignored
test tests::should_index_existing_vertex_property ... ignored
test tests::should_not_create_an_invalid_edge ... ignored
test tests::should_not_delete_an_invalid_edge ... ignored
test tests::should_not_delete_an_invalid_vertex ... ignored
test tests::should_not_delete_invalid_edge_properties ... ignored
test tests::should_not_delete_invalid_vertex_properties ... ignored
test tests::should_not_get_an_invalid_edge ... ignored
test tests::should_not_query_unindexed_edge_property ... ignored
test tests::should_not_query_unindexed_vertex_property ... ignored
test tests::should_not_set_invalid_edge_properties ... ignored
test tests::should_not_set_invalid_vertex_properties ... ignored
test tests::should_query_indexed_edge_property_empty ... ignored
test tests::should_query_indexed_vertex_property_empty ... ignored
test tests::should_sync ... ignored
test tests::should_update_indexed_edge_property ... ignored
test tests::should_update_indexed_vertex_property ... ignored

test result: ok. 0 passed; 0 failed; 54 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests (/Users/jasongoodwin/Development/src/indradb/target/release/deps/api-3b5f57734902791e)

running 6 tests
test bench_bulk_insert    ... bench: 111,641,500 ns/iter (+/- 19,591,737)
test bench_create_edge    ... bench:     142,721 ns/iter (+/- 49,218)
test bench_create_vertex  ... bench:     144,109 ns/iter (+/- 42,763)
test bench_get_edge_count ... bench:     142,385 ns/iter (+/- 43,270)
test bench_get_edges      ... bench:     297,362 ns/iter (+/- 1,180,450)
test bench_get_vertices   ... bench:     219,250 ns/iter (+/- 89,776)

test result: ok. 0 passed; 0 failed; 0 ignored; 6 measured; 0 filtered out; finished in 57.84s

@jasongoodwin
Copy link
Contributor Author

jasongoodwin commented Feb 13, 2022

The pr a bit. This is good to go IMO. I've tested this and I believe very strongly that this is the right thing to do for consumers of the api.
let me know if there is any objection.

An interesting quality in the performance is that there seem to be more consist response times (lower standard deviation).

@@ -44,6 +44,10 @@ fn map_conversion_result<T>(res: Result<T, crate::ConversionError>) -> Result<T,
res.map_err(|err| Status::invalid_argument(format!("{}", err)))
}

fn map_tokio_result<T>(res: Result<T, tokio::task::JoinError>) -> Result<T, Status> {
res.map_err(|err| Status::internal(format!("{}", err)))
}
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this is always called along with map_indradb_result? As a result, this could be simplified so that one function handles both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice I'll do that.

Copy link
Contributor Author

@jasongoodwin jasongoodwin Feb 14, 2022

Choose a reason for hiding this comment

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

K pushed a small refactor for that. I chose to keep two methods and just unwrap one into the other as the inner portion is used in send.

Copy link
Contributor Author

@jasongoodwin jasongoodwin Feb 14, 2022

Choose a reason for hiding this comment

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

87ab385 - lmk if that looks okay.

@ysimonson
Copy link
Member

Thanks for this fix!

@ysimonson ysimonson merged commit b845e15 into indradb:master Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants