8000 zygote hash and comment out evictor's 2nd queue · open-lambda/open-lambda@a026be2 · GitHub
[go: up one dir, main page]

Skip to content

Commit a026be2

Browse files
committed
zygote hash and comment out evictor's 2nd queue
1 parent 6ab424e commit a026be2

File tree

7 files changed

+24
-15
lines changed

7 files changed

+24
-15
lines changed

src/boss/cloudvm/azure_worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (worker *Worker) start(firstTime bool) error {
142142
run_one_time := "sudo python3 run_worker.py"
143143

144144
var run_worker_up string
145-
run_worker_up = fmt.Sprintf("sudo ./ol worker up -i ol-min -d -o import_cache_tree=%s,worker_url=0.0.0.0,features.warmup=false,limits.mem_mb=600,mem_pool_mb=10000,trace.evictor=true", tree_path)
145+
run_worker_up = fmt.Sprintf("sudo ./ol worker up -i ol-min -d -o import_cache_tree=%s,worker_url=0.0.0.0,features.warmup=false,limits.mem_mb=600,mem_pool_mb=8192,trace.evictor=true", tree_path)
146146

147147
var cmd string
148148
if firstTime {

src/boss/cloudvm/worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ func (pool *WorkerPool) RunLambda(w http.ResponseWriter, r *http.Request) {
520520
}
521521

522522
if loadbalancer.Lb.LbType == loadbalancer.Hash {
523-
targetGroup = loadbalancer.HashGetGroup(img, len(pool.workers[RUNNING]))
523+
targetGroup = loadbalancer.HashGetGroup(pkgs, len(pool.workers[RUNNING]))
524524
// fmt.Println(targetGroup)
525525
targetGroups = append(targetGroups, targetGroup)
526526
}

src/boss/loadbalancer/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func InitLoadBalancer(lbType int, maxGroup int, path string) {
7474
}
7575
}
7676
if lbType == Hash {
77+
GetRoot()
7778
initHasher()
7879
}
7980
}

src/boss/loadbalancer/hash.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package loadbalancer
22

33
import (
44
"crypto/sha256"
5+
"encoding/binary"
56
"hash"
6-
"math/big"
77
"sync"
88
)
99

@@ -12,23 +12,31 @@ var (
1212
hasherMutex sync.Mutex
1313
)
1414

15-
func hashString(input string) int {
15+
func hashString(input int) int {
1616
hasherMutex.Lock() // Lock the mutex before using the hasher
1717
defer hasherMutex.Unlock() // Unlock the mutex when the function exits
1818

1919
hasher.Reset()
20-
hasher.Write([]byte(input))
21-
hashBytes := hasher.Sum(nil)
20+
buf := make([]byte, binary.MaxVarintLen64)
21+
binary.LittleEndian.PutUint64(buf, uint64(input))
2222

23-
bigIntHash := new(big.Int).SetBytes(hashBytes).Int64()
24-
if bigIntHash < 0 {
25-
bigIntHash = -bigIntHash
23+
sum := sha256.Sum256(buf)
24+
// Take the first few bytes to fit into an int, ensuring it's always positive
25+
var truncatedHash int
26+
if size := binary.Size(truncatedHash); size == 64/8 {
27+
// 64-bit architecture
28+
truncatedHash = int(binary.LittleEndian.Uint64(sum[:8]) &^ (1 << 63))
29+
} else {
30+
// 32-bit architecture
31+
truncatedHash = int(binary.LittleEndian.Uint32(sum[:4]) &^ (1 << 31))
2632
}
27-
return int(bigIntHash)
33+
34+
return truncatedHash
2835
}
2936

30-
func HashGetGroup(img string, running int) int {
31-
hashInt := hashString(img)
37+
func HashGetGroup(pkgs []string, running int) int {
38+
node := root.Lookup(pkgs)
39+
hashInt := hashString(node.SplitGeneration)
3240
group := hashInt % running
3341
return group
3442
}

src/common/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func LoadDefaults(olPath string) error {
168168
Procs: 10,
169169
Mem_mb: 50,
170170
CPU_percent: 100,
171-
Max_runtime_default: 90,
171+
Max_runtime_default: 180,
172172
Installer_mem_mb: 500,
173173
Swappiness: 0,
174174
},

src/worker/sandbox/cgroups/cgroup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (cg *CgroupImpl) AddPid(pid string) error {
186186
func (cg *CgroupImpl) setFreezeState(state int64) error {
187187
cg.WriteInt("cgroup.freeze", state)
188188

189-
timeout := 5 * time.Second
189+
timeout := 30 * time.Second
190190
sleepDur := 1 * time.Millisecond
191191
time.Sleep(sleepDur)
192192
start := time.Now()

src/worker/sandbox/evictors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
// evictor can only run if there's enough memory for two containers.
1414
// if there are only 2, our goal is to have free mem for on container.
1515
// 20% only applies to containers in excess of 2.
16-
const FREE_SANDBOXES_PERCENT_GOAL = 20
16+
const FREE_SANDBOXES_PERCENT_GOAL = 10
1717

1818
// the maximum number of evictions we'll do concurrently
1919
const CONCURRENT_EVICTIONS = 8

0 commit comments

Comments
 (0)
0