3

Based on the documentation for Objectify and Google Cloud Datastore, I would expect the queries and the batch loads in the following code to execute in parallel:

List<Iterable<Key<MyType>>> results = new ArrayList<>();
for (...) {
  results.add(ofy().load()
      .type(MyType.class)
      .filter(...)
      .keys()
      .iterable());
}
...
Iterable<MyType> keys = ...;
Collection<MyType> c = ofy().load().keys(keys).values();

But the trace makes it look like each query and each entity load executes in sequence:

Trace

What gives?

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
Bob Lee
  • 1,962
  • 1
  • 12
  • 9

1 Answers1

2

It looks like this only happens when doing a cached get from Memcache. With similar code I see the expected async behavior for datastore_v3.Get/Put/Delete:

datastore_v3.Get datastore_v3.Put datastore_v3.Delete

It seems the reason for this is that Objectify doesn't use AsyncMemcacheService. Indeed, there is an open issue for this on the project page, and this can also be confirmed by checking out the source and doing a grep -r AsyncMemcacheService.

Regarding the serial datastore_v3.RunQuery calls, calls to ofy().load().type(...).filter(...).iterable() are 'asynchronous' in that they return immediately, however the actual Datastore queries themselves get executed serially as the App Engine Datastore API doesn't expose an explicitly async API for queries.

Adam
  • 5,697
  • 1
  • 20
  • 52