Suppose you have a type that needs explicit destruction to release resources:
type MyType struct {
...
}
func New() *MyType {
// acquire resources...
Suppose you have a type that needs explicit destruction to release resources:
type MyType struct {
...
}
func New() *MyType {
// acquire resources...
package main | |
import "go/jit" | |
func main() { | |
// jit.Run is a shorthand for jit.Compile, jit.Link and jit.Load | |
c, err := jit.Run(` | |
// - compiler is the same as the one used to build the executable | |
// the jit is running in | |
// - imports are allowed (but are restricted to the imports of |
type WriteBatcher struct { | |
l sync.Mutex | |
pending bool | |
buf []byte | |
err error | |
} | |
func (w *WriteBatcher) Write(p []byte) (int, error) { | |
w.l.Lock() | |
defer w.l.Unlock() |
We want to:
To this end we would like to find a scheme that progressively gives more freedom in CPU resource consumption to processes that stay below their share of CPU resources (including using more than their allocated shares) while restricting processes that use more than their share of CPU resources, especially if CPU-bound, to use only their allocation.
CFLAGS=-O2 -flto -ffunction-sections -fdata-sections -Wl,--gc-sections | |
CFLAGSNATIVE=-march=native -mtune=native | |
CFLAGSSTATIC=-static | |
build: aw.c | |
gcc -o aw aw.c $(CFLAGS) | |
build-static: aw.c | |
gcc -o aw aw.c $(CFLAGS) $(CFLAGSSTATIC) | |
I hereby claim:
To claim this, I am signing this object:
package intern | |
import ( | |
"sync" | |
) | |
type Pool struct { | |
sync.RWMutex | |
lookup map[string]string | |
} |
name old time/op new time/op delta | |
BuildString_Builder/1Write_NoGrow-2 43.4ns ± 2% 43.4ns ± 1% ~ (p=0.392 n=13+13) | |
BuildString_Builder/3Write_NoGrow-2 163ns ± 1% 161ns ± 1% -0.77% (p=0.001 n=13+14) | |
BuildString_Builder/3Write_Grow-2 61.1ns ± 1% 61.7ns ± 2% +0.98% (p=0.001 n=15+15) | |
BuildString_ByteBuffer/1Write_NoGrow-2 75.4ns ± 2% 76.4ns ± 1% +1.24% (p=0.000 n=13+12) | |
BuildString_ByteBuffer/3Write_NoGrow-2 230ns ± 2% 335ns ±15% +45.70% (p=0.000 n=13+13) | |
BuildString_ByteBuffer/3Write_Grow-2 181ns ± 2% 247ns ±15% +36.28% (p=0.000 n=14+15) | |
GenericNoMatch-2 380ns ± 2% 407ns ± 6% +7.07% (p=0.000 n=15+15) | |
GenericMatch1-2 5.37µs ± 4% 5.28µs ± 4% -1.68% (p=0.023 n=15+15) | |
GenericMatch2-2 21.1µs ± 3% 20.8µs ± 2% ~ (p=0.098 n=15+15) |
package partitioner | |
/* | |
A partitioner that assigns affinity from keys to partitions, while at the same time | |
attempting to spread the load across partitions. Affinity, to this end, is temporary. | |
This means that the affinity of a key to a partition changes over time. | |
There are three parameters that affect how often the affinity changes: | |
- every timeWindow affinity changes for all keys | |
- when, within a timeWindow, a key produces more than switchEveryBytes bytes or | |
switchEveryMessages messages the affinity of that key changes |