Memoize env-keyed subprocess probes through one helper: composer, python and ruby each define the same env key and drifted on when an answer is kept
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Read crates/socket-patch-core/src/crawlers/composer_crawler.rs, python_crawler.rs, and ruby_crawler.rs, then inspect the shared process utilities in utils/process.rs. Compare the memoization rules and tests named in the issue, especially the environment-change keep rule. Done when the three crawlers use the shared helper and the listed tests, including a test for changed environments, pass; pull request #1895 is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[agent] Filed by the scheduled architecture audit (audit-core). Register: register.
Kind: refactor. Register ID: A32.
Problem
Three crawlers memoize a subprocess answer (composer config, the Python site query, gem env), keyed on the sorted process environment plus the cwd. The key function is byte-identical in all three:
let mut vars: Vec<_> = std::env::vars_os().collect();
vars.sort();
(vars, std::env::current_dir().ok())
- composer:
EnvKeyedMemo+env_key, composer_crawler.rs L477-L550.`` It is a single slot, and it keeps an answer only if the environment is unchanged after the subprocess returns. - python:
KeyedMemo<K, V>+site_query_key, python_crawler.rs L2765-L2817.```` It is a single slot and stores every answer (let value = run()?; *lock() = Some((key, value.clone()))). It has no env-unchanged check, so an answer computed while another thread changed the environment is filed under the old key. - ruby:
GemEnvMemo(aHashMapofOnceCells) +gem_env_key, ruby_crawler.rs L1012-L1023 and L1625-L1650.`````` It keeps every key it has ever seen, never evicts, single-flights per key, and has composer's env-unchanged check.
The drift (python's missing env-unchanged check) comes from reading the code; I did not execute it. It only matters when tests or the CLI change env concurrently.
Proposed change
- Add one
utils::process::EnvKeyedMemo<V>with anenv_key(). Use a single slot and composer's rule: keep an answer only when the env is unchanged after the run. - Composer and python use it directly.
- Ruby's async single-flight can wrap the same key type and keep-rule. Alternatively, ruby's map can become the single slot, since no caller needs more than one environment at a time.
- Delete the three key functions and the two memo structs.
Size
3 files plus utils/process.rs, about −60 lines.
Acceptance criteria
- Behavior is unchanged. Composer's
get_or_run_keyedtests, python's memo test (python_crawler.rs ~L8126) and ruby'smemoize_gem_env_homestests must stay green and move to the shared helper. - One test covers the keep rule: an answer computed while the env changed is not cached.
- Ngôn ngữ chính
- Rust
- Star
- 8
- Fork
- 2
- Merge trung bình
- 19 giờ 19 phút
- Pull request đã merge (30 ngày)
- 697
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 SocketDev/socket-patch
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
SocketDev/socket-patch#1860 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SocketDev/socket-patch#1838 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Share one scoped env-var test guard: EnvGuard is copy-pasted 11 times across core unit and integration testsCó thể đã có người làm @mikolalysenko đã nhận 1 ngày trước. Đang mởagent:claimed agent:triaged arch-audit priority:p3 refactor
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
SocketDev/socket-patch#1889 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
SocketDev/socket-patch#1887 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:needs-human agent:triaged arch-audit priority:p3 refactor
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
SocketDev/socket-patch#1881 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SocketDev/socket-patch
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
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 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
yunfie-twitter/Palleria#474 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
servo/rust-smallvec#827 ·
Maintainer thường phản hồi trong vòng 1 ngày