yoshidan / google-cloud-rust

Google Cloud Client Libraries for Rust.
MIT License
251 stars 97 forks source link

spanner: slow initial session creation #323

Open danielnorberg opened 2 weeks ago

danielnorberg commented 2 weeks ago

Creation of google_cloud_spanner::client::Client can block for several seconds on the initial session pool population.

$ RUST_LOG=google_cloud_spanner=debug ...

2024-11-13T13:33:33.623060Z DEBUG google_cloud_spanner::session: spawn session creation request : session_count = 2
2024-11-13T13:33:36.207973Z DEBUG google_cloud_spanner::session: spawn session creation request : session_count = 2
2024-11-13T13:33:37.437913Z DEBUG google_cloud_spanner::session: spawn session creation request : session_count = 2
2024-11-13T13:33:39.892527Z DEBUG google_cloud_spanner::session: spawn session creation request : session_count = 2
2024-11-13T13:33:42.392172Z DEBUG google_cloud_spanner::session: initial session created count = 8

Would it make sense to defer the session pool initialization entirely to the "session creation task"?

yoshidan commented 2 weeks ago

I think the best approach to reduce initialization time would be to run the following in parallel, https://github.com/yoshidan/google-cloud-rust/blob/2f9219b17bbb9fb551ca160751c664bfba4604c5/spanner/src/session.rs#L238

danielnorberg commented 2 weeks ago

Sounds reasonable. Even individual session creation requests seem slow however. I wonder why that is. I will try to reproduce using one of the offical spanner clients.