Module: Gitlab::Git::RuggedImpl::UseRugged

Included in:
ConfigChecker::PumaRuggedChecker, Blob::ClassMethods, Commit, Commit::ClassMethods, Repository, Tree::ClassMethods
Defined in:
lib/gitlab/git/rugged_impl/use_rugged.rb

Instance Method Summary collapse

Instance Method Details

#execute_rugged_call(method_name, *args) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gitlab/git/rugged_impl/use_rugged.rb', line 17

def execute_rugged_call(method_name, *args)
  Gitlab::GitalyClient::StorageSettings.allow_disk_access do
    start = Gitlab::Metrics::System.monotonic_time

    result = send(method_name, *args) # rubocop:disable GitlabSecurity/PublicSend

    duration = Gitlab::Metrics::System.monotonic_time - start

    if Gitlab::RuggedInstrumentation.active?
      Gitlab::RuggedInstrumentation.increment_query_count
      Gitlab::RuggedInstrumentation.add_query_time(duration)

      Gitlab::RuggedInstrumentation.add_call_details(
        feature: method_name,
        args: args,
        duration: duration,
        backtrace: Gitlab::BacktraceCleaner.clean_backtrace(caller))
    end

    result
  end
end

#rugged_enabled_through_feature_flag?Boolean

Returns:

  • (Boolean)

50
51
52
53
54
# File 'lib/gitlab/git/rugged_impl/use_rugged.rb', line 50

def rugged_enabled_through_feature_flag?
  rugged_feature_keys.any? do |feature_key|
    Feature.enabled?(feature_key)
  end
end

#rugged_feature_keysObject


46
47
48
# File 'lib/gitlab/git/rugged_impl/use_rugged.rb', line 46

def rugged_feature_keys
  Gitlab::Git::RuggedImpl::Repository::FEATURE_FLAGS
end

#running_puma_with_multiple_threads?Boolean

Returns:

  • (Boolean)

40
41
42
43
44
# File 'lib/gitlab/git/rugged_impl/use_rugged.rb', line 40

def running_puma_with_multiple_threads?
  return false unless Gitlab::Runtime.puma?

  ::Puma.respond_to?(:cli_config) && ::Puma.cli_config.options[:max_threads] > 1
end

#use_rugged?(repo, feature_key) ⇒ Boolean

Returns:

  • (Boolean)

7
8
9
10
11
12
13
14
15
# File 'lib/gitlab/git/rugged_impl/use_rugged.rb', line 7

def use_rugged?(repo, feature_key)
  return Feature.enabled?(feature_key) if Feature.persisted_name?(feature_key)

  # Disable Rugged auto-detect(can_use_disk?) when Puma threads>1
  # https://gitlab.com/gitlab-org/gitlab/issues/119326
  return false if running_puma_with_multiple_threads?

  Gitlab::GitalyClient.can_use_disk?(repo.storage)
end