perf: zero allocations per Present and frame round trip (wlturbo v0.6.2) (#1)
- commit
- 35f7ff11b7082303674524f72794ec262fd91209
- author
- bnema · · 2026-10-01 20:26 UTC
- committer
- GitHub · · 2026-10-01 20:26 UTC
- parent
- f2db2fe
- signature
- GPG Unverified
B5690EEEBB952194The key is unknown
5 files · +13 -16
M alloc_test.go +4 -7
| @@ -137,11 +137,8 @@ func TestAllocPresent(t *testing.T) { | |||
| 137 | 137 | t.Logf("allocs per Present (requests only): %v", allocs) | |
| 138 | 138 | require.Zero(t, allocs) | |
| 139 | 139 | ||
| 140 | - | // The complete cycle adds the frame callback. wlturbo registers each | |
| 141 | - | // server-created wl_callback with two sync.Map stores (Context.proxies and | |
| 142 | - | // Display.objects) and a sync.Map store always allocates a node, so two | |
| 143 | - | // allocations per frame are inherent to the transport (wlturbo is out of | |
| 144 | - | // scope for this change). They are pinned so a regression above that shows. | |
| 140 | + | // The complete cycle adds the frame callback, registered under a recycled | |
| 141 | + | // ID in wlturbo's object tables. | |
| 145 | 142 | s.UseWireRequests() | |
| 146 | 143 | h := &countingHandler{} | |
| 147 | 144 | cycle := func() { | |
| @@ -158,8 +155,8 @@ func TestAllocPresent(t *testing.T) { | |||
| 158 | 155 | cycle() | |
| 159 | 156 | } | |
| 160 | 157 | full := testing.AllocsPerRun(100, cycle) | |
| 161 | - | t.Logf("allocs per Present+frame round trip: %v (wlturbo callback registration)", full) | |
| 162 | - | require.LessOrEqual(t, full, 2.0) | |
| 158 | + | t.Logf("allocs per Present+frame round trip: %v", full) | |
| 159 | + | require.Zero(t, full) | |
| 163 | 160 | require.Positive(t, h.frames) | |
| 164 | 161 | require.Zero(t, h.errs) | |
| 165 | 162 | } | |
| @@ -137,11 +137,8 @@ func TestAllocPresent(t *testing.T) { | |||||
| 137 | t.Logf("allocs per Present (requests only): %v", allocs) | 137 | t.Logf("allocs per Present (requests only): %v", allocs) | ||
| 138 | require.Zero(t, allocs) | 138 | require.Zero(t, allocs) | ||
| 139 | 139 | ||||
| 140 | - | // The complete cycle adds the frame callback. wlturbo registers each | 140 | + | // The complete cycle adds the frame callback, registered under a recycled |
| 141 | - | // server-created wl_callback with two sync.Map stores (Context.proxies and | 141 | + | // ID in wlturbo's object tables. |
| 142 | - | // Display.objects) and a sync.Map store always allocates a node, so two | |||
| 143 | - | // allocations per frame are inherent to the transport (wlturbo is out of | |||
| 144 | - | // scope for this change). They are pinned so a regression above that shows. | |||
| 145 | s.UseWireRequests() | 142 | s.UseWireRequests() | ||
| 146 | h := &countingHandler{} | 143 | h := &countingHandler{} | ||
| 147 | cycle := func() { | 144 | cycle := func() { | ||
| @@ -158,8 +155,8 @@ func TestAllocPresent(t *testing.T) { | |||||
| 158 | cycle() | 155 | cycle() | ||
| 159 | } | 156 | } | ||
| 160 | full := testing.AllocsPerRun(100, cycle) | 157 | full := testing.AllocsPerRun(100, cycle) | ||
| 161 | - | t.Logf("allocs per Present+frame round trip: %v (wlturbo callback registration)", full) | 158 | + | t.Logf("allocs per Present+frame round trip: %v", full) |
| 162 | - | require.LessOrEqual(t, full, 2.0) | 159 | + | require.Zero(t, full) |
| 163 | require.Positive(t, h.frames) | 160 | require.Positive(t, h.frames) | ||
| 164 | require.Zero(t, h.errs) | 161 | require.Zero(t, h.errs) | ||
| 165 | } | 162 | } | ||
M examples/go.mod +2 -2
| @@ -4,7 +4,7 @@ go 1.27 | |||
| 4 | 4 | ||
| 5 | 5 | require ( | |
| 6 | 6 | github.com/bnema/neferclient v0.1.0 | |
| 7 | - | github.com/bnema/nefergui v0.5.0 | |
| 7 | + | github.com/bnema/nefergui v0.5.1 | |
| 8 | 8 | ) | |
| 9 | 9 | ||
| 10 | 10 | require ( | |
| @@ -12,7 +12,7 @@ require ( | |||
| 12 | 12 | github.com/bnema/purego v0.13.0-bnema.1 // indirect | |
| 13 | 13 | github.com/bnema/purego-vulkan v0.6.0 // indirect | |
| 14 | 14 | github.com/bnema/purego-xkbcommon v0.2.0 // indirect | |
| 15 | - | github.com/bnema/wlturbo v0.6.1 // indirect | |
| 15 | + | github.com/bnema/wlturbo v0.6.2 // indirect | |
| 16 | 16 | github.com/go-text/typesetting v0.3.5 // indirect | |
| 17 | 17 | golang.org/x/image v0.46.0 // indirect | |
| 18 | 18 | golang.org/x/sys v0.48.0 // indirect | |
| @@ -4,7 +4,7 @@ go 1.27 | |||||
| 4 | 4 | ||||
| 5 | require ( | 5 | require ( | ||
| 6 | github.com/bnema/neferclient v0.1.0 | 6 | github.com/bnema/neferclient v0.1.0 | ||
| 7 | - | github.com/bnema/nefergui v0.5.0 | 7 | + | github.com/bnema/nefergui v0.5.1 |
| 8 | ) | 8 | ) | ||
| 9 | 9 | ||||
| 10 | require ( | 10 | require ( | ||
| @@ -12,7 +12,7 @@ require ( | |||||
| 12 | github.com/bnema/purego v0.13.0-bnema.1 // indirect | 12 | github.com/bnema/purego v0.13.0-bnema.1 // indirect | ||
| 13 | github.com/bnema/purego-vulkan v0.6.0 // indirect | 13 | github.com/bnema/purego-vulkan v0.6.0 // indirect | ||
| 14 | github.com/bnema/purego-xkbcommon v0.2.0 // indirect | 14 | github.com/bnema/purego-xkbcommon v0.2.0 // indirect | ||
| 15 | - | github.com/bnema/wlturbo v0.6.1 // indirect | 15 | + | github.com/bnema/wlturbo v0.6.2 // indirect |
| 16 | github.com/go-text/typesetting v0.3.5 // indirect | 16 | github.com/go-text/typesetting v0.3.5 // indirect | ||
| 17 | golang.org/x/image v0.46.0 // indirect | 17 | golang.org/x/image v0.46.0 // indirect | ||
| 18 | golang.org/x/sys v0.48.0 // indirect | 18 | golang.org/x/sys v0.48.0 // indirect | ||
M examples/go.sum +4 -4 generated file: collapsed
M go.mod +1 -1
| @@ -5,7 +5,7 @@ go 1.27 | |||
| 5 | 5 | require ( | |
| 6 | 6 | github.com/bnema/go-wayland-bindings v0.1.0 | |
| 7 | 7 | github.com/bnema/purego-xkbcommon v0.2.0 | |
| 8 | - | github.com/bnema/wlturbo v0.6.1 | |
| 8 | + | github.com/bnema/wlturbo v0.6.2 | |
| 9 | 9 | github.com/stretchr/testify v1.12.1 | |
| 10 | 10 | golang.org/x/sys v0.48.0 | |
| 11 | 11 | ) | |
| @@ -5,7 +5,7 @@ go 1.27 | |||||
| 5 | require ( | 5 | require ( | ||
| 6 | github.com/bnema/go-wayland-bindings v0.1.0 | 6 | github.com/bnema/go-wayland-bindings v0.1.0 | ||
| 7 | github.com/bnema/purego-xkbcommon v0.2.0 | 7 | github.com/bnema/purego-xkbcommon v0.2.0 | ||
| 8 | - | github.com/bnema/wlturbo v0.6.1 | 8 | + | github.com/bnema/wlturbo v0.6.2 |
| 9 | github.com/stretchr/testify v1.12.1 | 9 | github.com/stretchr/testify v1.12.1 | ||
| 10 | golang.org/x/sys v0.48.0 | 10 | golang.org/x/sys v0.48.0 | ||
| 11 | ) | 11 | ) | ||
M go.sum +2 -2
| @@ -4,8 +4,8 @@ github.com/bnema/purego v0.13.0-bnema.1 h1:fKRdztnvTmRqAjANMoN+utEIH73dvPqVPJh2i | |||
| 4 | 4 | github.com/bnema/purego v0.13.0-bnema.1/go.mod h1:xS1iX3noypxnbOUEUAqOvkfnUzgHuu19VtL4+dfUMJM= | |
| 5 | 5 | github.com/bnema/purego-xkbcommon v0.2.0 h1:UWh5rSJIBhYImg8wZ98UzK4QNt7gvkKR6gFseO21mtg= | |
| 6 | 6 | github.com/bnema/purego-xkbcommon v0.2.0/go.mod h1:GE8JGmR/rqdklz96tFaFU7M5kI7jN1ma5mh+rz+XXrg= | |
| 7 | - | github.com/bnema/wlturbo v0.6.1 h1:iprJoRs+4duIsiemPVPSmN3qdp0Nbh2iLJ5VMwcY0fY= | |
| 8 | - | github.com/bnema/wlturbo v0.6.1/go.mod h1:4i1k1wyw7FDWOkh2hg1ZwPfrPRn3+E6WrYg9Qrt74CA= | |
| 7 | + | github.com/bnema/wlturbo v0.6.2 h1:wV+NlplUoh6wG9E9ZKsPATMDSrTaiez3+T0xCDFZZjg= | |
| 8 | + | github.com/bnema/wlturbo v0.6.2/go.mod h1:4i1k1wyw7FDWOkh2hg1ZwPfrPRn3+E6WrYg9Qrt74CA= | |
| 9 | 9 | github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= | |
| 10 | 10 | github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= | |
| 11 | 11 | github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= | |
| @@ -4,8 +4,8 @@ github.com/bnema/purego v0.13.0-bnema.1 h1:fKRdztnvTmRqAjANMoN+utEIH73dvPqVPJh2i | |||||
| 4 | github.com/bnema/purego v0.13.0-bnema.1/go.mod h1:xS1iX3noypxnbOUEUAqOvkfnUzgHuu19VtL4+dfUMJM= | 4 | github.com/bnema/purego v0.13.0-bnema.1/go.mod h1:xS1iX3noypxnbOUEUAqOvkfnUzgHuu19VtL4+dfUMJM= | ||
| 5 | github.com/bnema/purego-xkbcommon v0.2.0 h1:UWh5rSJIBhYImg8wZ98UzK4QNt7gvkKR6gFseO21mtg= | 5 | github.com/bnema/purego-xkbcommon v0.2.0 h1:UWh5rSJIBhYImg8wZ98UzK4QNt7gvkKR6gFseO21mtg= | ||
| 6 | github.com/bnema/purego-xkbcommon v0.2.0/go.mod h1:GE8JGmR/rqdklz96tFaFU7M5kI7jN1ma5mh+rz+XXrg= | 6 | github.com/bnema/purego-xkbcommon v0.2.0/go.mod h1:GE8JGmR/rqdklz96tFaFU7M5kI7jN1ma5mh+rz+XXrg= | ||
| 7 | - | github.com/bnema/wlturbo v0.6.1 h1:iprJoRs+4duIsiemPVPSmN3qdp0Nbh2iLJ5VMwcY0fY= | 7 | + | github.com/bnema/wlturbo v0.6.2 h1:wV+NlplUoh6wG9E9ZKsPATMDSrTaiez3+T0xCDFZZjg= |
| 8 | - | github.com/bnema/wlturbo v0.6.1/go.mod h1:4i1k1wyw7FDWOkh2hg1ZwPfrPRn3+E6WrYg9Qrt74CA= | 8 | + | github.com/bnema/wlturbo v0.6.2/go.mod h1:4i1k1wyw7FDWOkh2hg1ZwPfrPRn3+E6WrYg9Qrt74CA= |
| 9 | github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= | 9 | github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= | ||
| 10 | github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= | 10 | github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= | ||
| 11 | github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= | 11 | github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= | ||