baseline: Decide which instruction implementations to inline into the dispatch loop
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
- 12/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp
- Lĩnh vực
- compilers, performance
Hướng nghiên cứu
The work is in the Baseline dispatch loops in baseline_execution.cpp and in intx's addmod(), sdivrem() and udivrem(). Start by building with GCC and Clang and checking the inlining decisions the issue describes. Done means a per-instruction inlining choice that is measured on random operands, at several code alignments, with branch-miss counters. This is a performance research task, not a first contribution.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Which instruction implementations are inlined into the Baseline dispatch loops (dispatch_cgoto, dispatch<false>, dispatch<true>) is left to the compilers' inlining heuristics. The same goes for which intx functions are inlined into those implementations. The heuristics weigh code size, not how hot or how expensive an instruction is, so unrelated size changes in evmone or intx move handlers in or out of the loops.
- GCC inlines into
baseline_execution.cppuntil the file has grown by--param inline-unit-growth(40%). It also lets a large function grow only bylarge-function-growth(100%). The dispatch loops sit at this limit:- SAR, LOG1–4, CALLDATACOPY, CODECOPY and EXTCODECOPY are left out.
- LOG0, MCOPY and RETURNDATACOPY move in and out with small changes in intx. For example, a smaller SLT in chfast/intx#453 pulls LOG0 in. The larger
exp()of chfast/intx#455 turns the EXP handler into a call and pulls LOG0 and MCOPY in.
- Clang decides per call site and keeps larger intx functions behind calls. The 256-bit results then take extra copies through memory, see ADDMOD below.
- Relayout: every such change also relayouts the loops, and the dispatch branch prediction depends on the layout. With GCC the chained-MUL benchmark runs in one of two states: 0.46M or 6.4M branch misses per 3 executions, with identical instructions and 1.5–2.4× the cycles.
Options
- Decide per instruction in evmone:
[[gnu::always_inline]],[[gnu::noinline]]or[[gnu::flatten]]on the implementations, possibly different for GCC and Clang. - Raise GCC's budget for
baseline_execution.cpponly:-
Use
--param=inline-unit-growth=100and--param=large-function-growth=200. -
In a prototype at x86-64-v3, this pins the current decisions and inlines the left-out handlers:
change SAR −2…−4% CODECOPY −3…−9% CALLDATACOPY −1…−5% RETURNDATACOPY −1…−4% evm-benchmarks ±2% snailtracer −3.8% .text+6.8 KB (v2), +8.7 KB (v3)
-
- Attributes in intx instead: they also affect intx's other users.
Items to check
Measure each item with per-instruction contracts on random (worst-case) operands, at 3 code alignments, and with branch-miss counters.
- ADDMOD with Clang.
-
What happens:
intx::addmod()(127 instructions) stays out of line. It copies the remainder out of the division result with a 32-byte load right afterudivrem()'s 8-byte stores. The load fails store forwarding, which costs about 11% of the cycles of an ADDMOD loop. The handler then copies the returned value again. -
[[clang::always_inline]]onintx::addmod()(x86-64-v3, 3 code alignments, ADDMOD contracts):modulus change 1–4 words −5…−8% BN254 −16…−18% GCC's code is identical.
-
The same with
[[gnu::always_inline]]: GCC gets slower. GCC already inlines the fast path ofaddmod()into the loop, and with the attribute the whole handler leaves the loop. BN254 +20%; chains of reduced ADDMODs +16% (v3) and +44% (v2). -
Side cost: with a zero modulus, the cheapest case, ADDMOD pays for the handler's frame: +24 cycles.
-
- SDIV/SMOD with Clang.
intx::sdivrem()stays out of line and returns its 64-byte result through memory. The copy of the result fails store forwarding.[[gnu::always_inline]]on it: Clang −10…−18%, GCC at x86-64-v3 up to +4.6% (its handlers then sit behind a call). - EXP with GCC: a call instead of inlined after chfast/intx#455.
- SAR, LOG1–4, CALLDATACOPY, CODECOPY, EXTCODECOPY with GCC: left out by the budget.
- Ngôn ngữ chính
- C++
- Star
- 979
- Fork
- 340
- Merge trung bình
- 12 giờ 16 phút
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
- Có Dockerfile hoặc 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 ipsilon/evmone
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ipsilon/evmone
Issue tương tự
-
Reference check: findingsĐang mởaudit-reference-check
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/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 76/100
schrodinger/pymol-open-source#532 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
xlnt-community/xlnt#174 ·
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
sleepyviper1213/redis#30 ·