Documentation ¶
Index ¶
- Constants
- func CleanupWorktrees(ctx context.Context, repo *localrepo.Repo) error
- func FixDirectoryPermissions(ctx context.Context, path string) error
- func GetRepackGitConfig(ctx context.Context, repo repository.GitRepo, bitmap bool) []git.ConfigPair
- func IsPoolRepository(repo repository.GitRepo) bool
- func IsRailsPoolRepository(repo repository.GitRepo) bool
- func RepackObjects(ctx context.Context, repo *localrepo.Repo, cfg RepackObjectsConfig) error
- func WriteCommitGraph(ctx context.Context, repo *localrepo.Repo, cfg WriteCommitGraphConfig) error
- type EagerOptimizationStrategy
- func (s EagerOptimizationStrategy) ShouldPruneObjects() bool
- func (s EagerOptimizationStrategy) ShouldRepackObjects() (bool, RepackObjectsConfig)
- func (s EagerOptimizationStrategy) ShouldRepackReferences() bool
- func (s EagerOptimizationStrategy) ShouldWriteCommitGraph() (bool, WriteCommitGraphConfig)
- type HeuristicalOptimizationStrategy
- func (s HeuristicalOptimizationStrategy) ShouldPruneObjects() bool
- func (s HeuristicalOptimizationStrategy) ShouldRepackObjects() (bool, RepackObjectsConfig)
- func (s HeuristicalOptimizationStrategy) ShouldRepackReferences() bool
- func (s HeuristicalOptimizationStrategy) ShouldWriteCommitGraph() (bool, WriteCommitGraphConfig)
- type Manager
- type OptimizationStrategy
- type OptimizeRepositoryConfig
- type OptimizeRepositoryOption
- type RepackObjectsConfig
- type RepositoryManager
- func (m *RepositoryManager) CleanStaleData(ctx context.Context, repo *localrepo.Repo) error
- func (m *RepositoryManager) Collect(metrics chan<- prometheus.Metric)
- func (m *RepositoryManager) Describe(descs chan<- *prometheus.Desc)
- func (m *RepositoryManager) OptimizeRepository(ctx context.Context, repo *localrepo.Repo, opts ...OptimizeRepositoryOption) error
- type WriteCommitGraphConfig
Constants ¶
const CutOffTime = -14 * 24 * time.Hour
CutOffTime is time delta that is used to indicate cutoff wherein an object would be considered old. Currently this is set to being 2 weeks (2 * 7days * 24hours).
Variables ¶
This section is empty.
Functions ¶
func CleanupWorktrees ¶
CleanupWorktrees cleans up stale and disconnected worktrees for the given repository.
func FixDirectoryPermissions ¶
FixDirectoryPermissions does a recursive directory walk to look for directories that cannot be accessed by the current user, and tries to fix those with chmod. The motivating problem is that directories with mode 0 break os.RemoveAll.
func GetRepackGitConfig ¶
func GetRepackGitConfig(ctx context.Context, repo repository.GitRepo, bitmap bool) []git.ConfigPair
GetRepackGitConfig returns configuration suitable for Git commands which write new packfiles.
func IsPoolRepository ¶ added in v15.2.0
func IsPoolRepository(repo repository.GitRepo) bool
IsPoolRepository returns whether the repository is an object pool.
func IsRailsPoolRepository ¶ added in v15.2.0
func IsRailsPoolRepository(repo repository.GitRepo) bool
IsRailsPoolRepository returns whether the repository is a pool repository generated by Rails.
func RepackObjects ¶
RepackObjects repacks objects in the given repository and updates the commit-graph. The way objects are repacked is determined via the RepackObjectsConfig.
func WriteCommitGraph ¶
WriteCommitGraph updates the commit-graph in the given repository. The commit-graph is updated incrementally, except in the case where it doesn't exist yet or in case it is detected that the commit-graph is missing bloom filters.
Types ¶
type EagerOptimizationStrategy ¶ added in v15.6.0
type EagerOptimizationStrategy struct {
// contains filtered or unexported fields
}
EagerOptimizationStrategy is a strategy that will eagerly perform optimizations. All of the data structures will be optimized regardless of whether they already are in an optimal state or not.
func NewEagerOptimizationStrategy ¶ added in v15.6.0
func NewEagerOptimizationStrategy(ctx context.Context, repo *localrepo.Repo) (EagerOptimizationStrategy, error)
NewEagerOptimizationStrategy creates a new EagerOptimizationStrategy.
func (EagerOptimizationStrategy) ShouldPruneObjects ¶ added in v15.6.0
func (s EagerOptimizationStrategy) ShouldPruneObjects() bool
ShouldPruneObjects always instructs the caller to prune objects, unless the repository is an object pool.
func (EagerOptimizationStrategy) ShouldRepackObjects ¶ added in v15.6.0
func (s EagerOptimizationStrategy) ShouldRepackObjects() (bool, RepackObjectsConfig)
ShouldRepackObjects always instructs the caller to repack objects. The strategy will always be to repack all objects into a single packfile. The bitmap will be written in case the repository does not have any alterantes.
func (EagerOptimizationStrategy) ShouldRepackReferences ¶ added in v15.6.0
func (s EagerOptimizationStrategy) ShouldRepackReferences() bool
ShouldRepackReferences always instructs the caller to repack references.
func (EagerOptimizationStrategy) ShouldWriteCommitGraph ¶ added in v15.6.0
func (s EagerOptimizationStrategy) ShouldWriteCommitGraph() (bool, WriteCommitGraphConfig)
ShouldWriteCommitGraph always instructs the caller to write the commit-graph. The strategy will always be to completely rewrite the commit-graph chain.
type HeuristicalOptimizationStrategy ¶ added in v15.6.0
type HeuristicalOptimizationStrategy struct {
// contains filtered or unexported fields
}
HeuristicalOptimizationStrategy is an optimization strategy that is based on a set of heuristics.
func NewHeuristicalOptimizationStrategy ¶ added in v15.6.0
func NewHeuristicalOptimizationStrategy(ctx context.Context, repo *localrepo.Repo) (HeuristicalOptimizationStrategy, error)
NewHeuristicalOptimizationStrategy constructs a heuristicalOptimizationStrategy for the given repository. It derives all data from the repository so that the heuristics used by this repository can be decided without further disk reads.
func (HeuristicalOptimizationStrategy) ShouldPruneObjects ¶ added in v15.6.0
func (s HeuristicalOptimizationStrategy) ShouldPruneObjects() bool
ShouldPruneObjects determines whether the repository has stale objects that should be pruned. Object pools are never pruned to not lose data in them, but otherwise we prune when we've found enough stale objects that might in fact get pruned.
func (HeuristicalOptimizationStrategy) ShouldRepackObjects ¶ added in v15.6.0
func (s HeuristicalOptimizationStrategy) ShouldRepackObjects() (bool, RepackObjectsConfig)
ShouldRepackObjects checks whether the repository's objects need to be repacked. This uses a set of heuristics that scales with the size of the object database: the larger the repository, the less frequent does it get a full repack.
func (HeuristicalOptimizationStrategy) ShouldRepackReferences ¶ added in v15.6.0
func (s HeuristicalOptimizationStrategy) ShouldRepackReferences() bool
ShouldRepackReferences determines whether the repository's references need to be repacked based on heuristics. The more references there are, the more loose referencos may exist until they are packed again.
func (HeuristicalOptimizationStrategy) ShouldWriteCommitGraph ¶ added in v15.6.0
func (s HeuristicalOptimizationStrategy) ShouldWriteCommitGraph() (bool, WriteCommitGraphConfig)
ShouldWriteCommitGraph determines whether we need to write the commit-graph and how it should be written.
type Manager ¶
type Manager interface { // CleanStaleData removes any stale data in the repository. CleanStaleData(context.Context, *localrepo.Repo) error // OptimizeRepository optimizes the repository's data structures such that it can be more // efficiently served. OptimizeRepository(context.Context, *localrepo.Repo, ...OptimizeRepositoryOption) error }
Manager is a housekeeping manager. It is supposed to handle housekeeping tasks for repositories such as the cleanup of unneeded files and optimizations for the repository's data structures.
type OptimizationStrategy ¶ added in v15.6.0
type OptimizationStrategy interface { // ShouldRepackObjects determines whether the repository needs to be repacked and, if so, // how it should be done. ShouldRepackObjects() (bool, RepackObjectsConfig) // ShouldPruneObjects determines whether the repository has stale objects that should be // pruned. ShouldPruneObjects() bool // ShouldRepackReferences determines whether the repository's references need to be // repacked. ShouldRepackReferences() bool // ShouldWriteCommitGraph determines whether we need to write the commit-graph and how it // should be written. ShouldWriteCommitGraph() (bool, WriteCommitGraphConfig) }
OptimizationStrategy is an interface to determine which parts of a repository should be optimized.
type OptimizeRepositoryConfig ¶ added in v15.6.0
type OptimizeRepositoryConfig struct {
Strategy OptimizationStrategy
}
OptimizeRepositoryConfig is the configuration used by OptimizeRepository that is computed by applying all the OptimizeRepositoryOption modifiers.
type OptimizeRepositoryOption ¶ added in v15.6.0
type OptimizeRepositoryOption func(cfg *OptimizeRepositoryConfig)
OptimizeRepositoryOption is an option that can be passed to OptimizeRepository.
func WithOptimizationStrategy ¶ added in v15.6.0
func WithOptimizationStrategy(strategy OptimizationStrategy) OptimizeRepositoryOption
WithOptimizationStrategy changes the strategy used to determine which parts of the repository will be optimized. By default the HeuristicalOptimizationStrategy is used.
type RepackObjectsConfig ¶
type RepackObjectsConfig struct { // FullRepack determines whether all reachable objects should be repacked into a single // packfile. This is much less efficient than doing incremental repacks, which only soak up // all loose objects into a new packfile. FullRepack bool // WriteBitmap determines whether reachability bitmaps should be written or not. There is no // reason to set this to `false`, except for legacy compatibility reasons with existing RPC // behaviour WriteBitmap bool }
RepackObjectsConfig is configuration for RepackObjects.
type RepositoryManager ¶
type RepositoryManager struct {
// contains filtered or unexported fields
}
RepositoryManager is an implementation of the Manager interface.
func NewManager ¶
func NewManager(promCfg gitalycfgprom.Config, txManager transaction.Manager) *RepositoryManager
NewManager creates a new RepositoryManager.
func (*RepositoryManager) CleanStaleData ¶
CleanStaleData cleans up any stale data in the repository.
func (*RepositoryManager) Collect ¶
func (m *RepositoryManager) Collect(metrics chan<- prometheus.Metric)
Collect is used to collect Prometheus metrics.
func (*RepositoryManager) Describe ¶
func (m *RepositoryManager) Describe(descs chan<- *prometheus.Desc)
Describe is used to describe Prometheus metrics.
func (*RepositoryManager) OptimizeRepository ¶
func (m *RepositoryManager) OptimizeRepository( ctx context.Context, repo *localrepo.Repo, opts ...OptimizeRepositoryOption, ) error
OptimizeRepository performs optimizations on the repository. Whether optimizations are performed or not depends on a set of heuristics.
type WriteCommitGraphConfig ¶ added in v15.2.0
type WriteCommitGraphConfig struct { // ReplaceChain causes WriteCommitGraph to rewrite the complete commit-graph chain. This is // a lot more expensive than the default, incremental update of the commit-graph chains but // may be required in certain cases to fix up commit-graphs. ReplaceChain bool }
WriteCommitGraphConfig contains configuration that can be passed to WriteCommitGraph to alter its default behaviour.
func WriteCommitGraphConfigForRepository ¶ added in v15.2.0
func WriteCommitGraphConfigForRepository(ctx context.Context, repo *localrepo.Repo) (WriteCommitGraphConfig, error)
WriteCommitGraphConfigForRepository returns the optimal default-configuration for the given repo. By default, the configuration will ask for an incremental commit-graph update. If the preexisting commit-graph is missing bloom filters though then the whole commit-graph chain will be rewritten.