Collection#select/#reject copy every component and rebuild its merged data before filtering
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- ruby
- Lĩnh vực
- performance
Hướng nghiên cứu
Read lib/compliance_engine/collection.rb, then follow Component#initialize_copy, #element, Data#mapping?, and Data#check_mapping to understand copy isolation and cache rebuilding. Implement equivalent select/reject behavior that duplicates only matching components without changing cache semantics. Use the issue’s 259-file, 2,308-check, and 59-profile dataset to measure heap, RSS, and mapping time; done means the results are correct, isolated, and no longer rebuild discarded components.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Collection#select and #reject (lib/compliance_engine/collection.rb) dup the whole collection and then filter it:
result = dup
result.collection = result.to_h.select(&block)
Collection#initialize_copy dups every component, and Component#initialize_copy clears each copy's @fragments/@element caches. The filter block then runs against those fresh copies, so any accessor it calls (for example check.controls or check.ces in Data#mapping?) rebuilds element. element does Marshal.load(Marshal.dump(fragment)) for every fragment before merging.
Data#check_mapping calls checks.select once per profile or CE. With P profiles/CEs and C checks, that is P × C component copies and P × C element rebuilds, and each rebuild Marshal-copies every fragment. Most of those copies belong to checks the filter then throws away.
#150 removed the deep copy of fragments in Component#initialize_copy. That cost is gone, but this per-select rebuild remains.
Suggested approach: run the block against self's components, whose caches are already warm, and dup only the components that match:
def select(&block)
return to_enum(:select) unless block_given?
result = dup_without_components # or equivalent
result.collection = to_h.select(&block).transform_values(&:dup)
result
end
(and likewise for reject). Care is needed to keep the copy isolation that initialize_copy guarantees: the returned components must still be independent copies, and the caches on self must reflect the same facts, enforcement tolerance and environment data the copies will use.
It would be worth measuring this the same way as #150 (the 259-file / 2,308-check / 59-profile data set: heap, RSS and time for mapping every profile with facts set).
- Ngôn ngữ chính
- Ruby
- Star
- 2
- Fork
- 1
- Merge trung bình
- 3 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Không 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 simp/rubygem-simp-compliance_engine
-
sce-schema.json: missing properties that live SCE data uses (id, benchmark_version, notes, oval-ids)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 62/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
simp/rubygem-simp-compliance_engine#138 · 1 bình luận ·
-
Malformed check data raises NoMethodError out of mapping?/hiera/fragments instead of being handledĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
simp/rubygem-simp-compliance_engine#137 · 2 bình luận ·
Tất cả issue của simp/rubygem-simp-compliance_engine
Issue tương tự
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
KevinSaison/fuchikoma#14 ·
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
blast/small refactor risk/medium spend-dem
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
chriskelly/MusicWall#84 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug interest-dpsg
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
hitobito/hitobito_dpsg#46 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
riscv/riscv-unified-db#2915 ·
Maintainer thường phản hồi trong vòng 2 ngày