Skip to content

proposal: testing: report energy consumption figures #30108

@Mahdi89

Description

@Mahdi89

I propose to report energy consumption figures in Go benchmarking machinery. This will allow Go developers to have some estimate of energy consumption of their programs as it's been shown that data movement accounts for 62.7% of energy usage in consumer devices. With energy factors becoming more and more important it's proved that impact of high-level code (e.g. by using more suitable data structures) on energy is orders of magnitude higher than low level/OS management etc. For the impact of high-level code on performance refer to https://github.com/dgryski/go-perfbook/blob/master/performance.md

With given allocated bytes in memory and ns/op I believe energy figures can be derived easily, however, architecture in use could have significant impact on these figures.

For instance, the following snippets show two different implementations where the first one uses variables locally and the second uses channels instead of variables. In terms of performance, the first one beats the second one by a factor of ~1000x (using Go's benchmarking tool). However, the second one avoids allocation of big data arrays and exploits serialisation (less random access), therefore I assume it must show better energy figures for real-world benchmarks:

func WithVariable() (int, int) {

	a := 2 + 3
	b := a + 3
	c := a + 5
	return b, c
}

func WithoutVariable() (int, int) {

	a := make(chan int, 2)
	a <- 2 + 3
	a <- 2 + 3
	return (<-a + 3), (<-a + 5)
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions