GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Avoid using `pb` internals for datastore on App Engine · Issue #298 · googleapis/google-cloud-python

Avoid using pb internals for datastore on App Engine #298

New issue
Copy link
New issue
Copy link
Closed
Closed
Avoid using pb internals for datastore on App Engine#298
Copy link
Assignees
tseaver
Labels
🚨This issue needs some love.api: datastoreIssues related to the Datastore API.triage meI really want to be triaged.

Description

@dhermes
dhermes
opened on Oct 27, 2014
Issue body actions

See #282 for context.

From @pcostell:

Just a random note about proto usage:
If you plan to let users run gcloud-python in the App Engine python runtime, proto access is
really slow (I believe because of the sandbox). I would limit proto access to serialization
and deserialization only.

and

Not 100% sure, but I think it uses a C proto library so it goes outside the process boundary.

Activity

Next
  1. dhermes
    added
    api: datastoreIssues related to the Datastore API.
    on Oct 27, 2014
  2. dhermes commented on Dec 30, 2014

    @dhermes
    dhermes
    on Dec 30, 2014
    ContributorAuthor
    More actions

    Currently digging into https://www.simonmweber.com/2013/06/18/python-protobuf-on-app-engine.html to see what I can find out.

  3. dhermes commented on Dec 30, 2014

    @dhermes
    dhermes
    on Dec 30, 2014
    ContributorAuthor
    More actions

    @pcostell I'm not sure your previous comments are relevant to gcloud. I just created a test application and the proto used is via the external protobuf library, not the proto libraries provided in App Engine.

    I added a debug print to check Entity.save() times in a single request and got:

    • 0.197650 seconds
    • 0.113310 seconds
    • 0.169830 seconds

    I was worried this was slow so did the same locally with the version on PyPI (0.3.0) and got similar times:

    • 1.152835 seconds (app was cold)
    • 0.233535 seconds
    • 0.359164 seconds
    • 0.217317 seconds

    ISTM the App Engine speed-up is due to the fast-path between the App Engine app and the Cloud Datastore machines.

    UPDATE: I'm fairly certain Patrick was referring to google.net.proto and google.net.proto2 as the libraries to avoid using. I checked to make sure we don't ever import from proto libraries included in GAE.

    SECOND UPDATE: I broke down Entity.save() into lower and lower level component pieces until the network was the only thing left. The times of each show that the impact of using the protobuf library is negligible.

  4. dhermes commented on Dec 30, 2014

    @dhermes
    dhermes
    on Dec 30, 2014
    ContributorAuthor
    More actions

    @silvolu @tseaver FYI gcloud works just fine deployed in App Engine.

  5. tseaver commented on Dec 31, 2014

    @tseaver
    tseaver
    on Dec 31, 2014
    Contributor
    More actions

    Great analysis!

  6. tseaver
    closed this as completedon Dec 31, 2014
  7. pcostell commented on Jan 4, 2015

    @pcostell
    pcostell
    on Jan 4, 2015
    Contributor
    More actions

    Awesome, good to know. Something that may be important: The reason GAE protos have slow access is that they use the C++ library, which requires a process boundary cross. This is used instead of a pure python library because serialization and deserialization is much faster in C++ than in python. In may be worthwhile to still minimize proto access in order to minimize SWIG-code entry points when users do have the C++ libraries (running on VMs or if GAE adds google.protobuf to the runtime).

  8. dhermes commented on Jan 5, 2015

    @dhermes
    dhermes
    on Jan 5, 2015
    ContributorAuthor
    More actions

    Luckily the protobuf library only uses C-code from the standard library. As @tseaver pointed out earlier today, struct is plenty fast.

    I analyzed the imports, and the only imports from outside the library are:

    StringIO.StringIO
    cStringIO
    cStringIO.StringIO
    copy_reg
    copyreg  # Py3, comment added by dhermes
    io.BytesIO  # Py3, comment added by dhermes
    operator
    os
    re
    struct
    sys
    uuid
    weakref
    
  9. pcostell commented on Jan 12, 2015

    @pcostell
    pcostell
    on Jan 12, 2015
    Contributor
    More actions

    Currently, when using the externally available protobuf library on App Engine, it is using the python-only version of the protobuf library (it's impossible to upload a C library to the python runtime). However, once we are able to get the external C library into the App Engine runtime it will start using the C version instead of the python version. The C version has faster encode/decode times however you do pay a penalty when accessing protocol buffer fields because it has to cross a process boundary. We saw this in NDB's Key implementation which tried to store everything internally in protobuf rather than storing the fields as native python types.

    I went through and it looks like you only access the protobuf on serialization and deserialization, which is perfect, so I'm leaving this as closed.

  10. tseaver commented on Jan 12, 2015

    @tseaver
    tseaver
    on Jan 12, 2015
    Contributor
    More actions

    @pcostell we just recently dropped the "long-lived protobuf" inside Query: glad that helps.

  11. jgeewax
    modified the milestone: This milestone has been deleted on Jan 30, 2015
  12. yoshi-automation
    added
    triage meI really want to be triaged.
    🚨This issue needs some love.
    on Apr 7, 2020
  13. JustinBeckwith
    assigned
    tseaver
    on Feb 1, 2021
  14. 32 remaining items

  15. parthea
    added a commit that references this issue on Jan 10, 2025

    chore: update templated files (#298)

    3d27991
  16. parthea
    added a commit that references this issue on Aug 21, 2025

    chore(deps): update all dependencies (#298)

    7773a37
  17. parthea
    added 2 commits that reference this issue on Sep 16, 2025

    chore(deps): update all dependencies (#298)

    c77a8f9

    FIX: update minimum google-cloud-bigquery version to 1.11.1 (#298)

    0b31615
  18. parthea
    added 7 commits that reference this issue on Nov 24, 2025

    chore: allow release-please to make releases (#298)

    746719e

    fix: handle bare 'grpc.Call' in 'from_grpc_error' (#298)

    f34aaa4

    fix: the unnest function lost needed type information (#298)

    1ce9fdd

    chore: release 1.2.0 (#338)

    6b6b753

    chore(python): update unittest workflow template (#298)

    8ae2414

    Update README.rst for Python 3.7 (#298)

    d48ffa2

    Enable static type checking with pytype (#298)

    f9737c7
  19. parthea
    added a commit that references this issue on Mar 2, 2026

    samples: use flaky in tests (#298)

    82d0624
  20. parthea
    added 3 commits that reference this issue on Mar 9, 2026

    chore(deps): update dependency importlib-metadata to v5.2.0 (#298)

    69c7074

    fix: preserve metadata value (#298)

    e878a6f

    chore: loosen opentelemetry dependencies (#298)

    ace0a3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

🚨This issue needs some love.api: datastoreIssues related to the Datastore API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.