You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 7, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on May 7, 2026. It is now read-only.
I believe there is a change of API or a performance issue when using batches with 2.1.0.
Environment details
OS type and version: Windows 10
Python version: 3.8.7
pip version: 20.3.3
google-cloud-datastore version: 2.1.0
google-api-core version: 1.24.1
Steps to reproduce
Use DatastoreClient::put_multi with 500 entities inside a batch
Code example
withclient.batch():
client.put_multi(chunk)
Performance
When using 1.15.0, my code can handle 9 batches of 500 entities in about 1-2 seconds while 2.1.0 takes literal minutes.
Disclaimer: I use the datastore emulator
Thanks @BinarSkugga . I know we overhauled, rather substantially, the transport layer in the v1 -> v2. It would be very helpful to understand if you are seeing a slowdown on a live endpoint.
I use those batches in parrallel using Python's ThreadPoolExecutor from the concurrent package.
Deleting entities seems also slightly slower but its negligible compared to writes and reads.
Might be worth to note that I had to remove the 'indices' key in my Entity object as the emulator doesn't seem to understand it. It tries to parse it as a column and fails because it contains a set().
I have received another customer report. While not quite the difference stated here, 2-3x slower is about what the other instance was observing. It would be good to benchmark a few operations and see if there are any obvious gains that could be made.
I've been attempting to recreate this, but so far am seeing more or less similar outcomes for batch operations between versions 2.1.0 and 1.15.3.
Querying may very well be slower, however.
First test run:
$ python datastore-test.py
[python-datastore@1.15.3] finished creation loop in 5.0 ms
[python-datastore@1.15.3] finished batch write in 1926.0 ms
[python-datastore@1.15.3] finished batch get in 391.0 ms
[python-datastore@1.15.3] finished batch update in 1706.0 ms
[python-datastore@1.15.3] finished batch query in 2216.0 ms
> loaded 3500 objects
Switch to version 2.1.0 and run again:
python datastore-test.py
[python-datastore@2.1.0] finished creation loop in 4.0 ms
[python-datastore@2.1.0] finished batch write in 2109.0 ms
[python-datastore@2.1.0] finished batch get in 588.0 ms
[python-datastore@2.1.0] finished batch update in 1701.0 ms
[python-datastore@2.1.0] finished batch query in 3702.0 ms
> loaded 4000 objects
Activity
[-]Batches in 2.10 are significantly slower[/-][+]Batches in >2.0.0 are significantly slower[/+][-]Batches in >2.0.0 are significantly slower[/-][+]Batches in >=2.0.0 are significantly slower[/+]crwilcox commentedon Jan 11, 2021
Are you seeing this in both emulator and live endpoints?
BinarSkugga commentedon Jan 12, 2021
I haven't tested on a live endpoint. I'm in vacation for the week, I'll definitely test this when I come back.
crwilcox commentedon Jan 15, 2021
Thanks @BinarSkugga . I know we overhauled, rather substantially, the transport layer in the v1 -> v2. It would be very helpful to understand if you are seeing a slowdown on a live endpoint.
BinarSkugga commentedon Jan 18, 2021
BinarSkugga commentedon Jan 18, 2021
Additional potentially impactful information:
BinarSkugga commentedon Jan 19, 2021
I may have talked to fast. It also happens on live endpoints.
Logs from 1.15.x:
Logs from 2.1.x:
Here's the code that handles this:
The concurrent service simply submit a new task per batch in the thread pool.
BinarSkugga commentedon Jan 25, 2021
Any insight on this ?
crwilcox commentedon Mar 22, 2021
I have received another customer report. While not quite the difference stated here, 2-3x slower is about what the other instance was observing. It would be good to benchmark a few operations and see if there are any obvious gains that could be made.
Reference PR from PubSub that was able to get back some time: googleapis/python-pubsub@c29d7f8
craiglabenz commentedon Mar 23, 2021
I've been attempting to recreate this, but so far am seeing more or less similar outcomes for batch operations between versions
2.1.0and1.15.3.Querying may very well be slower, however.
First test run:
Switch to version
2.1.0and run again:I will continue to investigate, but for now, here's the testing script I'm using.
fix: optimized protobuf access for performance (#155)