workflowcheck OOM issues on large codebases
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- java
- Lĩnh vực
- performance, tooling
Hướng nghiên cứu
Bắt đầu với điểm vào findWorkflowClasses của workflowcheck và theo dõi việc liệt kê ClassPath, cơ chế lưu vào bộ nhớ đệm của Loader.loadClass, findWorkflowImplInfo và processMethodValidity. So sánh các đề xuất về scan-target/resolution-classpath và lọc annotation, bao gồm cả hành vi --scan-classpath được đề xuất. Được xem là hoàn tất khi giảm việc quét eager và số lớp được giữ lại đối với các codebase lớn mà không làm mất các kiểm tra workflow dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 434
- Fork
- 252
- Merge trung bình
- 2 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 14
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của temporalio/sdk-java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
temporalio/sdk-java#2676 · 8 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
temporalio/sdk-java#1825 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
test server
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
temporalio/sdk-java#3088 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Warn if the SDK tried to send a payload above a specific size - JavaCó thể đã có người làm @jmaeagle99 đã nhận 20 ngày trước. Đang mở
temporalio/sdk-java#3059 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Allow configurable prefix for MDC keysCó thể đã có người làm @maciejdudko đã nhận 21 ngày trước. Đang mởenhancement
temporalio/sdk-java#3058 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của temporalio/sdk-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
redhat-developer/intellij-quarkus#1626 ·
-
Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
wso2/product-integrator-mi#5061 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
quarkiverse/quarkus-roq#1277 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Typos in page footerĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
apache/logging-site#48 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/maven-surefire#3496 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày