Skip to content

Commit c5cf981

Browse files
authored
Merge pull request #1762 from prometheus/release-1.21
Merge release 1.21.1 to main.
2 parents e84c305 + 8a42da3 commit c5cf981

14 files changed

+49
-242
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Unreleased
22

3+
## 1.21.1 / 2025-03-04
4+
5+
* [BUGFIX] prometheus: Revert of `Inc`, `Add` and `Observe` cumulative metric CAS optimizations (#1661), causing regressions on low contention cases.
6+
* [BUGFIX] prometheus: Fix GOOS=ios build, broken due to process_collector_* wrong build tags.
7+
38
## 1.21.0 / 2025-02-17
49

510
:warning: This release contains potential breaking change if you upgrade `github.com/prometheus/common` to 0.62+ together with client_golang. :warning:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.21.0
1+
1.21.1

prometheus/atomic_update.go

Lines changed: 0 additions & 50 deletions
This file was deleted.

prometheus/atomic_update_test.go

Lines changed: 0 additions & 167 deletions
This file was deleted.

prometheus/counter.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ func (c *counter) Add(v float64) {
134134
return
135135
}
136136

137-
atomicUpdateFloat(&c.valBits, func(oldVal float64) float64 {
138-
return oldVal + v
139-
})
137+
for {
138+
oldBits := atomic.LoadUint64(&c.valBits)
139+
newBits := math.Float64bits(math.Float64frombits(oldBits) + v)
140+
if atomic.CompareAndSwapUint64(&c.valBits, oldBits, newBits) {
141+
return
142+
}
143+
}
140144
}
141145

142146
func (c *counter) AddWithExemplar(v float64, e Labels) {

prometheus/gauge.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,13 @@ func (g *gauge) Dec() {
120120
}
121121

122122
func (g *gauge) Add(val float64) {
123-
atomicUpdateFloat(&g.valBits, func(oldVal float64) float64 {
124-
return oldVal + val
125-
})
123+
for {
124+
oldBits := atomic.LoadUint64(&g.valBits)
125+
newBits := math.Float64bits(math.Float64frombits(oldBits) + val)
126+
if atomic.CompareAndSwapUint64(&g.valBits, oldBits, newBits) {
127+
return
128+
}
129+
}
126130
}
127131

128132
func (g *gauge) Sub(val float64) {

prometheus/histogram.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,9 +1647,13 @@ func waitForCooldown(count uint64, counts *histogramCounts) {
16471647
// atomicAddFloat adds the provided float atomically to another float
16481648
// represented by the bit pattern the bits pointer is pointing to.
16491649
func atomicAddFloat(bits *uint64, v float64) {
1650-
atomicUpdateFloat(bits, func(oldVal float64) float64 {
1651-
return oldVal + v
1652-
})
1650+
for {
1651+
loadedBits := atomic.LoadUint64(bits)
1652+
newBits := math.Float64bits(math.Float64frombits(loadedBits) + v)
1653+
if atomic.CompareAndSwapUint64(bits, loadedBits, newBits) {
1654+
break
1655+
}
1656+
}
16531657
}
16541658

16551659
// atomicDecUint32 atomically decrements the uint32 p points to. See

prometheus/process_collector_darwin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14+
//go:build darwin && !ios
15+
1416
package prometheus
1517

1618
import (

prometheus/process_collector_cgo_darwin.c renamed to prometheus/process_collector_mem_cgo_darwin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build darwin && cgo
14+
//go:build darwin && !ios && cgo
1515

1616
#include <mach/mach_init.h>
1717
#include <mach/task.h>

prometheus/process_collector_cgo_darwin.go renamed to prometheus/process_collector_mem_cgo_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
//go:build darwin && cgo
14+
//go:build darwin && !ios && cgo
1515

1616
package prometheus
1717

0 commit comments

Comments
 (0)