Skip to content

Commit

Permalink
perf: improve garden performance (#4938)
Browse files Browse the repository at this point in the history
* perf: replace _.cloneDeep with fast-copy

* perf: lower debug logs log level

* perf: disable source mapping support

* chore: make the linter happy
  • Loading branch information
TimBeyer authored Aug 14, 2023
1 parent 65d3e75 commit bf00e65
Show file tree
Hide file tree
Showing 36 changed files with 71 additions and 35 deletions.
1 change: 0 additions & 1 deletion cli/bin/garden
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ if (process.env.GARDEN_ENABLE_PROFILING === "1" || process.env.GARDEN_ENABLE_PRO
const { initTracing } = require("@garden-io/core/build/src/util/open-telemetry/tracing")
initTracing()

require("source-map-support").install()
const cli = require("../build/src/cli")

// eslint-disable-next-line @typescript-eslint/no-floating-promises
Expand Down
1 change: 1 addition & 0 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"eventemitter2": "^6.4.9",
"eventemitter3": "^5.0.0",
"execa": "^4.1.0",
"fast-copy": "^3.0.1",
"fs-extra": "^11.1.0",
"get-port": "^5.1.1",
"glob": "^10.2.6",
Expand Down
3 changes: 2 additions & 1 deletion core/src/actions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import { actionOutputsSchema } from "../plugin/handlers/base/base"
import type { GraphResult, GraphResults } from "../graph/results"
import type { RunResult } from "../plugin/base"
import { Memoize } from "typescript-memoize"
import { cloneDeep, flatten, fromPairs, isString, memoize, omit, sortBy } from "lodash"
import cloneDeep from "fast-copy"
import { flatten, fromPairs, isString, memoize, omit, sortBy } from "lodash"
import { ActionConfigContext, ActionSpecContext } from "../config/template-contexts/actions"
import { relative } from "path"
import { InternalError } from "../exceptions"
Expand Down
4 changes: 2 additions & 2 deletions core/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ import { getCustomCommands } from "../commands/custom"
import { Profile } from "../util/profiling"
import { prepareDebugLogfiles } from "./debug-logs"
import { Log } from "../logger/log-entry"
import { JsonFileWriter } from "../logger/writers/json-file-writer"
import { dedent } from "../util/string"
import { GardenProcess, GlobalConfigStore } from "../config-store/global"
import { registerProcess, waitForOutputFlush } from "../process"
import { uuidv4 } from "../util/random"
import { withSessionContext } from "../util/open-telemetry/context"
import { wrapActiveSpan } from "../util/open-telemetry/spans"
import { JsonFileWriter } from "../logger/writers/json-file-writer"

export interface RunOutput {
argv: any
Expand Down Expand Up @@ -135,7 +135,7 @@ ${renderCommands(commands)}
{
logFilePath: join(gardenDirPath, LOGS_DIR_NAME, jsonLogfileName),
truncatePrevious: true,
level: LogLevel.silly,
level: LogLevel.debug,
json: true,
},
{
Expand Down
3 changes: 2 additions & 1 deletion core/src/commands/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Bluebird from "bluebird"
import chalk from "chalk"
import execa from "execa"
import { apply as jsonMerge } from "json-merge-patch"
import { cloneDeep, keyBy, mapValues, flatten } from "lodash"
import cloneDeep from "fast-copy"
import { keyBy, mapValues, flatten } from "lodash"
import { parseCliArgs, prepareMinimistOpts } from "../cli/helpers"
import { BooleanParameter, globalOptions, IntegerParameter, Parameter, StringParameter } from "../cli/params"
import { loadConfigResources } from "../config/base"
Expand Down
3 changes: 2 additions & 1 deletion core/src/commands/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import chalk from "chalk"
import { cloneDeep, flatten, last, repeat, size } from "lodash"
import cloneDeep from "fast-copy"
import { flatten, last, repeat, size } from "lodash"
import { printHeader, getTerminalWidth, renderMessageWithDivider, renderDuration } from "../logger/util"
import { Command, CommandParams, CommandResult } from "./base"
import { dedent, wordWrap, deline } from "../util/string"
Expand Down
3 changes: 2 additions & 1 deletion core/src/config-store/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { ConfigStore } from "./base"
import { z } from "zod"
import { readFile } from "fs-extra"
import { load } from "js-yaml"
import { cloneDeep, omit } from "lodash"
import cloneDeep from "fast-copy"
import { omit } from "lodash"

export const legacyGlobalConfigFilename = "global-config.yml"
export const globalConfigFilename = "global-config.json"
Expand Down
3 changes: 2 additions & 1 deletion core/src/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Joi, { SchemaLike } from "@hapi/joi"
import Ajv from "ajv"
import addFormats from "ajv-formats"
import { splitLast, deline, dedent, naturalList, titleize } from "../util/string"
import { cloneDeep, isArray, isPlainObject, isString, mapValues, memoize } from "lodash"
import cloneDeep from "fast-copy"
import { isArray, isPlainObject, isString, mapValues, memoize } from "lodash"
import { joiPathPlaceholder } from "./validation"
import { DOCS_BASE_URL, GardenApiVersion } from "../constants"
import { ActionKind, actionKinds, actionKindsLower } from "../actions/types"
Expand Down
3 changes: 2 additions & 1 deletion core/src/config/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import { resolveTemplateStrings } from "../template-string/template-string"
import { EnvironmentConfigContext, ProjectConfigContext } from "./template-contexts/project"
import { findByName, getNames } from "../util/util"
import { ConfigurationError, ParameterError, ValidationError } from "../exceptions"
import { cloneDeep, memoize } from "lodash"
import cloneDeep from "fast-copy"
import { memoize } from "lodash"
import { GenericProviderConfig, providerConfigBaseSchema } from "./provider"
import { DOCS_BASE_URL, GardenApiVersion, GitScanMode, gitScanModes } from "../constants"
import { defaultDotIgnoreFile } from "../util/fs"
Expand Down
3 changes: 2 additions & 1 deletion core/src/docs/table-of-contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import matter = require("gray-matter")
import dtree = require("directory-tree")
import { readFileSync, writeFile, createFile } from "fs-extra"
import { resolve } from "path"
import { cloneDeep, repeat } from "lodash"
import cloneDeep from "fast-copy"
import { repeat } from "lodash"
import titleize = require("titleize")
import humanizeString = require("humanize-string")
import { dedent } from "../util/string"
Expand Down
3 changes: 2 additions & 1 deletion core/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { ensureDir } from "fs-extra"
import dedent from "dedent"
import { platform, arch } from "os"
import { relative, resolve } from "path"
import { flatten, sortBy, keyBy, mapValues, cloneDeep, groupBy, set } from "lodash"
import cloneDeep from "fast-copy"
import { flatten, sortBy, keyBy, mapValues, groupBy, set } from "lodash"
import AsyncLock from "async-lock"

import { TreeCache } from "./cache"
Expand Down
3 changes: 2 additions & 1 deletion core/src/graph/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import Bluebird from "bluebird"
import { cloneDeep, isEqual, mapValues, memoize, omit, pick, uniq } from "lodash"
import cloneDeep from "fast-copy"
import { isEqual, mapValues, memoize, omit, pick, uniq } from "lodash"
import {
Action,
ActionConfig,
Expand Down
3 changes: 2 additions & 1 deletion core/src/logger/log-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import logSymbols from "log-symbols"
import { cloneDeep, round } from "lodash"
import cloneDeep from "fast-copy"
import { round } from "lodash"

import { LogLevel } from "./logger"
import { Omit } from "../util/util"
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/kubernetes/helm/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { ExecBuildConfig } from "../../exec/build"
import { HelmActionConfig, HelmDeployConfig, HelmPodTestConfig } from "./config"
import { getServiceResourceSpec } from "../util"
import { jsonMerge } from "../../../util/util"
import { cloneDeep, omit } from "lodash"
import cloneDeep from "fast-copy"
import { omit } from "lodash"
import { DeepPrimitiveMap } from "../../../config/common"
import { convertServiceResource } from "../kubernetes-type/common"
import { ConvertModuleParams } from "../../../plugin/handlers/Module/convert"
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/kubernetes/local-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import { ContainerDeployAction, containerLocalModeSchema, ContainerLocalModeSpec } from "../container/config"
import { dedent, gardenAnnotationKey, splitLast } from "../../util/string"
import { cloneDeep, remove, set } from "lodash"
import cloneDeep from "fast-copy"
import { remove, set } from "lodash"
import { BaseResource, KubernetesResource, SyncableResource, SyncableRuntimeAction } from "./types"
import { PrimitiveMap } from "../../config/common"
import {
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/kubernetes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import tar from "tar"
import tmp from "tmp-promise"
import { cloneDeep, omit, pick, some } from "lodash"
import cloneDeep from "fast-copy"
import { omit, pick, some } from "lodash"
import { Log } from "../../logger/log-entry"
import { CoreV1Event } from "@kubernetes/client-node"
import {
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/kubernetes/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
syncTargetPathSchema,
} from "../container/moduleConfig"
import { dedent, gardenAnnotationKey } from "../../util/string"
import { cloneDeep, kebabCase, keyBy, omit, set } from "lodash"
import cloneDeep from "fast-copy"
import { kebabCase, keyBy, omit, set } from "lodash"
import {
getResourceContainer,
getResourceKey,
Expand Down
3 changes: 2 additions & 1 deletion core/src/resolve-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { cloneDeep, isArray, isString, keyBy } from "lodash"
import cloneDeep from "fast-copy"
import { isArray, isString, keyBy } from "lodash"
import { validateWithPath } from "./config/validation"
import {
getModuleTemplateReferences,
Expand Down
3 changes: 2 additions & 1 deletion core/src/template-string/template-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
GenericContext,
ScanContext,
} from "../config/template-contexts/base"
import { cloneDeep, difference, isNumber, isPlainObject, isString, uniq } from "lodash"
import cloneDeep from "fast-copy"
import { difference, isNumber, isPlainObject, isString, uniq } from "lodash"
import {
ActionReference,
arrayConcatKey,
Expand Down
3 changes: 2 additions & 1 deletion core/src/types/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { flatten, uniq, cloneDeep, some } from "lodash"
import cloneDeep from "fast-copy"
import { flatten, uniq, some } from "lodash"
import { getNames, findByName } from "../util/util"
import { ModuleConfig, moduleConfigSchema } from "../config/module"
import type { ModuleVersion } from "../vcs/vcs"
Expand Down
3 changes: 2 additions & 1 deletion core/src/util/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { GlobalOptions, globalOptions, ParameterValues } from "../cli/params"
import { cloneDeep, isEqual, keyBy, set, mapValues } from "lodash"
import cloneDeep from "fast-copy"
import { isEqual, keyBy, set, mapValues } from "lodash"
import { Garden, GardenOpts, GardenParams, GetConfigGraphParams, resolveGardenParams } from "../garden"
import { DeepPrimitiveMap, StringMap } from "../config/common"
import { ModuleConfig } from "../config/module"
Expand Down
3 changes: 2 additions & 1 deletion core/test/helpers/test-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { cloneDeep, get, isString, merge } from "lodash"
import cloneDeep from "fast-copy"
import { get, isString, merge } from "lodash"

import { convertExecModule } from "../../src/plugins/exec/convert"
import { createSchema, joi, joiArray } from "../../src/config/common"
Expand Down
3 changes: 2 additions & 1 deletion core/test/integ/src/plugins/container/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { expectError, getDataDir, makeTestGarden, TestGarden } from "../../../..
import { ActionLog, createActionLog } from "../../../../../src/logger/log-entry"
import { expect } from "chai"
import { ContainerBuildAction, ContainerBuildActionSpec } from "../../../../../src/plugins/container/moduleConfig"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import { publishContainerBuild } from "../../../../../src/plugins/container/publish"
import { Executed } from "../../../../../src/actions/types"
import { BuildActionConfig } from "../../../../../src/actions/build"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
import { KubernetesPluginContext, KubernetesProvider } from "../../../../../../src/plugins/kubernetes/config"
import { V1ConfigMap, V1Secret } from "@kubernetes/client-node"
import { KubernetesResource, KubernetesWorkload } from "../../../../../../src/plugins/kubernetes/types"
import { cloneDeep, keyBy } from "lodash"
import cloneDeep from "fast-copy"
import { keyBy } from "lodash"
import { getContainerTestGarden } from "./container"
import { DeployTask } from "../../../../../../src/tasks/deploy"
import { TestGarden, expectError, findNamespaceStatusEvent, grouped } from "../../../../../helpers"
Expand Down
3 changes: 2 additions & 1 deletion core/test/integ/src/plugins/kubernetes/helm/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import { resolve } from "path"
import { expect } from "chai"
import { cloneDeep, omit } from "lodash"
import cloneDeep from "fast-copy"
import { omit } from "lodash"

import { expectError, getDataDir, makeTestGarden, TestGarden, withDefaultGlobalOpts } from "../../../../../helpers"
import { PluginContext } from "../../../../../../src/plugin-context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { expect } from "chai"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import { ConfigGraph } from "../../../../../../src/graph/config-graph"
import { PluginContext } from "../../../../../../src/plugin-context"
import { readManifests } from "../../../../../../src/plugins/kubernetes/kubernetes-type/common"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { expect } from "chai"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import { TestGarden, getDataDir, makeTestGarden } from "../../../../../helpers"
import { ModuleConfig } from "../../../../../../src/config/module"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import { expect } from "chai"
import execa from "execa"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import tmp from "tmp-promise"

import { TestGarden } from "../../../../../helpers"
Expand Down
3 changes: 2 additions & 1 deletion core/test/unit/src/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { expect } from "chai"
import { PublishCommand } from "../../../../src/commands/publish"
import { withDefaultGlobalOpts, makeTestGarden, getAllTaskResults, getDataDir } from "../../../helpers"
import { taskResultOutputs } from "../../../helpers"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import { PublishActionResult, PublishBuildAction } from "../../../../src/plugin/handlers/Build/publish"
import { createGardenPlugin, GardenPluginSpec } from "../../../../src/plugin/plugin"
import { ConvertModuleParams } from "../../../../src/plugin/handlers/Module/convert"
Expand Down
3 changes: 2 additions & 1 deletion core/test/unit/src/config/render-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
import { resolve } from "path"
import { joi } from "../../../../src/config/common"
import { pathExists, remove } from "fs-extra"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import { configTemplateKind, renderTemplateKind } from "../../../../src/config/base"
import { RenderTemplateConfig, renderConfigTemplate } from "../../../../src/config/render-template"
import { Log } from "../../../../src/logger/log-entry"
Expand Down
3 changes: 2 additions & 1 deletion core/test/unit/src/plugins/container/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import { expect } from "chai"
import { join } from "path"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import td from "testdouble"
import tmp from "tmp-promise"
import { writeFile, mkdir } from "fs-extra"
Expand Down
3 changes: 2 additions & 1 deletion core/test/unit/src/router/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { expect } from "chai"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import { ResolvedBuildAction } from "../../../../src/actions/build"
import { joi } from "../../../../src/config/common"
import { resolveAction } from "../../../../src/graph/actions"
Expand Down
3 changes: 2 additions & 1 deletion core/test/unit/src/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { expect } from "chai"
import { getDataDir, makeTestGarden, makeTestGardenA } from "../../../helpers"
import { TestConfig } from "../../../../src/config/test"
import { testFromConfig } from "../../../../src/types/test"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import { DEFAULT_TEST_TIMEOUT_SEC } from "../../../../src/constants"

describe("testFromConfig", () => {
Expand Down
3 changes: 2 additions & 1 deletion core/test/unit/src/vcs/vcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
} from "../../../../src/vcs/vcs"
import { makeTestGardenA, makeTestGarden, getDataDir, TestGarden, defaultModuleConfig } from "../../../helpers"
import { expect } from "chai"
import { cloneDeep } from "lodash"
import cloneDeep from "fast-copy"

import { ModuleConfig } from "../../../../src/config/module"
import { GitHandler } from "../../../../src/vcs/git"
import { resolve, join } from "path"
Expand Down
3 changes: 2 additions & 1 deletion plugins/jib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import { joi } from "@garden-io/core/build/src/config/common"
import { baseBuildSpecSchema } from "@garden-io/core/build/src/config/module"
import { ConfigureModuleParams } from "@garden-io/core/build/src/plugin/handlers/Module/configure"
import { containerHelpers } from "@garden-io/core/build/src/plugins/container/helpers"
import { cloneDeep, pick } from "lodash"
import cloneDeep from "fast-copy"
import { pick } from "lodash"
import { LogLevel } from "@garden-io/core/build/src/logger/logger"
import { detectProjectType, getBuildFlags, JibBuildActionSpec, JibBuildConfig, JibContainerModule } from "./util"
import { ConvertModuleParams, ConvertModuleResult } from "@garden-io/core/build/src/plugin/handlers/Module/convert"
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf00e65

Please sign in to comment.