You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: Use of local_data().len()
Fix: Replace with num_elems_local()
Reason: They return the same value, but local_data (sometimes) grabs a lock that might not be released as quickly as expected (e.g., during loop initialization the lock is kept for the lifetime of the loop, not just the lifetime of the initialization).
While developing a benchmark using a LocalLockArray, the "issue" version was used in a loop init that also included an array put (e.g., for i in 0...array.local_data().len() {array.put(i, ...)}). Switching the loop init to 0...array.num_elems_local() fixed the problem. The issue only comes up for LocalLockArray, but the change is valid on all array types.
Can we make a clippy check (or similar) for this?
The text was updated successfully, but these errors were encountered:
Issue: Use of local_data().len()
Fix: Replace with num_elems_local()
Reason: They return the same value, but local_data (sometimes) grabs a lock that might not be released as quickly as expected (e.g., during loop initialization the lock is kept for the lifetime of the loop, not just the lifetime of the initialization).
While developing a benchmark using a LocalLockArray, the "issue" version was used in a loop init that also included an array put (e.g.,
for i in 0...array.local_data().len() {array.put(i, ...)}
). Switching the loop init to0...array.num_elems_local()
fixed the problem. The issue only comes up for LocalLockArray, but the change is valid on all array types.Can we make a clippy check (or similar) for this?
The text was updated successfully, but these errors were encountered: