workflowcheck OOM issues on large codebases
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- java
- Área
- performance, tooling
Línea de trabajo
Comienza con el punto de entrada findWorkflowClasses de workflowcheck y sigue la enumeración de ClassPath, el almacenamiento en caché de Loader.loadClass, findWorkflowImplInfo y processMethodValidity. Compara las sugerencias sobre scan-target/resolution-classpath y el filtrado de anotaciones, incluido el comportamiento propuesto de --scan-classpath. Se considera terminado cuando se reduzcan el escaneo eager y las clases retenidas para bases de código grandes sin perder las comprobaciones de workflow previstas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
workflowcheck scans the entirety of the runtimeClasspath and stores a cache of all visited classes in a hashmap. For large codebases, this is wasteful and can OOM CI jobs.
I suspect the current behavior was chosen because (1) it's simple, and (2) to potentially capture workflows that are brought in by dependencies. For the second point, it feels like the burden of determinism checks for workflows provided by a library should be on the library provider, rather than the consumer.
I suspect that suggestion 2 below may be the best fix and most-correct, but it might be behaviorally backwards-incompatible from what exists today
Current Behavior
temporal-workflowcheck uses a single classpath concept. When you call findWorkflowClasses(String... classPaths):
- ClassPath constructor enumerates every .class file across all JARs and directories (filtering only
java/,javax/,jdk/,com/sun/). For a larges app, this could be tens of thousands of classes. - The main loop calls
loader.loadClass()on every one of them, using ASM ClassReader to parse bytecode. Each class gets cached inLoader.classes(aHashMap<String, ClassInfo>). - For each class, it checks whether any public non-static non-abstract method is a workflow implementation (by walking the superclass/interface chain via
findWorkflowImplInfo). This triggers moreloadClasscalls. - For workflow methods found,
processMethodValiditytraces the call chain through dependencies to detect non-deterministic operations, triggering yet moreloadClasscalls.
The result for a project with a few workflow classes buried among ~20,000 dependency classes, the tool eagerly loads all 20,000 just to find those few classes. The Loader.classes cache retains every ClassInfo for the lifetime of the scan.
Suggestions
(1) Separate scan targets from resolution classpath
Add a new overload:
public List<ClassInfo> findWorkflowClasses(
String[] scanPaths, // enumerate classes from here
String[] resolutionPaths // available for call-chain resolution only
) throws IOException
ClassPath would enumerate class names only from scanPaths, but create a URLClassLoader covering both. The main loop iterates a fraction of the classes; Loader.loadClass() still works for call-chain tracing because the full classpath is on the classloader.
Instead of eagerly loading 20,000 classes in the discovery loop, only module classes are enumerated. Dependencies are loaded on-demand during processMethodValidity tracing, and only the onesactually in the call chain. The Loader.classes cache might end up with ~1k entries instead of ~20k.
We'd need to add a --scan-classpath <path> flag (repeatable). When present, the tool would only enumerate from those path(s). When absent, current behavior would be preserved (scan everything).
A much less durable alternative would be to support configurable classpath exclusions. While flexible, it'd put a toil-level burden on developers to whack-a-mole classpaths as a module's dependency graph changes.
(2) Lazy load with annotation filtering
Instead of loading every class through ASM's full ClassReader, do a two-pass approach:
- Pass 1: Quick scan of workflow-related annotations (
WorkflowInterface,WorkflowMethod, etc), which can be done by reading the class constant pools instead of the full class. Classes without these annotations (or that don't implement interfaces containing them) would be skipped entirely. - Pass 2: Full ASM analysis only on classes identified by pass 1.
- Lenguaje dominante
- Java
- Estrellas
- 433
- Forks
- 249
- Merge medio
- 6 d 5 h
- PR fusionados (30 d)
- 25
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 temporalio/sdk-java
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
temporalio/sdk-java#2676 · 8 comentarios · 2 reacciones ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
temporalio/sdk-java#1825 ·
-
test server
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
temporalio/sdk-java#3088 · 2 comentarios ·
-
temporalio/sdk-java#3059 · 1 asignado ·
-
enhancement
temporalio/sdk-java#3058 · 1 asignado ·
Todos los issues de temporalio/sdk-java
Issues similares
-
area-deployment area-integrations triage:bot-seen
Dificultad 2/5 Medio día Aptitud para principiantes 86/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/flink-agents#1156 ·
-
[source-shopify] FAILED bulk operation without partialDataUrl is silently treated as successful Abiertoarea/connectors autoteam community connectors/source/shopify needs-triage team/use type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100