pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.32k stars 636 forks source link

Unexpectedly high pantsd memory usage with Go #19053

Closed jyggen closed 1 year ago

jyggen commented 1 year ago

We have a relatively small amount of Go code in our monorepository (49 files and 8041 lines according to pants count-loc, compared to 879 files and 101251 lines Python), and yet when enabling the Go backend we need to bump pantsd_max_memory_usage from the default value up to at least 8GiB in order to make pantsd not restart on every Pants execution (though it still restarts frequently enough for our Python developers to simply disable the Go backend locally due to the performance degradation it causes).

Here's the memory summary after running pants --stats-memory-summary fix lint check test golang/:: on 2.16.0rc2:

12:34:16.78 [INFO] Memory summary (total size in bytes, count, name):
  48            1               abc.EnvironmentAware
  48            1               abc.EnvironmentAware
  48            1               pants.backend.codegen.protobuf.go.rules.ProtobufGoModuleImportPathsMappingsHook
  48            1               pants.backend.codegen.protobuf.go.rules._SetupGoProtocPlugin
  48            1               pants.backend.codegen.protobuf.lint.buf.subsystem.BufSubsystem
  48            1               pants.backend.codegen.protobuf.protobuf_dependency_inference.ProtobufMapping
  48            1               pants.backend.codegen.protobuf.protoc.Protoc
  48            1               pants.backend.codegen.protobuf.python.python_protobuf_module_mapper.PythonProtobufMappingMarker
  48            1               pants.backend.codegen.protobuf.python.python_protobuf_subsystem.PythonProtobufSubsystem
  48            1               pants.backend.docker.lint.hadolint.subsystem.Hadolint
  48            1               pants.backend.docker.subsystems.dockerfile_parser.DockerfileParser
  48            1               pants.backend.docker.subsystems.dockerfile_parser.ParserSetup
  48            1               pants.backend.go.dependency_inference.AllGoModuleImportPathsMappings
  48            1               pants.backend.go.dependency_inference.GoModuleImportPathsMapping
  48            1               pants.backend.go.goals.check.GoCheckRequest
  48            1               pants.backend.go.lint.gofmt.subsystem.GofmtSubsystem
  48            1               pants.backend.go.subsystems.golang.GolangSubsystem
  48            1               pants.backend.go.subsystems.golang.GolangSubsystem.EnvironmentAware
  48            1               pants.backend.go.subsystems.gotest.GoTestSubsystem
  48            1               pants.backend.go.target_type_rules.FirstPartyGoModuleImportPathsMappingsHook
  48            1               pants.backend.go.target_type_rules.GenerateTargetsFromGoModRequest
  48            1               pants.backend.go.target_type_rules.GoImportPathMappingRequest
  48            1               pants.backend.go.util_rules.build_pkg.SetupAsmCheckBinary
  48            1               pants.backend.go.util_rules.build_pkg_target._ResolveStdlibEmbedConfigRequest
  48            1               pants.backend.go.util_rules.build_pkg_target._ResolveStdlibEmbedConfigResult
  48            1               pants.backend.go.util_rules.cgo.CGoCompilerWrapperScript
  48            1               pants.backend.go.util_rules.cgo.CGoCompilerWrapperScriptRequest
  48            1               pants.backend.go.util_rules.cgo_binaries.CGoBinaryPathRequest
  48            1               pants.backend.go.util_rules.go_bootstrap.GoBootstrap
  48            1               pants.backend.go.util_rules.goroot.GoRoot
  48            1               pants.backend.go.util_rules.link.LinkerSetup
  48            1               pants.backend.go.util_rules.pkg_analyzer.PackageAnalyzerSetup
  48            1               pants.backend.go.util_rules.sdk.GoSdkRunSetup
  48            1               pants.backend.go.util_rules.third_party_pkg.AllThirdPartyPackages
  48            1               pants.backend.go.util_rules.third_party_pkg.AllThirdPartyPackagesRequest
  48            1               pants.backend.go.util_rules.third_party_pkg.ModuleDescriptors
  48            1               pants.backend.go.util_rules.third_party_pkg.ModuleDescriptorsRequest
  48            1               pants.backend.project_info.filter_targets.FilterSubsystem
  48            1               pants.backend.project_info.regex_lint.RegexLintSubsystem
  48            1               pants.backend.python.dependency_inference.module_mapper.AllPythonTargets
  48            1               pants.backend.python.dependency_inference.module_mapper.FirstPartyPythonModuleMapping
  48            1               pants.backend.python.dependency_inference.module_mapper.FirstPartyPythonTargetsMappingMarker
  48            1               pants.backend.python.dependency_inference.module_mapper.ThirdPartyPythonModuleMapping
  48            1               pants.backend.python.dependency_inference.parse_python_dependencies.GeneralPythonDependencyVisitorRequest
  48            1               pants.backend.python.dependency_inference.parse_python_dependencies.ParserScript
  48            1               pants.backend.python.dependency_inference.parse_python_dependencies.PythonDependencyVisitor
  48            1               pants.backend.python.dependency_inference.subsystem.PythonInferSubsystem
  48            1               pants.backend.python.goals.lockfile.PythonSyntheticLockfileTargetsRequest
  48            1               pants.backend.python.lint.add_trailing_comma.subsystem.AddTrailingComma
  48            1               pants.backend.python.lint.autoflake.subsystem.Autoflake
  48            1               pants.backend.python.lint.bandit.subsystem.Bandit
  48            1               pants.backend.python.lint.black.subsystem.Black
  48            1               pants.backend.python.lint.docformatter.subsystem.Docformatter
  48            1               pants.backend.python.lint.flake8.subsystem.Flake8
  48            1               pants.backend.python.lint.flake8.subsystem.Flake8FirstPartyPlugins
  48            1               pants.backend.python.lint.isort.subsystem.Isort
  48            1               pants.backend.python.macros.python_requirements.GenerateFromPythonRequirementsRequest
  48            1               pants.backend.python.subsystems.python_native_code.PythonNativeCodeSubsystem
  48            1               pants.backend.python.subsystems.python_native_code.PythonNativeCodeSubsystem.EnvironmentAware
  48            1               pants.backend.python.subsystems.repos.PythonRepos
  48            1               pants.backend.python.subsystems.setup.PythonSetup
  48            1               pants.backend.python.target_types_rules.PythonResolveFieldDefaultFactoryRequest
  48            1               pants.backend.python.util_rules.interpreter_constraints.InterpreterConstraints
  48            1               pants.backend.python.util_rules.pex_cli.PexCli
  48            1               pants.backend.python.util_rules.pex_cli.PexPEX
  48            1               pants.backend.python.util_rules.pex_environment.PexEnvironment
  48            1               pants.backend.python.util_rules.pex_environment.PexSubsystem
  48            1               pants.backend.python.util_rules.pex_environment.PexSubsystem.EnvironmentAware
  48            1               pants.backend.python.util_rules.pex_environment.PythonExecutable
  48            1               pants.backend.python.util_rules.pex_requirements.Lockfile
  48            1               pants.backend.python.util_rules.pex_requirements.Resolve
  48            1               pants.backend.python.util_rules.python_sources.PythonSourceFiles
  48            1               pants.backend.python.util_rules.python_sources.StrippedPythonSourceFiles
  48            1               pants.backend.shell.lint.shellcheck.subsystem.Shellcheck
  48            1               pants.backend.shell.lint.shfmt.subsystem.Shfmt
  48            1               pants.backend.shell.subsystems.shell_test_subsys.ShellTestSubsystem
  48            1               pants.backend.shell.subsystems.shunit2.Shunit2
  48            1               pants.backend.visibility.rules.BuildFileVisibilityImplementationRequest
  48            1               pants.base.build_root.BuildRoot
  48            1               pants.build_graph.build_configuration.BuildConfiguration
  48            1               pants.core.goals.check.Check
  48            1               pants.core.goals.check.CheckResults
  48            1               pants.core.goals.check.CheckSubsystem
  48            1               pants.core.goals.fix.Fix
  48            1               pants.core.goals.fix.FixSubsystem
  48            1               pants.core.goals.lint.AddTrailingCommaRequest.PartitionRequest
  48            1               pants.core.goals.lint.AutoflakeRequest.PartitionRequest
  48            1               pants.core.goals.lint.BanditRequest.PartitionRequest
  48            1               pants.core.goals.lint.BlackRequest.PartitionRequest
  48            1               pants.core.goals.lint.BlackRequest.PartitionRequest
  48            1               pants.core.goals.lint.BufFormatRequest.PartitionRequest
  48            1               pants.core.goals.lint.BufLintRequest.PartitionRequest
  48            1               pants.core.goals.lint.DocformatterRequest.PartitionRequest
  48            1               pants.core.goals.lint.Flake8Request.PartitionRequest
  48            1               pants.core.goals.lint.GofmtRequest.PartitionRequest
  48            1               pants.core.goals.lint.HadolintRequest.Batch
  48            1               pants.core.goals.lint.HadolintRequest.PartitionRequest
  48            1               pants.core.goals.lint.IsortRequest.PartitionRequest
  48            1               pants.core.goals.lint.Lint
  48            1               pants.core.goals.lint.LintSubsystem
  48            1               pants.core.goals.lint.RegexLintRequest.PartitionRequest
  48            1               pants.core.goals.lint.ShellcheckRequest.PartitionRequest
  48            1               pants.core.goals.lint.ShfmtRequest.PartitionRequest
  48            1               pants.core.goals.test.GoTestRequest.PartitionRequest
  48            1               pants.core.goals.test.PyTestRequest.PartitionRequest
  48            1               pants.core.goals.test.ShellTestRequest.PartitionRequest
  48            1               pants.core.goals.test.Shunit2TestRequest.PartitionRequest
  48            1               pants.core.goals.test.Test
  48            1               pants.core.goals.test.TestExtraEnv
  48            1               pants.core.goals.test.TestSubsystem
  48            1               pants.core.subsystems.debug_adapter.DebugAdapterSubsystem
  48            1               pants.core.subsystems.python_bootstrap.PythonBootstrap
  48            1               pants.core.subsystems.python_bootstrap.PythonBootstrapSubsystem
  48            1               pants.core.subsystems.python_bootstrap.PythonBootstrapSubsystem.EnvironmentAware
  48            1               pants.core.subsystems.python_bootstrap._ExpandInterpreterSearchPathsRequest
  48            1               pants.core.subsystems.python_bootstrap._PyEnvPathsRequest
  48            1               pants.core.util_rules.adhoc_binaries.PythonBuildStandaloneBinary
  48            1               pants.core.util_rules.distdir.DistDir
  48            1               pants.core.util_rules.environments.AllEnvironmentTargets
  48            1               pants.core.util_rules.environments.DockerPlatformFieldDefaultFactoryRequest
  48            1               pants.core.util_rules.environments.EnvironmentsSubsystem
  48            1               pants.core.util_rules.environments.SingleEnvironmentNameRequest
  48            1               pants.core.util_rules.subprocess_environment.SubprocessEnvironment
  48            1               pants.core.util_rules.subprocess_environment.SubprocessEnvironmentVars
  48            1               pants.core.util_rules.system_binaries.BinaryPath
  48            1               pants.core.util_rules.system_binaries.UnzipBinaryRequest
  48            1               pants.engine.addresses.UnparsedAddressInputs
  48            1               pants.engine.environment.ChosenLocalEnvironmentName
  48            1               pants.engine.fs.SpecsPaths
  48            1               pants.engine.internals.build_files.BuildFileOptions
  48            1               pants.engine.internals.dep_rules.BuildFileDependencyRulesImplementation
  48            1               pants.engine.internals.dep_rules.MaybeBuildFileDependencyRulesImplementation
  48            1               pants.engine.internals.graph.SubprojectRoots
  48            1               pants.engine.internals.mapper.SpecsFilter
  48            1               pants.engine.internals.options_parsing._Options
  48            1               pants.engine.internals.parser.BuildFilePreludeSymbols
  48            1               pants.engine.internals.parser.Parser
  48            1               pants.engine.internals.synthetic_targets.AllSyntheticAddressMaps
  48            1               pants.engine.platform.Platform
  48            1               pants.engine.target.FieldDefaults
  48            1               pants.engine.target.FieldSetsPerTarget
  48            1               pants.engine.target.FieldSetsPerTargetRequest
  48            1               pants.engine.target.RegisteredTargetTypes
  48            1               pants.engine.target.TargetRootsToFieldSets
  48            1               pants.engine.target.TargetRootsToFieldSetsRequest
  48            1               pants.engine.target.TargetTypesToGenerateTargetsRequests
  48            1               pants.engine.unions.UnionMembership
  48            1               pants.goal.anonymous_telemetry.AnonymousTelemetry
  48            1               pants.goal.anonymous_telemetry.AnonymousTelemetryCallbackFactoryRequest
  48            1               pants.goal.stats_aggregator.StatsAggregatorCallbackFactoryRequest
  48            1               pants.goal.stats_aggregator.StatsAggregatorSubsystem
  48            1               pants.init.bootstrap_scheduler.BootstrapStatus
  48            1               pants.option.global_options.GlobalOptions
  48            1               pants.option.global_options.KeepSandboxes
  48            1               pants.option.global_options.NamedCachesDirOption
  48            1               pants.option.global_options.UnmatchedBuildFileGlobs
  48            1               pants.source.source_root.SourceRootConfig
  48            2               pants.backend.python.util_rules.python_sources.PythonSourceFilesRequest
  48            2               pants.core.util_rules.system_binaries.UnzipBinary
  48            4               pants.engine.console.Console
  48            4               pants.engine.fs.Workspace
  48            11310           pants.engine.environment.EnvironmentName
  56            1               pants.backend.go.util_rules.go_mod.AllGoModTargets
  64            1               pants.engine.streaming_workunit_handler.WorkunitsCallbackFactories
  80            1               (native) run_id
  80            1               (native) session_values
  88            1               builtins.ProcessExecutionEnvironment
  96            2               pants.backend.go.dependency_inference.GoModuleImportPathsMappings
  96            2               pants.backend.go.util_rules.build_pkg.CheckForGolangAssemblyRequest
  96            2               pants.backend.go.util_rules.build_pkg.CheckForGolangAssemblyResult
  96            2               pants.backend.go.util_rules.go_mod.GoModInfo
  96            2               pants.backend.go.util_rules.go_mod.GoModInfoRequest
  96            2               pants.backend.go.util_rules.implicit_linker_deps.SdkImplicitLinkerDependenciesHook
  96            2               pants.backend.go.util_rules.import_analysis.GoStdLibPackages
  96            2               pants.backend.go.util_rules.import_analysis.GoStdLibPackagesRequest
  96            2               pants.backend.go.util_rules.link_defs.ImplicitLinkerDependencies
  96            2               pants.backend.python.dependency_inference.module_mapper.FirstPartyPythonMappingImpl
  96            2               pants.backend.python.util_rules.pex.BuildPexResult
  96            2               pants.backend.python.util_rules.pex.VenvPex
  96            2               pants.backend.python.util_rules.pex.VenvPexRequest
  96            2               pants.backend.python.util_rules.pex_requirements.LoadedLockfile
  96            2               pants.backend.python.util_rules.pex_requirements.LoadedLockfileRequest
  96            2               pants.backend.python.util_rules.pex_requirements.ResolvePexConfig
  96            2               pants.backend.python.util_rules.pex_requirements.ResolvePexConfigRequest
  96            2               pants.core.goals.fix.BlackRequest.Batch
  96            2               pants.core.subsystems.python_bootstrap._SearchPaths
  96            2               pants.core.util_rules.config_files.ConfigFiles
  96            2               pants.core.util_rules.config_files.ConfigFilesRequest
  96            2               pants.core.util_rules.environments.EnvironmentNameRequest
  96            2               pants.core.util_rules.environments.EnvironmentTarget
  96            2               pants.core.util_rules.system_binaries.BashBinaryRequest
  96            2               pants.engine.internals.graph.Owners
  96            2               pants.engine.internals.graph.OwnersRequest
  96            2               pants.engine.streaming_workunit_handler.WorkunitsCallbackFactory
  96            2               pants.engine.target.AllTargetsRequest
  96            2               pants.engine.target.FieldDefaultFactoryResult
  96            3               pants.core.util_rules.system_binaries.BashBinary
  96            10              pants.base.specs.Specs
  96            160             pants.source.source_root.SourceRoot
  96            224             pants.source.source_root.OptionalSourceRoot
  144           3               pants.backend.go.go_sources.load_go_binary.LoadedGoBinary
  144           3               pants.backend.go.go_sources.load_go_binary.LoadedGoBinaryRequest
  144           3               pants.backend.go.util_rules.cgo.CGoCompileRequest
  144           3               pants.backend.go.util_rules.cgo.CGoCompileResult
  144           3               pants.backend.go.util_rules.cgo.CheckCompilerSupportsFlagRequest
  144           3               pants.backend.go.util_rules.cgo.CheckCompilerSupportsOptionResult
  144           3               pants.backend.go.util_rules.cgo.SetupCompilerCmdRequest
  144           3               pants.backend.go.util_rules.cgo.SetupCompilerCmdResult
  144           3               pants.backend.go.util_rules.sdk.GoSdkToolIDRequest
  144           3               pants.backend.go.util_rules.sdk.GoSdkToolIDResult
  144           3               pants.base.specs.RawSpecsWithOnlyFileOwners
  144           3               pants.core.goals.fix.FixResult
  144           3               pants.core.goals.fix._FixBatchResult
  144           3               pants.core.util_rules.archive.ExtractedArchive
  144           3               pants.core.util_rules.archive.MaybeExtractArchiveRequest
  144           3               pants.core.util_rules.external_tool.DownloadedExternalTool
  144           3               pants.core.util_rules.external_tool.ExternalToolRequest
  144           3               pants.engine.fs.DownloadFile
  144           4               pants.engine.env_vars.CompleteEnvironmentVars
  144           9               pants.backend.python.util_rules.pex_cli.PexCliProcess
  168           3               pants.core.goals.fix._FixBatchRequest
  192           4               pants.backend.codegen.protobuf.go.rules._SetupGoProtobufPackageBuildRequest
  192           4               pants.backend.python.dependency_inference.parse_python_dependencies.ParsePythonDependenciesRequest
  192           4               pants.backend.python.dependency_inference.parse_python_dependencies.ParsedPythonDependencies
  192           4               pants.backend.python.dependency_inference.rules.InferInitDependencies
  192           4               pants.backend.python.dependency_inference.rules.InferPythonImportDependencies
  192           4               pants.backend.python.dependency_inference.rules.ResolvedParsedPythonDependencies
  192           4               pants.backend.python.dependency_inference.rules.ResolvedParsedPythonDependenciesRequest
  192           4               pants.core.goals.fix.GofmtRequest.Batch
  192           4               pants.core.goals.lint.LintResult
  192           6               pants.backend.python.util_rules.pex.PexRequest
  209           1               (native) construct_scope_
  209           1               (native) construct_scope_add_trailing_comma
  209           1               (native) construct_scope_anonymous_telemetry
  209           1               (native) construct_scope_autoflake
  209           1               (native) construct_scope_bandit
  209           1               (native) construct_scope_black
  209           1               (native) construct_scope_buf
  209           1               (native) construct_scope_check
  209           1               (native) construct_scope_debug_adapter
  209           1               (native) construct_scope_docformatter
  209           1               (native) construct_scope_dockerfile_parser
  209           1               (native) construct_scope_environments_preview
  209           1               (native) construct_scope_filter
  209           1               (native) construct_scope_fix
  209           1               (native) construct_scope_flake8
  209           1               (native) construct_scope_go_test
  209           1               (native) construct_scope_gofmt
  209           1               (native) construct_scope_golang
  209           1               (native) construct_scope_hadolint
  209           1               (native) construct_scope_isort
  209           1               (native) construct_scope_lint
  209           1               (native) construct_scope_pex
  209           1               (native) construct_scope_pex_cli
  209           1               (native) construct_scope_protoc
  209           1               (native) construct_scope_python
  209           1               (native) construct_scope_python_bootstrap
  209           1               (native) construct_scope_python_infer
  209           1               (native) construct_scope_python_native_code
  209           1               (native) construct_scope_python_protobuf
  209           1               (native) construct_scope_python_repos
  209           1               (native) construct_scope_regex_lint
  209           1               (native) construct_scope_shell_test
  209           1               (native) construct_scope_shellcheck
  209           1               (native) construct_scope_shfmt
  209           1               (native) construct_scope_shunit2
  209           1               (native) construct_scope_source
  209           1               (native) construct_scope_stats
  209           1               (native) construct_scope_subprocess_environment
  209           1               (native) construct_scope_test
  209           1               (native) pants.backend.codegen.protobuf.protobuf_dependency_inference.map_protobuf_files
  209           1               (native) pants.backend.codegen.protobuf.target_types.find_all_protobuf_targets
  209           1               (native) pants.backend.go.util_rules.go_mod.find_all_go_mod_targets
  209           1               (native) pants.backend.python.dependency_inference.module_mapper.find_all_python_projects
  209           1               (native) pants.backend.python.dependency_inference.module_mapper.map_third_party_modules_to_addresses
  209           1               (native) pants.core.util_rules.distdir.get_distdir
  209           1               (native) pants.core.util_rules.environments.determine_all_environments
  209           1               (native) pants.core.util_rules.environments.determine_local_environment
  209           1               (native) pants.engine.internals.build_files.evaluate_preludes
  209           1               (native) pants.engine.internals.build_files.extract_build_file_options
  209           1               (native) pants.engine.internals.dep_rules.get_build_file_dependency_rules_implementation
  209           1               (native) pants.engine.internals.graph.extract_subproject_roots
  209           1               (native) pants.engine.internals.graph.extract_unmatched_build_file_globs
  209           1               (native) pants.engine.internals.graph.field_defaults
  209           1               (native) pants.engine.internals.graph.find_all_targets_singleton
  209           1               (native) pants.engine.internals.graph.find_all_unexpanded_targets_singleton
  209           1               (native) pants.engine.internals.graph.target_types_to_generate_targets_requests
  209           1               (native) pants.engine.internals.options_parsing.extract_keep_sandboxes
  209           1               (native) pants.engine.internals.options_parsing.extract_named_caches_dir_option
  209           1               (native) pants.engine.internals.options_parsing.parse_options
  209           1               (native) pants.engine.internals.specs_rules.setup_specs_filter
  209           1               (native) pants.engine.internals.synthetic_targets.all_synthetic_targets
  209           1               (native) pants.init.engine_initializer.EngineInitializer.setup_graph_extended.bootstrap_status
  209           1               (native) pants.init.engine_initializer.EngineInitializer.setup_graph_extended.build_configuration_singleton
  209           1               (native) pants.init.engine_initializer.EngineInitializer.setup_graph_extended.build_root_singleton
  209           1               (native) pants.init.engine_initializer.EngineInitializer.setup_graph_extended.parser_singleton
  209           1               (native) pants.init.engine_initializer.EngineInitializer.setup_graph_extended.registered_target_types_singleton
  209           1               (native) pants.init.engine_initializer.EngineInitializer.setup_graph_extended.union_membership_singleton
  225           1               (native) construct_env_aware_scope_golang
  225           1               (native) construct_env_aware_scope_pex
  225           1               (native) construct_env_aware_scope_python_bootstrap
  225           1               (native) construct_env_aware_scope_python_native_code
  225           1               (native) construct_env_aware_scope_subprocess_environment
  225           1               (native) construct_env_aware_scope_test
  225           1               (native) pants.backend.build_files.utils._get_build_file_partitioner_rules.partition_build_files
  225           1               (native) pants.backend.codegen.protobuf.go.rules.setup_go_protoc_plugin
  225           1               (native) pants.backend.codegen.protobuf.lint.buf.format_rules.partition_buf
  225           1               (native) pants.backend.codegen.protobuf.lint.buf.lint_rules.partition_buf
  225           1               (native) pants.backend.codegen.protobuf.python.python_protobuf_module_mapper.map_protobuf_to_python_modules
  225           1               (native) pants.backend.docker.subsystems.dockerfile_parser.setup_parser
  225           1               (native) pants.backend.go.target_type_rules.go_merge_import_paths_analysis
  225           1               (native) pants.backend.go.util_rules.build_pkg.setup_golang_asm_check_binary
  225           1               (native) pants.backend.go.util_rules.cgo.make_cgo_compile_wrapper_script
  225           1               (native) pants.backend.go.util_rules.go_bootstrap.resolve_go_bootstrap
  225           1               (native) pants.backend.go.util_rules.goroot.setup_goroot
  225           1               (native) pants.backend.go.util_rules.link.setup_go_linker
  225           1               (native) pants.backend.go.util_rules.pkg_analyzer.setup_go_package_analyzer
  225           1               (native) pants.backend.go.util_rules.sdk.go_sdk_invoke_setup
  225           1               (native) pants.backend.project_info.regex_lint.partition_inputs
  225           1               (native) pants.backend.python.dependency_inference.module_mapper.map_first_party_python_targets_to_modules
  225           1               (native) pants.backend.python.dependency_inference.module_mapper.merge_first_party_module_mappings
  225           1               (native) pants.backend.python.dependency_inference.parse_python_dependencies.general_parser_script
  225           1               (native) pants.backend.python.dependency_inference.parse_python_dependencies.get_parser_script
  225           1               (native) pants.backend.python.goals.lockfile.python_lockfile_synthetic_targets
  225           1               (native) pants.backend.python.goals.pytest_runner.partition_python_tests
  225           1               (native) pants.backend.python.lint.bandit.rules.partition_bandit
  225           1               (native) pants.backend.python.lint.black.rules.partition_black
  225           1               (native) pants.backend.python.lint.flake8.subsystem.flake8_first_party_plugins
  225           1               (native) pants.backend.python.macros.python_requirements.generate_from_python_requirement
  225           1               (native) pants.backend.python.target_types_rules.python_resolve_field_default_factory
  225           1               (native) pants.backend.python.util_rules.pex_cli.download_pex_pex
  225           1               (native) pants.backend.python.util_rules.pex_environment.find_pex_python
  225           1               (native) pants.backend.python.util_rules.pex_requirements.get_lockfile_for_resolve
  225           1               (native) pants.backend.visibility.rules.build_file_visibility_implementation
  225           1               (native) pants.core.goals.test.get_filtered_environment
  225           1               (native) pants.core.subsystems.python_bootstrap.python_bootstrap
  225           1               (native) pants.core.util_rules.adhoc_binaries.get_python_for_scripts
  225           1               (native) pants.core.util_rules.environments.docker_platform_field_default_factory
  225           1               (native) pants.core.util_rules.environments.extract_process_config_from_environment
  225           1               (native) pants.core.util_rules.environments.resolve_environment_name
  225           1               (native) pants.core.util_rules.environments.resolve_single_environment_name
  225           1               (native) pants.core.util_rules.subprocess_environment.get_subprocess_environment
  225           1               (native) pants.core.util_rules.system_binaries.get_bash
  225           1               (native) pants.engine.internals.graph.find_all_targets
  225           1               (native) pants.engine.internals.graph.find_all_unexpanded_targets
  225           1               (native) pants.engine.internals.graph.find_valid_field_sets
  225           1               (native) pants.engine.internals.graph.resolve_unparsed_address_inputs
  225           1               (native) pants.engine.internals.platform_rules.complete_environment_vars
  225           1               (native) pants.engine.internals.platform_rules.current_platform
  225           1               (native) pants.engine.internals.specs_rules.resolve_addresses_from_specs
  225           1               (native) pants.engine.internals.specs_rules.resolve_specs_paths
  225           1               (native) pants.engine.streaming_workunit_handler.construct_workunits_callback_factories
  225           1               (native) pants.goal.anonymous_telemetry.construct_callback
  225           1               (native) pants.goal.stats_aggregator.construct_callback
  240           5               pants.backend.go.util_rules.build_pkg.BuiltGoPackage
  240           5               pants.backend.go.util_rules.build_pkg.RenderEmbedConfigRequest
  240           5               pants.backend.go.util_rules.build_pkg.RenderedEmbedConfig
  240           5               pants.backend.python.util_rules.ancestor_files.AncestorFiles
  240           5               pants.backend.python.util_rules.ancestor_files.AncestorFilesRequest
  240           5               pants.core.util_rules.stripped_source_files.StrippedSourceFiles
  240           5               pants.core.util_rules.system_binaries.BinaryPathRequest
  240           5               pants.core.util_rules.system_binaries.BinaryPaths
  240           5               pants.engine.internals.graph._DependencyMapping
  240           5               pants.engine.internals.graph._DependencyMappingRequest
  240           5               pants.engine.target.TransitiveTargets
  240           5               pants.engine.target.TransitiveTargetsRequest
  240           14              builtins.Digest
  241           1               (native) pants.backend.build_files.fmt.black.register.black_fmt
  241           1               (native) pants.backend.codegen.protobuf.go.rules.map_import_paths_of_all_go_protobuf_targets
  241           1               (native) pants.backend.docker.lint.hadolint.rules.run_hadolint
  241           1               (native) pants.backend.go.goals.check.check_go
  241           1               (native) pants.backend.go.target_type_rules.generate_targets_from_go_mod
  241           1               (native) pants.backend.go.target_type_rules.go_map_import_paths_by_module
  241           1               (native) pants.backend.go.target_type_rules.map_import_paths_to_packages
  241           1               (native) pants.backend.go.util_rules.build_pkg_target.resolve_go_stdlib_embed_config
  241           1               (native) pants.backend.go.util_rules.cgo_binaries.find_cgo_binary_path
  241           1               (native) pants.backend.go.util_rules.third_party_pkg.analyze_module_dependencies
  241           1               (native) pants.backend.go.util_rules.third_party_pkg.download_and_analyze_third_party_packages
  241           1               (native) pants.backend.python.lint.flake8.rules.partition_flake8
  241           1               (native) pants.backend.python.util_rules.pex.find_interpreter
  241           1               (native) pants.backend.python.util_rules.python_sources.prepare_python_sources
  241           1               (native) pants.backend.python.util_rules.python_sources.strip_python_sources
  241           1               (native) pants.core.subsystems.python_bootstrap._expand_interpreter_search_paths
  241           1               (native) pants.core.subsystems.python_bootstrap._get_pyenv_paths
  241           1               (native) pants.core.util_rules.system_binaries.find_unzip
  241           1               (native) pants.engine.internals.specs_rules.find_valid_field_sets_for_target_roots
  257           1               (native) pants.core.goals.check.check
  257           1               (native) pants.core.goals.test.run_tests
  257           1               (native) pants.core.util_rules.system_binaries.find_unzip_wrapper
  273           1               (native) pants.core.goals.fix.fix
  273           1               (native) pants.core.goals.lint.lint
  288           6               pants.backend.docker.subsystems.dockerfile_parser.DockerfileInfo
  288           6               pants.backend.docker.subsystems.dockerfile_parser.DockerfileInfoRequest
  288           6               pants.backend.docker.util_rules.dockerfile.GenerateDockerfileRequest
  288           6               pants.engine.target.GeneratedSources
  288           18              pants.backend.docker.subsystems.dockerfile_parser.DockerfileParseRequest
  336           9               pants.backend.python.util_rules.pex.VenvPexProcess
  432           9               pants.backend.python.dependency_inference.module_mapper.PythonModuleOwners
  432           9               pants.backend.python.dependency_inference.module_mapper.PythonModuleOwnersRequest
  432           9               pants.engine.env_vars.EnvironmentVars
  432           9               pants.engine.env_vars.EnvironmentVarsRequest
  432           9               pants.source.source_root.OptionalSourceRootsResult
  432           9               pants.source.source_root.SourceRootsResult
  432           18              pants.source.source_root.SourceRootsRequest
  450           2               (native) pants.backend.python.util_rules.pex_requirements.determine_resolve_pex_config
  450           2               (native) pants.backend.python.util_rules.pex_requirements.load_lockfile
  450           2               (native) pants.core.util_rules.config_files.find_config_file
  450           2               (native) pants.core.util_rules.environments.get_target_for_environment_name
  450           2               (native) pants.core.util_rules.partitions._single_partition_field_set_rules.partitioner
  450           2               (native) pants.engine.internals.graph.find_owners
  472           1               pants.backend.codegen.protobuf.target_types.AllProtobufTargets
  480           3               (native) downloaded_file
  480           10              pants.backend.go.util_rules.link.LinkGoBinaryRequest
  480           10              pants.backend.go.util_rules.link.LinkedGoBinary
  482           2               (native) pants.backend.go.lint.gofmt.rules.gofmt_fmt
  482           2               (native) pants.backend.go.util_rules.build_pkg.check_for_golang_assembly
  482           2               (native) pants.backend.go.util_rules.go_mod.determine_go_mod_info
  482           2               (native) pants.backend.go.util_rules.implicit_linker_deps.provide_sdk_implicit_linker_dependencies
  482           2               (native) pants.backend.go.util_rules.import_analysis.analyze_go_stdlib_packages
  482           2               (native) pants.backend.python.util_rules.pex.build_pex
  482           2               (native) pants.backend.python.util_rules.pex.create_venv_pex
  482           2               (native) pants.backend.python.util_rules.pex.wrap_venv_prex_request
  498           2               (native) pants.core.util_rules.system_binaries.find_bash
  672           14              pants.backend.codegen.protobuf.go.rules.GoCodegenBuildProtobufRequest
  675           3               (native) pants.core.util_rules.archive.convert_digest_to_MaybeExtractArchiveRequest
  675           3               (native) pants.core.util_rules.partitions._partition_per_input_field_set_rules.partitioner
  675           3               (native) pants.engine.download_file.download_file
  675           3               (native) pants.engine.internals.specs_rules.addresses_from_raw_specs_with_only_file_owners
  675           3               (native) pants.engine.internals.specs_rules.filter_targets
  707           4               (native) read_link
  723           3               (native) pants.backend.go.go_sources.load_go_binary.setup_go_binary
  723           3               (native) pants.backend.go.util_rules.cgo.cgo_compile_request
  723           3               (native) pants.backend.go.util_rules.cgo.check_compiler_supports_flag
  723           3               (native) pants.backend.go.util_rules.cgo.setup_compiler_cmd
  723           3               (native) pants.backend.go.util_rules.sdk.compute_go_tool_id
  723           3               (native) pants.backend.python.util_rules.pex_cli.setup_pex_cli_process
  723           3               (native) pants.core.goals.fix.convert_fix_result_to_lint_result
  723           3               (native) pants.core.goals.fix.fix_batch
  723           3               (native) pants.core.util_rules.archive.maybe_extract_archive
  723           3               (native) pants.core.util_rules.external_tool.download_external_tool
  768           16              pants.backend.codegen.protobuf.protobuf_dependency_inference.InferProtobufDependencies
  768           16              pants.backend.codegen.protobuf.python.python_protobuf_subsystem.InferPythonProtobufDependencies
  864           18              pants.backend.go.goals.test.FalliblePrepareGoTestBinaryResult
  864           18              pants.backend.go.goals.test.PrepareGoTestBinaryRequest
  864           18              pants.backend.go.target_type_rules.InferGoPackageDependenciesRequest
  864           18              pants.backend.go.util_rules.first_party_pkg.FallibleFirstPartyPkgAnalysis
  864           18              pants.backend.go.util_rules.first_party_pkg.FallibleFirstPartyPkgDigest
  864           18              pants.backend.go.util_rules.first_party_pkg.FirstPartyPkgAnalysisRequest
  864           18              pants.backend.go.util_rules.first_party_pkg.FirstPartyPkgDigestRequest
  864           18              pants.backend.go.util_rules.first_party_pkg.FirstPartyPkgImportPath
  864           18              pants.backend.go.util_rules.first_party_pkg.FirstPartyPkgImportPathRequest
  864           18              pants.backend.go.util_rules.go_mod.NearestAncestorGoModRequest
  864           18              pants.backend.go.util_rules.go_mod.NearestAncestorGoModResult
  864           18              pants.backend.go.util_rules.tests_analysis.GenerateTestMainRequest
  864           18              pants.backend.go.util_rules.tests_analysis.GeneratedTestMain
  864           18              pants.core.goals.test.GoTestRequest.Batch
  864           18              pants.core.goals.test.TestResult
  900           4               (native) pants.backend.python.dependency_inference.rules.infer_python_init_dependencies
  912           19              pants.backend.go.util_rules.build_opts.GoBuildOptions
  912           19              pants.backend.go.util_rules.build_opts.GoBuildOptionsFromTargetRequest
  960           20              pants.backend.python.target_types_rules.PythonValidateDependenciesRequest
  960           20              pants.engine.internals.synthetic_targets.SyntheticTargetsSpecPathsRequest
  960           24              pants.core.util_rules.source_files.SourceFilesRequest
  964           4               (native) pants.backend.codegen.protobuf.go.rules.setup_full_package_build_request
  964           4               (native) pants.backend.python.dependency_inference.parse_python_dependencies.parse_python_dependencies
  964           4               (native) pants.backend.python.dependency_inference.rules.infer_python_dependencies_via_source
  964           4               (native) pants.backend.python.dependency_inference.rules.resolve_parsed_dependencies
  968           20              pants.engine.internals.synthetic_targets.SyntheticTargetsSpecPaths
  1008          21              pants.core.util_rules.source_files.SourceFiles
  1056          43              pants.base.specs.RawSpecs
  1125          5               (native) pants.backend.go.util_rules.build_pkg.render_embed_config
  1125          5               (native) pants.backend.python.util_rules.ancestor_files.find_ancestor_files
  1125          5               (native) pants.engine.internals.graph.transitive_dependency_mapping
  1125          5               (native) pants.engine.internals.graph.transitive_targets
  1160          19              pants.core.util_rules.partitions.Partitions
  1189          5               (native) pants.core.util_rules.stripped_source_files.strip_source_roots
  1205          5               (native) pants.backend.go.util_rules.build_pkg.required_built_go_package
  1237          5               (native) pants.core.util_rules.system_binaries.find_binary
  1296          31              pants.base.specs.RawSpecsWithoutFileOwners
  1350          6               (native) pants.backend.docker.util_rules.dockerfile.hydrate_dockerfile
  1350          6               (native) pants.core.util_rules.partitions._single_partition_file_rules.partitioner
  1440          30              pants.backend.codegen.protobuf.target_types.GeneratorSettingsRequest
  1446          6               (native) pants.backend.docker.subsystems.dockerfile_parser.parse_dockerfile
  1446          6               (native) pants.backend.docker.subsystems.dockerfile_parser.setup_process_for_parse_dockerfile
  1488          31              pants.backend.go.util_rules.assembly.AssembleGoAssemblyFilesRequest
  1488          31              pants.backend.go.util_rules.assembly.FallibleAssembleGoAssemblyFilesResult
  1488          31              pants.backend.go.util_rules.assembly.FallibleGenerateAssemblySymabisResult
  1488          31              pants.backend.go.util_rules.assembly.GenerateAssemblySymabisRequest
  1687          7               (native) pants.backend.python.util_rules.pex.setup_venv_pex_process
  1712          7               (native) select
  1872          39              pants.option.scope.Scope
  1872          39              pants.option.scope.ScopedOptions
  2025          9               (native) pants.source.source_root.get_optional_source_roots
  2025          9               (native) pants.source.source_root.get_source_roots
  2169          9               (native) pants.backend.python.dependency_inference.module_mapper.map_module_to_address
  2169          9               (native) pants.engine.internals.platform_rules.environment_vars_subset
  2410          10              (native) pants.backend.go.util_rules.link.link_go_binary
  3360          70              pants.backend.go.go_sources.load_go_binary.NaiveBuildGoPackageRequestForStdlibPackageRequest
  3374          14              (native) pants.backend.codegen.protobuf.go.rules.setup_build_go_package_request_for_protobuf
  3600          16              (native) pants.backend.codegen.protobuf.python.python_protobuf_subsystem.infer_dependencies
  3856          16              (native) pants.backend.codegen.protobuf.protobuf_dependency_inference.infer_protobuf_dependencies
  4050          18              (native) pants.backend.go.util_rules.go_mod.find_nearest_ancestor_go_mod
  4338          18              (native) pants.backend.go.goals.test.prepare_go_test_binary
  4338          18              (native) pants.backend.go.goals.test.run_go_tests
  4338          18              (native) pants.backend.go.target_type_rules.infer_go_dependencies
  4338          18              (native) pants.backend.go.util_rules.first_party_pkg.analyze_first_party_package
  4338          18              (native) pants.backend.go.util_rules.first_party_pkg.compute_first_party_package_import_path
  4338          18              (native) pants.backend.go.util_rules.first_party_pkg.setup_first_party_pkg_digest
  4338          18              (native) pants.backend.go.util_rules.tests_analysis.generate_testmain
  4500          20              (native) pants.backend.python.target_types_rules.validate_python_dependencies
  4500          20              (native) pants.engine.internals.synthetic_targets.get_synthetic_targets_spec_paths
  4579          19              (native) pants.backend.go.util_rules.build_opts.go_extract_build_options_from_target
  4725          21              (native) pants.engine.internals.specs_rules.resolve_addresses_from_raw_specs
  4820          20              (native) pants.core.util_rules.source_files.determine_source_files
  5302          22              (native) pants.backend.go.util_rules.build_pkg_target.required_build_go_package_request
  5400          24              (native) pants.engine.internals.specs_rules.addresses_from_raw_specs_without_file_owners
  6750          30              (native) pants.backend.codegen.protobuf.target_types.generator_settings
  7471          31              (native) pants.backend.go.util_rules.assembly.assemble_go_assembly_files
  7471          31              (native) pants.backend.go.util_rules.assembly.generate_go_assembly_symabisfile
  7536          157             pants.engine.target.HydrateSourcesRequest
  7536          157             pants.engine.target.HydratedSources
  8592          184             pants.backend.go.util_rules.build_pkg_target.BuildGoPackageRequestForStdlibRequest
  8775          39              (native) pants.engine.internals.options_parsing.scope_options
  9792          204             pants.backend.python.target_types.PythonFilesGeneratorSettingsRequest
  10608         221             pants.backend.go.target_type_rules.InferGoThirdPartyPackageDependenciesRequest
  10608         221             pants.backend.go.util_rules.third_party_pkg.ThirdPartyPkgAnalysis
  10608         221             pants.backend.go.util_rules.third_party_pkg.ThirdPartyPkgAnalysisRequest
  11232         234             pants.engine.target.TargetFilesGeneratorSettings
  11280         384             pants.source.source_root.SourceRootRequest
  12048         251             pants.engine.internals.mapper.AddressFamily
  12624         263             pants.backend.visibility.rules.VisibilityValidateDependenciesRequest
  12624         263             pants.engine.target.DependenciesRuleApplication
  12624         263             pants.engine.target.DependenciesRuleApplicationRequest
  12672         264             pants.engine.target.ExplicitlyProvidedDependencies
  12672         1056            pants.engine.target.DependenciesRequest
  12960         280             pants.backend.go.util_rules.build_pkg_target.BuildGoPackageTargetRequest
  13392         279             pants.engine.target.InferredDependencies
  13584         283             pants.engine.target.ValidatedDependencies
  15696         327             pants.engine.internals.build_files.OptionalAddressFamily
  15696         327             pants.engine.internals.synthetic_targets.SyntheticAddressMapsRequest
  15760         328             pants.engine.internals.synthetic_targets.SyntheticAddressMaps
  16032         334             pants.backend.go.util_rules.third_party_pkg.AnalyzeThirdPartyModuleRequest
  16032         334             pants.backend.go.util_rules.third_party_pkg.AnalyzedThirdPartyModule
  16176         578             pants.engine.internals.build_files.AddressFamilyDir
  16656         347             pants.engine.internals.graph.GenerateFileTargets
  16752         349             pants.engine.target.GeneratedTargets
  16870         70              (native) pants.backend.go.go_sources.load_go_binary.naive_build_go_package_request_for_stdlib
  18864         393             pants.engine.target.SourcesPaths
  18864         393             pants.engine.target.SourcesPathsRequest
  19056         397             pants.backend.go.util_rules.import_config.ImportConfig
  19056         397             pants.backend.go.util_rules.import_config.ImportConfigRequest
  20544         456             pants.backend.go.util_rules.build_pkg.FallibleBuildGoPackageRequest
  21888         456             pants.build_graph.address.Address
  21888         456             pants.build_graph.address.MaybeAddress
  21888         912             pants.build_graph.address.AddressInput
  24384         508             pants.backend.go.util_rules.build_pkg.GoCompileActionIdRequest
  24384         508             pants.backend.go.util_rules.build_pkg.GoCompileActionIdResult
  24384         602             pants.backend.go.util_rules.build_pkg.BuildGoPackageRequest
  24432         509             pants.backend.go.util_rules.build_pkg.FallibleBuiltGoPackage
  26208         546             pants.engine.internals.parametrize._TargetParametrizationsRequest
  26208         546             pants.engine.internals.target_adaptor.TargetAdaptor
  26208         546             pants.engine.internals.target_adaptor.TargetAdaptorRequest
  30576         546             pants.engine.internals.parametrize._TargetParametrizations
  36000         160             (native) pants.source.source_root.get_source_root
  37837         157             (native) pants.engine.internals.graph.hydrate_sources
  38544         803             pants.engine.process.ProcessResult
  38544         803             pants.engine.process.ProductDescription
  42039         355             (native) digest_file
  42898         178             (native) pants.backend.go.util_rules.build_pkg_target.setup_build_go_package_target_request_for_stdlib
  43440         1693            pants.backend.go.util_rules.sdk.GoSdkProcess
  43632         909             pants.core.util_rules.stripped_source_files.StrippedFileName
  43632         909             pants.core.util_rules.stripped_source_files.StrippedFileNameRequest
  45900         204             (native) pants.backend.python.target_types_rules.python_files_generator_settings
  50400         224             (native) pants.source.source_root.get_optional_source_root
  53261         221             (native) pants.backend.go.target_type_rules.infer_go_third_party_package_dependencies
  53261         221             (native) pants.backend.go.util_rules.third_party_pkg.extract_package_info
  56475         251             (native) pants.engine.internals.build_files.ensure_address_family
  59175         263             (native) pants.backend.visibility.rules.visibility_validate_dependencies
  59175         263             (native) pants.engine.internals.build_files.get_dependencies_rule_application
  59400         264             (native) pants.engine.internals.graph.determine_explicitly_provided_dependencies
  59400         264             (native) pants.engine.internals.graph.resolve_dependencies
  60400         2               pants.engine.target.AllTargets
  60975         271             (native) pants.engine.internals.graph.resolve_targets
  62660         260             (native) pants.backend.go.util_rules.build_pkg_target.setup_build_go_package_target_request
  63072         1719            pants.engine.process.Process
  63192         2               pants.engine.target.AllUnexpandedTargets
  66150         294             (native) pants.engine.internals.graph.resolve_unexpanded_targets
  73575         327             (native) pants.engine.internals.build_files.parse_address_family
  73575         327             (native) pants.engine.internals.synthetic_targets.get_synthetic_address_maps
  80494         334             (native) pants.backend.go.util_rules.third_party_pkg.analyze_go_third_party_module
  83627         347             (native) pants.engine.internals.graph.generate_file_targets
  84064         3               pants.engine.target.FilteredTargets
  88425         393             (native) pants.engine.internals.graph.resolve_source_paths
  89325         397             (native) pants.backend.go.util_rules.import_config.generate_import_config
  102600                456             (native) pants.engine.internals.build_files.maybe_resolve_address
  102600                456             (native) pants.engine.internals.build_files.resolve_address
  122428                508             (native) pants.backend.go.util_rules.build_pkg.compute_compile_action_id
  122669                509             (native) pants.backend.go.util_rules.build_pkg.build_go_package
  122850                546             (native) pants.engine.internals.build_files.find_target_adaptor
  131586                546             (native) pants.engine.internals.graph.resolve_target_parametrizations
  166544                272             pants.engine.target.Targets
  187139                803             (native) pants.engine.process.get_multi_platform_request_description
  193523                803             (native) pants.engine.process.fallible_to_exec_result_or_raise
  204525                909             (native) pants.core.util_rules.stripped_source_files.strip_file_name
  218105                905             (native) pants.backend.go.util_rules.sdk.setup_go_sdk_process
  251381                424             (native) snapshot
  253488                5281            pants.backend.go.util_rules.go_mod.OwningGoMod
  253488                5281            pants.backend.go.util_rules.go_mod.OwningGoModRequest
  258864                5393            pants.backend.go.util_rules.third_party_pkg.AnalyzeThirdPartyPackageRequest
  258864                5393            pants.backend.go.util_rules.third_party_pkg.FallibleThirdPartyPkgAnalysis
  378864                7893            pants.engine.target.WrappedTarget
  378864                7893            pants.engine.target.WrappedTargetRequest
  921456                294             pants.engine.target.UnexpandedTargets
  1188225               5281            (native) pants.backend.go.util_rules.go_mod.find_owning_go_mod
  1299713               5393            (native) pants.backend.go.util_rules.third_party_pkg.analyze_go_third_party_package
  1775925               7893            (native) pants.engine.internals.graph.resolve_target
  1799480               321             pants.engine.addresses.Addresses
  9514217               1384            (native) process
  18527906              10365           (native) scandir
  24590773              449             (native) paths
stuhood commented 1 year ago

There is an additional repro on #19060.

jyggen commented 1 year ago

gist with debug logs for pants check. A lot of paths are redacted, so let me know if this complicates debugging and I'll look into anonymizing them somehow instead.

Edit: additional gist with --no-local-cache and --no-pantsd

tdyas commented 1 year ago

I looked at the additional gist and the relevant Process invocations are in that log. I don't see any processes invocations with a long list of arguments though because at least for the compile steps those processes are passing the source filenames via a file and just referencing the file in the command-line arguments.

I wonder what the source of the size of the huge processes are.

@stuhood: Any suggestions how to dig further here? Are process instances or results cached somewhere by the engine?

tdyas commented 1 year ago

It may also be worth running a memory profiler to see where exactly these "process" allocations are occurring. https://github.com/KDE/heaptrack was useful to me at one point.

stuhood commented 1 year ago

@stuhood: Any suggestions how to dig further here? Are process instances or results cached somewhere by the engine?

Yes: the Process struct is cached as a Node in the graph. If it is large, then our memory usage will be higher.

I expect that the next step would be taking advantage of the DeepSizeOf trait that is peppered around the codebase (including on Process and all of its transitively referenced types), to figure out what part of the Processes from #19060 are large.


@jyggen's repro from the description is slightly different: both scandir and paths are pretty clearly suffering from path duplication (and taking up 65% of memory). We've solved that problem for DirectoryDigest by switching to DigestTrie, but we're not currently using a trie for those structures.

The connection between #19060 and this issue might be that the Args list for some processes contain many paths (which are then additionally duplicates of other scandir and paths), but that would need confirmation using DeepSizeOf.

stuhood commented 1 year ago

We've solved that problem for DirectoryDigest by switching to DigestTrie, but we're not currently using a trie for those structures.

I have a draft of doing this for Paths over here: https://github.com/pantsbuild/pants/pull/19232 ... haven't benchmarked it yet.

Will do scandir in a separate PR. (EDIT: https://github.com/pantsbuild/pants/pull/19246)

stuhood commented 1 year ago

The >=2.18.0.dev2 releases contain a fix for the scandir memory size: I'm still looking at how to solve the paths memory size issue.

As mentioned on #19232, that approach ended up being a dead-end for paths, because it didn't differentiate between matched directories and directories which were present because of a parent directory.

jyggen commented 1 year ago

Cheers! I'm off work until early August, so won't be able to give it a try on our monorepo until then sadly.

Something else worth mentioning:

We have disabled pantsd in CI (self-hosted GitLab runner with 8GB of RAM) since forever due to it always being killed for OOM reasons anyway (and Pants exiting with an error when this happens while it's running). It hasn't been too painful other than sequential Pants invocations surely taking longer than they would've with pantsd running.

When upgrading from 2.16.x to 2.17.x however, we've started to see invocations of pants test being killed for (presumably) memory reasons as well. This happens every CI run on my "bump to Pants 2.17.x" branch, and the only way to make it stay alive is to disable the Go backend (or revert to 2.16.x).

The exact, and not very helpful, output is:

/bin/bash: line 188:    47 Killed                  pants test --shard="$((${CI_NODE_INDEX}-1))/${CI_NODE_TOTAL}" ::

I do have a memory profile from heaptrack that I could send over once I'm back at work (it's probably more useful to you two than to me). I'll try to do some additional debugging then as well, but it looks like this issue will be blocking us from migrating past 2.16.x.

stuhood commented 1 year ago

One connection that @jriddy raised around memory usage is that we are doing a lot more memoization than we probably need to: the last sticking point here is around the memory usage of paths nodes... and it didn't hit me until last night that we almost certainly don't need to be memoizing those, which avoids any need to optimize their size in memory.

In general, we should (be able to) make a lot more memoization decisions than we currently are (where all @rule invokes are memoized, and only "rule helpers" are not). That way, if something is likely to only be used once, we avoid the cost of memoization, and only pay the cost of the dependency injection. I'll open a separate ticket about that.

As to resolving this issue: I'll get a PR out to remove the paths node.

jriddy commented 1 year ago

@jyggen I'm working on creating public reproduction repros for these kinds of issues, which will help us benchmark these things and write tests that keep memory and speed performance part of our release evaluations.

My current approach is to create a script that reproduces the dependency graph of a closed-source repo with none of the actual content of code and all target and path names obfuscated. I'm doing this mainly for python now, but I don't think there's any reason we couldn't do it for Go as well. Would you be interested in using this?

jyggen commented 1 year ago

@jriddy Most definitely!

jyggen commented 1 year ago

I'm still a bit worried about this one. When upgrading to Pants 2.17 we had to bump our CI instances to 16 GB memory in order for Pants to not get killed by the OS due to OOM. Disabling all Go-related backends brings this back down to a managable memory usage that could be handled by our previous 8 GB instances. We, as of writing, have 6828 lines of Go vs. 109335 lines of Python, so it's not a linear thing based on LoC.

I'm rather certain it's during analyzation/compilation of 3rd-party dependencies that the memory usage skyrockets. I haven't been able to confirm it nor find the reason why it would, but it's usually on of the last things to get printed in the debug logs before Pants/pantsd is killed.

I'll try to spend a day or two in the near future to look into this further, but worth flagging that the memory usage is still high - and from my perspective, without knowing the reason why, unexpectedly high.

SergeBakharev commented 1 year ago

+1 I'm finding that it's unrelated to the number of LoC but rather the size/quantity of the 3rd party golang deps. We are at a point that 35GB of memory is insufficient for our CI nodes.