Documentation
¶
Index ¶
- Constants
- func CleanupWorktrees(ctx context.Context, repo *localrepo.Repo) error
- func GetRepackGitConfig(ctx context.Context, repo repository.GitRepo, bitmap bool) []git.ConfigPair
- func PruneObjects(ctx context.Context, repo *localrepo.Repo, cfg PruneObjectsConfig) error
- 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(context.Context) (bool, PruneObjectsConfig)
- func (s EagerOptimizationStrategy) ShouldRepackObjects(ctx context.Context) (bool, RepackObjectsConfig)
- func (s EagerOptimizationStrategy) ShouldRepackReferences(context.Context) bool
- func (s EagerOptimizationStrategy) ShouldWriteCommitGraph(context.Context) (bool, WriteCommitGraphConfig)
- type HeuristicalOptimizationStrategy
- func (s HeuristicalOptimizationStrategy) ShouldPruneObjects(context.Context) (bool, PruneObjectsConfig)
- func (s HeuristicalOptimizationStrategy) ShouldRepackObjects(ctx context.Context) (bool, RepackObjectsConfig)
- func (s HeuristicalOptimizationStrategy) ShouldRepackReferences(context.Context) bool
- func (s HeuristicalOptimizationStrategy) ShouldWriteCommitGraph(ctx context.Context) (bool, WriteCommitGraphConfig)
- type Manager
- type OptimizationStrategy
- type OptimizationStrategyConstructor
- type OptimizeRepositoryConfig
- type OptimizeRepositoryOption
- type PruneObjectsConfig
- type RepackObjectsConfig
- type RepackObjectsStrategy
- 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 ( // RepackObjectsStrategyIncremental performs an incremental repack by writing all loose // objects that are currently reachable into a new packfile. RepackObjectsStrategyIncremental = RepackObjectsStrategy("incremental") // RepackObjectsStrategyFullWithLooseUnreachable performs a full repack by writing all // reachable objects into a new packfile. Unreachable objects will be exploded into loose // objects. RepackObjectsStrategyFullWithLooseUnreachable = RepackObjectsStrategy("full_with_loose_unreachable") // RepackObjectsStrategyFullWithCruft performs a full repack by writing all reachable // objects into a new packfile. Unreachable objects will be written into a separate cruft // packfile. RepackObjectsStrategyFullWithCruft = RepackObjectsStrategy("full_with_cruft") // RepackObjectsStrategyFullWithUnreachable performs a full repack by writing all reachable // objects into a new packfile. Packed unreachable objects will be appended to the packfile // and redundant loose object files will be deleted. // // Note that this will not include unreachable loose objects, but only packed loose objects. // git-repack(1) does not currently expose an option to make it include all objects. // Combined with geometric repacks though this is acceptable as the geometric strategy will // include all loose objects. RepackObjectsStrategyFullWithUnreachable = RepackObjectsStrategy("full_with_unreachable") // RepackObjectsStrategyGeometric performs an geometric repack. This strategy will repack // packfiles so that the resulting pack structure forms a geometric sequence in the number // of objects. Loose objects will get soaked up as part of the repack regardless of their // reachability. RepackObjectsStrategyGeometric = RepackObjectsStrategy("geometric") )
const ( // FullRepackCooldownPeriod is the cooldown period that needs to pass since the last full // repack before we consider doing another full repack. FullRepackCooldownPeriod = 5 * 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func CleanupWorktrees ¶
CleanupWorktrees cleans up stale and disconnected worktrees for the given repository.
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 PruneObjects ¶ added in v15.10.0
PruneObjects prunes loose objects from the repository that are already packed or which are unreachable and older than the configured expiry date.
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(info stats.RepositoryInfo) EagerOptimizationStrategy
NewEagerOptimizationStrategy creates a new EagerOptimizationStrategy.
func (EagerOptimizationStrategy) ShouldPruneObjects ¶ added in v15.6.0
func (s EagerOptimizationStrategy) ShouldPruneObjects(context.Context) (bool, PruneObjectsConfig)
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(ctx context.Context) (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 alternates.
func (EagerOptimizationStrategy) ShouldRepackReferences ¶ added in v15.6.0
func (s EagerOptimizationStrategy) ShouldRepackReferences(context.Context) bool
ShouldRepackReferences always instructs the caller to repack references.
func (EagerOptimizationStrategy) ShouldWriteCommitGraph ¶ added in v15.6.0
func (s EagerOptimizationStrategy) ShouldWriteCommitGraph(context.Context) (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(info stats.RepositoryInfo) HeuristicalOptimizationStrategy
NewHeuristicalOptimizationStrategy constructs a heuristicalOptimizationStrategy for the given repository info. 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(context.Context) (bool, PruneObjectsConfig)
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(ctx context.Context) (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(context.Context) 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(ctx context.Context) (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(context.Context) (bool, RepackObjectsConfig) // ShouldPruneObjects determines whether the repository has stale objects that should be // pruned and, if so, how it should be done. ShouldPruneObjects(context.Context) (bool, PruneObjectsConfig) // ShouldRepackReferences determines whether the repository's references need to be // repacked. ShouldRepackReferences(context.Context) bool // ShouldWriteCommitGraph determines whether we need to write the commit-graph and how it // should be written. ShouldWriteCommitGraph(context.Context) (bool, WriteCommitGraphConfig) }
OptimizationStrategy is an interface to determine which parts of a repository should be optimized.
type OptimizationStrategyConstructor ¶ added in v15.9.0
type OptimizationStrategyConstructor func(stats.RepositoryInfo) OptimizationStrategy
OptimizationStrategyConstructor is a constructor for an OptimizationStrategy that is being informed by the passed-in RepositoryInfo.
type OptimizeRepositoryConfig ¶ added in v15.6.0
type OptimizeRepositoryConfig struct {
StrategyConstructor OptimizationStrategyConstructor
}
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 WithOptimizationStrategyConstructor ¶ added in v15.9.0
func WithOptimizationStrategyConstructor(strategyConstructor OptimizationStrategyConstructor) OptimizeRepositoryOption
WithOptimizationStrategyConstructor changes the constructor for the optimization strategy.that is used to determine which parts of the repository will be optimized. By default the HeuristicalOptimizationStrategy is used.
type PruneObjectsConfig ¶ added in v15.10.0
type PruneObjectsConfig struct { // ExpireBefore controls the grace period after which unreachable objects shall be pruned. // An unreachable object must be older than the given date in order to be considered for // deletion. ExpireBefore time.Time }
PruneObjectsConfig determines which objects should be pruned in PruneObjects.
type RepackObjectsConfig ¶
type RepackObjectsConfig struct { // Strategy determines the strategy with which to repack objects. Strategy RepackObjectsStrategy // 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 // WriteMultiPackIndex determines whether a multi-pack index should be written or not. WriteMultiPackIndex bool // CruftExpireBefore determines the cutoff date before which unreachable cruft objects shall // be expired and thus deleted. CruftExpireBefore time.Time }
RepackObjectsConfig is configuration for RepackObjects.
type RepackObjectsStrategy ¶ added in v15.11.0
type RepackObjectsStrategy string
RepackObjectsStrategy defines how objects shall be repacked.
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.