Skip to content

Commit e34e77c

Browse files
arkamarjakubno
andauthored
refactor: use N << 10/20 style for readable byte-size constants (#2186)
* refactor: use N << 10/20 style for readable byte-size constants Replace misleading `2 << N` bit shifts with `N << 10` (KiB) or `N << 20` (MiB) style so the human-readable size is immediately obvious. Keep `2 << 20` where it already reads naturally as 2 MiB. No functional change — all values are identical. * refactor: annotate constants with readable size equivalents Co-authored-by: Jakub Novák <kubus.novak@gmail.com>
1 parent bde9fa2 commit e34e77c

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/envd/internal/logs/bufferedEvents.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
defaultMaxBufferSize = 2 << 15
10+
defaultMaxBufferSize = 64 << 10 // 64 KiB
1111
defaultTimeout = 2 * time.Second
1212
)
1313

packages/envd/internal/services/process/handler/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const (
2828
defaultNice = 0
2929
defaultOomScore = 100
3030
outputBufferSize = 64
31-
stdChunkSize = 2 << 14
32-
ptyChunkSize = 2 << 13
31+
stdChunkSize = 32 << 10 // 32 KiB
32+
ptyChunkSize = 16 << 10 // 16 KiB
3333
)
3434

3535
type ProcessExit struct {

packages/orchestrator/internal/sandbox/template/storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
const (
1717
oldMemfileHugePageSize = 2 << 20 // 2 MiB
18-
oldRootfsBlockSize = 2 << 11 // 4 KiB
18+
oldRootfsBlockSize = 4 << 10 // 4 KiB
1919
)
2020

2121
type Storage struct {

packages/shared/pkg/storage/header/diff.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
)
99

1010
const (
11-
PageSize = 2 << 11
12-
HugepageSize = 2 << 20
13-
RootfsBlockSize = 2 << 11
11+
PageSize = 4 << 10 // 4 KiB
12+
HugepageSize = 2 << 20 // 2 MiB
13+
RootfsBlockSize = 4 << 10 // 4 KiB
1414
)
1515

1616
var tracer = otel.Tracer("github.com/e2b-dev/infra/packages/shared/pkg/storage/header")

packages/shared/pkg/storage/storage_google.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
const (
3535
googleReadTimeout = 10 * time.Second
3636
googleOperationTimeout = 5 * time.Second
37-
googleBufferSize = 2 << 21
37+
googleBufferSize = 4 << 20 // 4 MiB
3838
googleInitialBackoff = 10 * time.Millisecond
3939
googleMaxBackoff = 10 * time.Second
4040
googleBackoffMultiplier = 2

0 commit comments

Comments
 (0)