Skip to content

cleanup: Use Go 1.19 atomic types#5792

Merged
algorandskiy merged 4 commits intoalgorand:masterfrom
ohill:use-atomic-types
Oct 23, 2023
Merged

cleanup: Use Go 1.19 atomic types#5792
algorandskiy merged 4 commits intoalgorand:masterfrom
ohill:use-atomic-types

Conversation

@ohill
Copy link
Copy Markdown
Contributor

@ohill ohill commented Oct 20, 2023

Summary

Go 1.19 introduced types like atomic.Uint64, atomic.Int32, atomic.Bool, that provide automatic alignment for 32-bit platforms, plus extra safety to ensure access to the underlying value only uses atomic methods. This converts nearly all the calls to atomic to use these types. It also catches a few places where non-atomic and atomic access were mixed together.

Test Plan

Removed TestAtomicVariablesAlignment

ohill added 2 commits October 20, 2023 12:54
    sed -E -i -e 's/atomic.Load(Int32|Uint64|Uint32|Int64)\(&([^\)]+)\)/\2.Load()/g' \
          -e 's/atomic.Store(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+)\)/\2.Store(\3)/g' \
          -e 's/atomic.CompareAndSwap(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+), ([^,]+)\)/\2.CompareAndSwap(\3, \4)/g' \
          -e 's/atomic.Add(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+)\)/\2.Add(\3)/g' *.go
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 20, 2023

Codecov Report

Merging #5792 (d0f706d) into master (6c482ab) will decrease coverage by 0.01%.
Report is 4 commits behind head on master.
The diff coverage is 73.82%.

@@            Coverage Diff             @@
##           master    #5792      +/-   ##
==========================================
- Coverage   55.55%   55.54%   -0.01%     
==========================================
  Files         474      474              
  Lines       66850    66848       -2     
==========================================
- Hits        37138    37133       -5     
- Misses      27188    27190       +2     
- Partials     2524     2525       +1     
Files Coverage Δ
cmd/tealdbg/cdtSession.go 66.29% <100.00%> (ø)
crypto/merklearray/worker.go 100.00% <100.00%> (ø)
data/pools/transactionPool.go 51.45% <100.00%> (ø)
ledger/bulletin.go 92.30% <100.00%> (-1.93%) ⬇️
network/netidentity.go 100.00% <100.00%> (ø)
network/netprio.go 72.00% <100.00%> (ø)
network/p2pNetwork.go 65.43% <100.00%> (ø)
rpcs/blockService.go 74.33% <100.00%> (ø)
rpcs/ledgerService.go 53.12% <100.00%> (ø)
util/condvar/timedwait.go 100.00% <100.00%> (ø)
... and 10 more

... and 13 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment thread .golangci.yml
Comment thread data/pools/transactionPool.go
Comment thread ledger/bulletin.go
Comment thread rpcs/blockService.go Outdated
Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically the same questions as Jason had

Copy link
Copy Markdown
Contributor

@cce cce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to have possibly fixed some bugs with handling of atomics

Comment thread ledger/eval/prefetcher/prefetcher.go
Comment thread network/p2pNetwork.go
Comment thread network/wsNetwork.go
Comment thread shared/pingpong/pingpong.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants