Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
shihyuho committed Jan 17, 2024
1 parent 5a7a59d commit 05e77cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Non-Heap = Direct Memory + Metaspace + Reserved Code Cache + (Thread Stack * Thr

| 參數說明 | 優先判斷 args 傳入 | 其次判斷 OS Variable | 最後的預設值或行為 |
|---|---|---|---|
| 是否啟用記憶體計算機制 | | `$MEM_CALC_ENABLED` | `true` |
| 記憶體計算工具分配的預留空間百分比 | `--head-room` | `$BPL_JVM_HEAD_ROOM` | `0` |
| 運行時將加載的 class 數量 | `--loaded-class-count` | `$BPL_JVM_LOADED_CLASS_COUNT` | 動態計算全部 class 總數量的 35%, 包含 App 目錄下及 JVM 中的 class 等 |
| 運行時的用戶線程數 | `--thread-count` | `$BPL_JVM_THREAD_COUNT` | `200` |
Expand Down
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ read_jvm_flags() {
}

execute_memory_calculator() {
if [ "${MEM_CALC_ENABLED}" = "false" ]; then
echo "Memory calculator is disabled"
return
fi

local bin_path=$1
local debug=$2
$bin_path/memory-calculator -o="$TMP_ENV" -v="$debug" || { echo "Memory calculator failed"; exit 1; }
Expand Down
12 changes: 0 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
)

const (
envEnabled = "MEM_CALC_ENABLED"
envJavaHome = "JAVA_HOME"
envJavaOpts = "JAVA_OPTS"
envJavaToolOptions = "JAVA_TOOL_OPTIONS"
Expand Down Expand Up @@ -85,7 +84,6 @@ var (
)

type Config struct {
enabled bool // 整個機制是否啟用
jvmOptions string
headRoom int
threadCount int
Expand Down Expand Up @@ -113,10 +111,6 @@ func main() {
fmt.Println(version)
return nil
}
if !c.enabled {
fmt.Printf("%v is disabled\n", cmd.Short)
return nil
}
return run(c)
},
}
Expand All @@ -140,7 +134,6 @@ func main() {

func newConfig() Config {
c := Config{
enabled: true,
jvmOptions: defaultJvmOptions,
headRoom: defaultHeadRoom,
threadCount: defaultThreadCount,
Expand All @@ -150,11 +143,6 @@ func newConfig() Config {
enableJmx: defaultEnableJmx,
enableJdwp: defaultEnableJdwp,
}
if val, ok := os.LookupEnv(envEnabled); ok {
if b, err := strconv.ParseBool(val); err == nil {
c.enabled = b
}
}
if val, ok := os.LookupEnv(envJavaOpts); ok {
c.jvmOptions = val
}
Expand Down

0 comments on commit 05e77cd

Please sign in to comment.