Option to skip per-method docstring generation in build() (memory / high-concurrency)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
Línea de trabajo
Comienza en build() y sigue discovery.createMethod, schema.Schemas.prettyPrintSchema y prettyPrintByName para ver dónde se generan los docstrings de response-schema durante la construcción de servicios y subrecursos perezosos. Reproduce el perfil de memoria de Sheets v4 descrito en el issue; el trabajo estará terminado cuando una opción de tiempo de compilación compatible omita esa generación sin afectar a la construcción normal cuando esté habilitada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Feature request: an option to skip per-method docstring generation in build()
Problem
build() (and lazy sub-resource construction) generates a fully-expanded, recursively
pretty-printed prototype of each method's response schema and attaches it as
method.__doc__ (discovery.createMethod → schema.Schemas.prettyPrintSchema /
prettyPrintByName). For APIs with large, deeply-nested schemas this is very expensive, and it
is paid every time a service/resource is constructed.
Concrete numbers from profiling Sheets v4 (google-api-python-client==2.198.0, Python 3.13),
measured with RSS (no tracemalloc, to avoid its overhead):
- Building the service, then touching one sub-resource (
service.spreadsheets(), no API
call): ~66 MB. - Of that, ~99.9% is the docstring schema expansion — no-oping
prettyPrintSchema/
prettyPrintByNamedrops it to ~1 MB. The.spreadsheets()methods themselves are ~24 KB. - The docstrings are only useful for interactive
help(); in a server they are never read.
Impact
In a concurrent server (a fresh service built per request, common with per-user credentials),
these allocations are not shared across in-flight requests. 8 concurrent Sheets requests
each build ~66 MB of docstrings simultaneously ≈ 530 MB peak, which OOM-kills a
memory-limited container. This is the concurrent-peak sibling of the long-standing
reference-cycle memory issue in #535 (whose recommended fix — build/reuse a single service — is
not always feasible when credentials differ per request).
Request
A supported way to skip docstring generation at build time, e.g.:
build("sheets", "v4", credentials=creds, generate_docstrings=False)
# or a module/env toggle
Today the only options are to monkeypatch Schemas.prettyPrintSchema/prettyPrintByName
(fragile across versions) or fork. A first-class flag would let memory-constrained / high-
concurrency deployments opt out of documentation strings they never use.
Environment
google-api-python-client==2.198.0, Python 3.13- Reproly: build any large-schema API (Sheets v4), touch a sub-resource, measure RSS; repeat
concurrently to see the multiplier.
Related: #535 (memory from repeated build() / reference cycles).
- Lenguaje dominante
- Python
- Estrellas
- 8.9k
- Forks
- 2.6k
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 16
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de googleapis/google-api-python-client
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
googleapis/google-api-python-client#2788 ·
Los mantenedores suelen responder en 1 día
-
test: connection leak test test_discovery_http_is_closed is shadowed and syntactically invalidAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
googleapis/google-api-python-client#2757 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
googleapis/google-api-python-client#2755 ·
Los mantenedores suelen responder en 1 día
-
forms for APAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
googleapis/google-api-python-client#2830 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
googleapis/google-api-python-client#2825 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de googleapis/google-api-python-client
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 91/100
TencentCloud/Octop#1577 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
PedestrianDynamics/pyFDS-Evac#552 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
resend/resend-skills#144 ·
Los mantenedores suelen responder en 1 día
-
update UV in dockerfileAbiertogood first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100