Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev tming cache #339

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1bb1b8c
feat:support result cache,issue: #315
tbs60 Nov 7, 2024
a8e9b88
feat:support result cache,issue: #315
tbs60 Nov 7, 2024
db15c5c
Merge branch 'TencentBlueKing:master' into dev_tming_cache
tbs60 Dec 9, 2024
608dd3b
feat:support result cache, issue: #315
tbs60 Dec 23, 2024
59d8533
feat:support result cache, issue: #315
tbs60 Dec 23, 2024
1ed30b1
feat:support result cache, issue: #315
tbs60 Dec 24, 2024
b65e0ef
feat:support result cache, issue: #315
tbs60 Dec 26, 2024
3625e34
feat:support result cache, issue: #315
tbs60 Dec 26, 2024
74a098d
feat:support result cache, issue: #315
tbs60 Dec 27, 2024
c150409
feat:support result cache, issue: #315
tbs60 Dec 31, 2024
644ca23
feat:support result cache, issue: #315
tbs60 Dec 31, 2024
6484f90
feat:support result cache, issue: #315
tbs60 Dec 31, 2024
0993dae
feat:support result cache, issue: #315
tbs60 Dec 31, 2024
a3f0b63
feat:support result cache, issue: #315
tbs60 Jan 2, 2025
4b449da
feat:support result cache, issue: #315
tbs60 Jan 2, 2025
78ed1e3
feat:support result cache, issue: #315
tbs60 Jan 6, 2025
43d900e
feat:support result cache, issue: #315
tbs60 Jan 6, 2025
867baba
feat:support result cache, issue: #315
tbs60 Jan 7, 2025
d4dcc1c
feat:support result cache, issue: #315
tbs60 Jan 8, 2025
4fa79c5
feat:support result cache, issue: #315
tbs60 Jan 8, 2025
65467ae
feat:support result cache, issue: #315
tbs60 Jan 17, 2025
1d45cfd
feat:support result cache, issue: #315
tbs60 Jan 20, 2025
96fe3e9
feat:support result cache, issue: #315
tbs60 Jan 20, 2025
ff38c8f
feat:support result cache, issue: #315
tbs60 Jan 20, 2025
fbbd92b
feat:support result cache, issue: #315
tbs60 Feb 6, 2025
7a49582
feat:support result cache, issue: #315
tbs60 Feb 7, 2025
664aedb
feat:support result cache, issue: #315
tbs60 Feb 7, 2025
e8fbbff
feat:support result cache, issue: #315
tbs60 Feb 7, 2025
8236676
feat:support result cache, issue: #315
tbs60 Feb 10, 2025
fe95ebc
Merge branch 'master' into dev_tming_cache
tming Feb 20, 2025
ff84d3c
feat:support result cache, issue: #315
tbs60 Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 114 additions & 89 deletions src/backend/booster/bk_dist/booster/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,95 +23,100 @@ import (

// define const vars
const (
FlagProjectID = "project_id"
FlagBuildID = "build_id"
FlagArgs = "args"
FlagGccVersion = "gcc_version"
FlagBazel = "bazel"
FlagBazelPlus = "bazel_plus"
FlagBazel4Plus = "bazel4_plus"
FlagBazelNoLauncher = "bazel_no_launcher"
FlagLauncher = "launcher"
FlagLog = "log"
FlagLogDir = "log_dir"
FlagLogToConsole = "log_to_console"
FlagExecutorLog = "executor_log"
FlagTest = "test"
FlagCommandPath = "command_path"
FlagLimit = "limit"
FlagNoLocal = "no_local"
FlagLocal = "local"
FlagDegraded = "degraded"
FlagSaveCode = "save_code"
FlagJobs = "jobs"
FlagMaxJobs = "max_jobs"
FlagPresetJobs = "preset_jobs"
FlagMaxDegradedJobs = "max_degraded_jobs"
FlagMaxLocalTotalJobs = "max_local_total_jobs"
FlagMaxLocalExeJobs = "max_local_exe_jobs"
FlagMaxLocalPreJobs = "max_local_pre_jobs"
FlagMaxLocalPostJobs = "max_local_post_jobs"
FlagHook = "hook"
FlagBoosterType = "booster_type"
FlagHookConfig = "hook_config"
FlagHookPreloadLib = "hook_preload_library"
FlagAdditionFile = "addition_file"
FlagDashboard = "dashboard"
FlagWorkerList = "worker_list"
FlagCheckMd5 = "check_md5"
FlagOutputEnvJSONFile = "output_env_json_file"
FlagOutputEnvSourceFile = "output_env_source_file"
FlagCommitSuicide = "commit_suicide"
FlagToolChainJSONFile = "tool_chain_json_file"
FlagSearchToolchain = "search_toolchain"
FlagBatchMode = "batch_mode"
FlagDirectives = "directives"
FlagGlobalSlots = "global_slots"
FlagSudoController = "sudo_controller"
FlagIOTimeoutSecs = "io_timeout_secs"
FlagPump = "pump"
FlagPumpDisableMacro = "pump_disable_macro"
FlagPumpIncludeSysHeader = "pump_include_sys_header"
FlagPumpCheck = "pump_check"
FlagPumpCache = "pump_cache"
FlagPumpCacheDir = "pump_cache_dir"
FlagPumpCacheSizeMaxMB = "pump_cache_size_max_MB"
FlagPumpCacheRemoveAll = "pump_cache_remove_all"
FlagPumpBlackList = "pump_black_list"
FlagPumpMinActionNum = "pump_min_action_num"
FlagPumpDisableStatCache = "pump_disable_stat_cache"
FlagPumpSearchLink = "pump_search_link"
FlagPumpSearchLinkFile = "pump_search_link_file"
FlagPumpSearchLinkDir = "pump_search_link_dir"
FlagPumpLstatByDir = "pump_lstat_by_dir"
FlagPumpCorrectCap = "pump_correct_cap"
FlagForceLocalList = "force_local_list"
FlagNoWork = "no_work"
FlagControllerNoWait = "controller_no_wait"
FlagControllerRemainTime = "controller_remain_time"
FlagServer = "server"
FlagWorkerSideCache = "worker_side_cache"
FlagLocalRecord = "local_record"
FlagWriteMemroMemroy = "write_memory"
FlagIdleKeepSecs = "idle_keep_secs"
FlagResourceTimeoutSecs = "resource_timeout_secs"
FlagLocalIdleCPUPercent = "use_local_cpu_percent"
FlagDisableFileLock = "disable_file_lock"
FlagAutoResourceMgr = "auto_resource_mgr"
FlagResIdleSecsForFree = "res_idle_secs_for_free"
FlagSendCork = "send_cork"
FlagSendFileMemoryLimit = "send_file_memory_limit"
FlagSendMemoryCache = "send_memory_cache"
FlagNetErrorLimit = "net_error_limit"
FlagRemoteRetryTimes = "remote_retry_times"
FlagEnableLink = "enable_link"
FlagEnableLib = "enable_lib"
FlagLongTCP = "long_tcp"
FlagUseDefaultWorker = "use_default_worker"
FlagDynamicPort = "dynamic_port"
FlagWorkerOfferSlot = "worker_offer_slot"
FlagCleanTmpFilesDayAgo = "clean_tmp_files_day_ago"
FlagIgnoreHttpStatus = "ignore_http_status"
FlagProjectID = "project_id"
FlagBuildID = "build_id"
FlagArgs = "args"
FlagGccVersion = "gcc_version"
FlagBazel = "bazel"
FlagBazelPlus = "bazel_plus"
FlagBazel4Plus = "bazel4_plus"
FlagBazelNoLauncher = "bazel_no_launcher"
FlagLauncher = "launcher"
FlagLog = "log"
FlagLogDir = "log_dir"
FlagLogToConsole = "log_to_console"
FlagExecutorLog = "executor_log"
FlagTest = "test"
FlagCommandPath = "command_path"
FlagLimit = "limit"
FlagNoLocal = "no_local"
FlagLocal = "local"
FlagDegraded = "degraded"
FlagSaveCode = "save_code"
FlagJobs = "jobs"
FlagMaxJobs = "max_jobs"
FlagPresetJobs = "preset_jobs"
FlagMaxDegradedJobs = "max_degraded_jobs"
FlagMaxLocalTotalJobs = "max_local_total_jobs"
FlagMaxLocalExeJobs = "max_local_exe_jobs"
FlagMaxLocalPreJobs = "max_local_pre_jobs"
FlagMaxLocalPostJobs = "max_local_post_jobs"
FlagHook = "hook"
FlagBoosterType = "booster_type"
FlagHookConfig = "hook_config"
FlagHookPreloadLib = "hook_preload_library"
FlagAdditionFile = "addition_file"
FlagDashboard = "dashboard"
FlagWorkerList = "worker_list"
FlagCheckMd5 = "check_md5"
FlagOutputEnvJSONFile = "output_env_json_file"
FlagOutputEnvSourceFile = "output_env_source_file"
FlagCommitSuicide = "commit_suicide"
FlagToolChainJSONFile = "tool_chain_json_file"
FlagSearchToolchain = "search_toolchain"
FlagBatchMode = "batch_mode"
FlagDirectives = "directives"
FlagGlobalSlots = "global_slots"
FlagSudoController = "sudo_controller"
FlagIOTimeoutSecs = "io_timeout_secs"
FlagPump = "pump"
FlagPumpDisableMacro = "pump_disable_macro"
FlagPumpIncludeSysHeader = "pump_include_sys_header"
FlagPumpCheck = "pump_check"
FlagPumpCache = "pump_cache"
FlagPumpCacheDir = "pump_cache_dir"
FlagPumpCacheSizeMaxMB = "pump_cache_size_max_MB"
FlagPumpCacheRemoveAll = "pump_cache_remove_all"
FlagPumpBlackList = "pump_black_list"
FlagPumpMinActionNum = "pump_min_action_num"
FlagPumpDisableStatCache = "pump_disable_stat_cache"
FlagPumpSearchLink = "pump_search_link"
FlagPumpSearchLinkFile = "pump_search_link_file"
FlagPumpSearchLinkDir = "pump_search_link_dir"
FlagPumpLstatByDir = "pump_lstat_by_dir"
FlagPumpCorrectCap = "pump_correct_cap"
FlagForceLocalList = "force_local_list"
FlagNoWork = "no_work"
FlagControllerNoWait = "controller_no_wait"
FlagControllerRemainTime = "controller_remain_time"
FlagServer = "server"
FlagResultCacheList = "result_cache_list"
FlagWorkerSideCache = "worker_side_cache"
FlagLocalRecord = "local_record"
FlagWriteMemroMemroy = "write_memory"
FlagIdleKeepSecs = "idle_keep_secs"
FlagResourceTimeoutSecs = "resource_timeout_secs"
FlagLocalIdleCPUPercent = "use_local_cpu_percent"
FlagDisableFileLock = "disable_file_lock"
FlagAutoResourceMgr = "auto_resource_mgr"
FlagResIdleSecsForFree = "res_idle_secs_for_free"
FlagSendCork = "send_cork"
FlagSendFileMemoryLimit = "send_file_memory_limit"
FlagSendMemoryCache = "send_memory_cache"
FlagNetErrorLimit = "net_error_limit"
FlagRemoteRetryTimes = "remote_retry_times"
FlagEnableLink = "enable_link"
FlagEnableLib = "enable_lib"
FlagLongTCP = "long_tcp"
FlagUseDefaultWorker = "use_default_worker"
FlagDynamicPort = "dynamic_port"
FlagWorkerOfferSlot = "worker_offer_slot"
FlagCleanTmpFilesDayAgo = "clean_tmp_files_day_ago"
FlagIgnoreHttpStatus = "ignore_http_status"
FlagResultCacheType = "result_cache_type"
FlagResultCacheTriggleSecs = "result_cache_triggle_secs"
FlagResultCacheIndexNum = "result_cache_index_num"
FlagResultCacheFileNum = "result_cache_file_num"

EnvBuildIDOld = "TURBO_PLAN_BUILD_ID"
EnvBuildID = "TBS_BUILD_ID"
Expand Down Expand Up @@ -389,6 +394,10 @@ var (
Name: "server",
Usage: "specify the server address for booster",
},
commandCli.StringSliceFlag{
Name: "result_cache_list, rcl",
Usage: "specify the result cache list for booster",
},
commandCli.BoolFlag{
Name: "worker_side_cache, wsc",
Usage: "check file cache in worker side before sending",
Expand Down Expand Up @@ -477,6 +486,22 @@ var (
Name: "ignore_http_status",
Usage: "tasks will be executed even local http connection disconnected when this flag set",
},
commandCli.IntFlag{
Name: "result_cache_type",
Usage: "use which result cache type,0:no cache,1:local cache,2:remote cache,3:both",
},
commandCli.IntFlag{
Name: "result_cache_triggle_secs",
Usage: "only remote execute time(seconds) great than this will triggle result cache",
},
commandCli.IntFlag{
Name: "result_cache_index_num",
Usage: "specify index number for local result cache",
},
commandCli.IntFlag{
Name: "result_cache_file_num",
Usage: "specify file number for local result cache",
},
}
)

Expand Down
148 changes: 87 additions & 61 deletions src/backend/booster/bk_dist/booster/command/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ func newBooster(c *commandCli.Context) (*pkg.Booster, error) {
cleanTmpFilesDayAgo = c.Int(FlagCleanTmpFilesDayAgo)
}

// cache_server, _ := getCacheServerHost(c)

resultCacheTriggleSecs := -1
if c.IsSet(FlagResultCacheTriggleSecs) && c.Int(FlagResultCacheTriggleSecs) >= 0 {
resultCacheTriggleSecs = c.Int(FlagResultCacheTriggleSecs)
}

// generate a new booster.
cmdConfig := dcType.BoosterConfig{
Type: dcType.GetBoosterType(bt),
Expand All @@ -257,67 +264,70 @@ func newBooster(c *commandCli.Context) (*pkg.Booster, error) {
Args: c.String(FlagArgs),
Cmd: strings.Join(os.Args, " "),
Works: dcType.BoosterWorks{
Stdout: os.Stdout,
Stderr: os.Stderr,
RunDir: runDir,
User: usr.Username,
LimitPerWorker: c.Int(FlagLimit),
Jobs: c.Int(FlagJobs),
MaxJobs: c.Int(FlagMaxJobs),
Presetjobs: c.Int(FlagPresetJobs),
MaxDegradedJobs: c.Int(FlagMaxDegradedJobs),
MaxLocalTotalJobs: defaultCPULimit(c.Int(FlagMaxLocalTotalJobs)),
MaxLocalPreJobs: c.Int(FlagMaxLocalPreJobs),
MaxLocalExeJobs: c.Int(FlagMaxLocalExeJobs),
MaxLocalPostJobs: c.Int(FlagMaxLocalPostJobs),
HookPreloadLibPath: c.String(FlagHookPreloadLib),
HookConfigPath: c.String(FlagHookConfig),
HookMode: c.Bool(FlagHook),
NoLocal: c.Bool(FlagNoLocal),
Local: c.Bool(FlagLocal),
WorkerSideCache: c.Bool(FlagWorkerSideCache),
LocalRecord: c.Bool(FlagLocalRecord),
Degraded: c.Bool(FlagDegraded),
ExecutorLogLevel: c.String(FlagExecutorLog),
Environments: make(map[string]string),
Bazel: c.Bool(FlagBazel),
BazelPlus: c.Bool(FlagBazelPlus),
Bazel4Plus: c.Bool(FlagBazel4Plus),
BazelNoLauncher: c.Bool(FlagBazelNoLauncher),
Launcher: c.Bool(FlagLauncher) || c.Bool(FlagBazelPlus) || c.Bool(FlagBazel4Plus),
AdditionFiles: c.StringSlice(FlagAdditionFile),
WorkerList: c.StringSlice(FlagWorkerList),
CheckMd5: c.Bool(FlagCheckMd5),
OutputEnvJSONFile: c.StringSlice(FlagOutputEnvJSONFile),
OutputEnvSourceFile: c.StringSlice(FlagOutputEnvSourceFile),
CommitSuicide: c.Bool(FlagCommitSuicide),
ToolChainJSONFile: c.String(FlagToolChainJSONFile),
SupportDirectives: c.Bool(FlagDirectives),
GlobalSlots: c.Bool(FlagGlobalSlots),
IOTimeoutSecs: c.Int(FlagIOTimeoutSecs),
Pump: c.Bool(FlagPump),
PumpDisableMacro: c.Bool(FlagPumpDisableMacro),
PumpIncludeSysHeader: c.Bool(FlagPumpIncludeSysHeader),
PumpCheck: c.Bool(FlagPumpCheck),
PumpCache: c.Bool(FlagPumpCache),
PumpCacheDir: c.String(FlagPumpCacheDir),
PumpCacheSizeMaxMB: pumpCacheSizeMaxMB,
PumpCacheRemoveAll: c.Bool(FlagPumpCacheRemoveAll),
PumpBlackList: c.StringSlice(FlagPumpBlackList),
PumpMinActionNum: int32(pumpMinActionNum),
PumpDisableStatCache: c.Bool(FlagPumpDisableStatCache),
PumpSearchLink: c.Bool(FlagPumpSearchLink),
PumpSearchLinkFile: c.String(FlagPumpSearchLinkFile),
PumpSearchLinkDir: c.StringSlice(FlagPumpSearchLinkDir),
PumpLstatByDir: c.Bool(FlagPumpLstatByDir),
PumpCorrectCap: c.Bool(FlagPumpCorrectCap),
ForceLocalList: c.StringSlice(FlagForceLocalList),
NoWork: c.Bool(FlagNoWork),
WriteMemroy: c.Bool(FlagWriteMemroMemroy),
IdleKeepSecs: c.Int(FlagIdleKeepSecs),
CleanTmpFilesDayAgo: cleanTmpFilesDayAgo,
SearchToolchain: c.Bool(FlagSearchToolchain),
IgnoreHttpStatus: c.Bool(FlagIgnoreHttpStatus),
Stdout: os.Stdout,
Stderr: os.Stderr,
RunDir: runDir,
User: usr.Username,
LimitPerWorker: c.Int(FlagLimit),
Jobs: c.Int(FlagJobs),
MaxJobs: c.Int(FlagMaxJobs),
Presetjobs: c.Int(FlagPresetJobs),
MaxDegradedJobs: c.Int(FlagMaxDegradedJobs),
MaxLocalTotalJobs: defaultCPULimit(c.Int(FlagMaxLocalTotalJobs)),
MaxLocalPreJobs: c.Int(FlagMaxLocalPreJobs),
MaxLocalExeJobs: c.Int(FlagMaxLocalExeJobs),
MaxLocalPostJobs: c.Int(FlagMaxLocalPostJobs),
HookPreloadLibPath: c.String(FlagHookPreloadLib),
HookConfigPath: c.String(FlagHookConfig),
HookMode: c.Bool(FlagHook),
NoLocal: c.Bool(FlagNoLocal),
Local: c.Bool(FlagLocal),
WorkerSideCache: c.Bool(FlagWorkerSideCache),
LocalRecord: c.Bool(FlagLocalRecord),
Degraded: c.Bool(FlagDegraded),
ExecutorLogLevel: c.String(FlagExecutorLog),
Environments: make(map[string]string),
Bazel: c.Bool(FlagBazel),
BazelPlus: c.Bool(FlagBazelPlus),
Bazel4Plus: c.Bool(FlagBazel4Plus),
BazelNoLauncher: c.Bool(FlagBazelNoLauncher),
Launcher: c.Bool(FlagLauncher) || c.Bool(FlagBazelPlus) || c.Bool(FlagBazel4Plus),
AdditionFiles: c.StringSlice(FlagAdditionFile),
WorkerList: c.StringSlice(FlagWorkerList),
CheckMd5: c.Bool(FlagCheckMd5),
OutputEnvJSONFile: c.StringSlice(FlagOutputEnvJSONFile),
OutputEnvSourceFile: c.StringSlice(FlagOutputEnvSourceFile),
CommitSuicide: c.Bool(FlagCommitSuicide),
ToolChainJSONFile: c.String(FlagToolChainJSONFile),
SupportDirectives: c.Bool(FlagDirectives),
GlobalSlots: c.Bool(FlagGlobalSlots),
IOTimeoutSecs: c.Int(FlagIOTimeoutSecs),
Pump: c.Bool(FlagPump),
PumpDisableMacro: c.Bool(FlagPumpDisableMacro),
PumpIncludeSysHeader: c.Bool(FlagPumpIncludeSysHeader),
PumpCheck: c.Bool(FlagPumpCheck),
PumpCache: c.Bool(FlagPumpCache),
PumpCacheDir: c.String(FlagPumpCacheDir),
PumpCacheSizeMaxMB: pumpCacheSizeMaxMB,
PumpCacheRemoveAll: c.Bool(FlagPumpCacheRemoveAll),
PumpBlackList: c.StringSlice(FlagPumpBlackList),
PumpMinActionNum: int32(pumpMinActionNum),
PumpDisableStatCache: c.Bool(FlagPumpDisableStatCache),
PumpSearchLink: c.Bool(FlagPumpSearchLink),
PumpSearchLinkFile: c.String(FlagPumpSearchLinkFile),
PumpSearchLinkDir: c.StringSlice(FlagPumpSearchLinkDir),
PumpLstatByDir: c.Bool(FlagPumpLstatByDir),
PumpCorrectCap: c.Bool(FlagPumpCorrectCap),
ForceLocalList: c.StringSlice(FlagForceLocalList),
NoWork: c.Bool(FlagNoWork),
WriteMemroy: c.Bool(FlagWriteMemroMemroy),
IdleKeepSecs: c.Int(FlagIdleKeepSecs),
CleanTmpFilesDayAgo: cleanTmpFilesDayAgo,
SearchToolchain: c.Bool(FlagSearchToolchain),
IgnoreHttpStatus: c.Bool(FlagIgnoreHttpStatus),
ResultCacheList: c.StringSlice(FlagResultCacheList),
ResultCacheType: c.Int(FlagResultCacheType),
ResultCacheTriggleSecs: resultCacheTriggleSecs,
},

Transport: dcType.BoosterTransport{
Expand Down Expand Up @@ -367,6 +377,8 @@ func newBooster(c *commandCli.Context) (*pkg.Booster, error) {
UseDefaultWorker: c.Bool(FlagUseDefaultWorker) || c.Bool(FlagBazelNoLauncher),
DynamicPort: withDynamicPort,
WorkerOfferSlot: c.Bool(FlagWorkerOfferSlot),
ResultCacheIndexNum: c.Int(FlagResultCacheIndexNum),
ResultCacheFileNum: c.Int(FlagResultCacheFileNum),
},
}

Expand Down Expand Up @@ -563,6 +575,20 @@ func getServerFromConfig(c *commandCli.Context) (string, error) {
return "", fmt.Errorf("no server specified")
}

// func getCacheServerHost(c *commandCli.Context) (string, error) {
// if c.IsSet(FlagCacheServer) {
// s := c.String(FlagCacheServer)
// blog.Infof("booster-command: use cache server from command line --cache_server specified: %s", s)
// return s, nil
// }

// if c.Bool(FlagTest) {
// return TestCacheServerHost, nil
// }

// return ProdCacheServerHost, nil
// }

func getConfig(path string) (*Config, error) {
f, err := os.Open(path)
if err != nil {
Expand Down
Loading