inducer / inducer/arraycontext
Repeated freezes cause repeated computation
- Ngôn ngữ chính
- Python
- Star
- 9
- Fork
- 11
- Merge trung bình
- 17 giờ 12 phút
- Pull request đã merge (30 ngày)
- 2
Mô tả
(Maybe this is an `arraycontext` issue? Not sure.)
Suppose a moderately complex expression is built and evaluated. Then it is evaluated again. Repeated codegen (most likely cached, though see inducer/pytato#163) and repeated evaluation ensues. This isn't ideal. Possibly, a symbolic array, once evaluated, should hold on to its value, to avoid reevaluation. If we don't deal with this somehow, then pytato's arrays can't be meaningfully memoized (e.g. with `@memoize`/`@memoize_method` from pytools), as, sure, they memoize the expression, but the actual evaluation is done again and again.
A simple approach to this would be simply stuff the evaluated value into a hidden attribute (`_evaluated`?) on the expression nodes. I'm aware that this introduces mutation into otherwise immutable objects... but it's the cache-y kind of mutability, and it doesn't change the semantics of the object in the slightest. So I suspect it's OK.
Another possible concern is the lifetime of the evaluated value (i.e. it might outstay its welcome). I don't *think* that'll be a big concern because
- somebody held on to the symbolic value, demonstrating that there's at least potential interest in reevaluating.
- if it becomes an issue, we could make an interface to free the stored value, enabling the memory to be freed.
Generally, codegen should stop at already-evaluated notes (and treat them as `DataWrapper`s).
@MTCam is hitting this with cache retrievals upon freeze when exercising lazy evaluation for chemistry in https://github.com/illinois-ceesd/mirgecom.
cc @kaushikcfd
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách lần theo các điểm vào của việc đánh giá mảng ký hiệu và codegen được mô tả trong issue, sau đó tái hiện việc đánh giá lặp lại sau một freeze hoặc khi truy xuất từ cache. Kiểm tra cách các ghi chú đã được đánh giá được biểu diễn và codegen xử lý chúng như thế nào. Công việc được xem là hoàn tất khi việc đánh giá lặp lại tái sử dụng giá trị đã lưu mà không thay đổi ngữ nghĩa ký hiệu, đồng thời có cách phù hợp để giải phóng giá trị đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- backend
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100