Repository navigation
Conversation
petermm
left a comment
There was a problem hiding this comment.
AMP review:
PR Review: exact-equality fast path
Commit reviewed: f424c95a97c5a0a74615af4907753141006e93d4
Verdict: Approve — no actionable correctness or regression findings.
Findings
No findings.
The fast path preserves exact-equality semantics:
- Bit-identical terms were already treated as equal by the first branch of
term_compare. - Distinct immediate terms are canonical and therefore cannot be exactly equal.
- Lists, boxed values, and mixed representations still fall back to
term_compare(..., TermCompareExact, ...). - Comparisons that may allocate still retain the existing
TermCompareMemoryAllocFailhandling in all three opcode implementations. OP_SELECT_VALcontinues decoding every value/label pair after finding a match, so the instruction pointer remains positioned correctly before the jump.
Oracle independently reviewed the commit's term-tag invariants, structural-comparison fallback, and OOM paths and likewise reported no actionable regressions or test gaps.
Suggested diffs
None. No small fix or follow-up suggestion is warranted by the reviewed code.
Verification
git diff HEAD^..HEAD --check— passed.cmake --build build --target AtomVM -j2— passed with only the pre-existing duplicate-library linker warning../build/tests/test-erlang— passed (exit status 0)../build/tests/test-term— passed (exit status 0; this is a stale local artifact and is not part of the current CMake target set, so it is supplementary only).
The claimed performance improvement was not independently benchmarked as part of this correctness review.
|
we want this based on release-0.7 right? |
|
Sounds good let me do that! |
f424c95 to
578b066
Compare
bettio
left a comment
There was a problem hiding this comment.
Just an important thing here and it can be merged: git commit --amend --signoff so it can pass DCO CI check.
Also there is a non-blocking issue: CHANGELOG entry might be improved in terms of clarity and order.
| term, so it could be used to read port information; there is no `erlang:port_info/2` | ||
| in AtomVM yet to migrate such code to) | ||
| - Exact-equality opcodes (`is_eq_exact`, `is_not_eq_exact`, `select_val`) decide two immediates | ||
| without `term_compare`; atom `case` clauses no longer compare atom names through the atom table |
There was a problem hiding this comment.
Let's reframe this as an optimization, so it is clearer to the end user. Something like: "Optimize atom comparison in ...". Let's also append this at the end of 0.7.0-beta.0 ### Changed section, so we keep this change in chronological order.
| calling it with a port now raises `badarg` (previous versions accepted any id-carrying | ||
| term, so it could be used to read port information; there is no `erlang:port_info/2` | ||
| in AtomVM yet to migrate such code to) | ||
| - Exact-equality opcodes (`is_eq_exact`, `is_not_eq_exact`, `select_val`) decide two immediates |
There was a problem hiding this comment.
This change is invisible to users and doesn't need to be mentioned here (except as faster comparison maybe).
| *equal = false; | ||
| return true; | ||
| } | ||
| return false; |
There was a problem hiding this comment.
Boxed vs immediate is also fast to compare.
I went through something similar here:
This is one third of #2388
is_eq_exact,is_not_eq_exactandselect_valwould always call term_compare, which for two atoms looks up both names in the atom table and memcmps them.Two immediates with the same bits are always equal and two immediates with different bits are never equal. We can decide inline and only fall back to term_compare when a side is boxed or a list.
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later