commit: 45f28da0876f572b0bc5d81b7baeefda1b2b108f Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> AuthorDate: Mon Feb 23 22:44:14 2015 +0000 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> CommitDate: Mon Feb 23 22:44:14 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/ag.git;a=commit;h=45f28da0
Include a --jobs parameter. Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> --- ag | 7 +++++++ lib/utils.rb | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ag b/ag index d36acc4..97c223f 100755 --- a/ag +++ b/ag @@ -24,6 +24,7 @@ $options.index_only = false $options.no_threading = false $options.debug = false $options.readonly = false +$options.jobs = false op = OptionParser.new do |opts| opts.banner = "Usage: ag <<--index-full|--index-new|--delete|--reindex|--info> <--list listname>> <[--file|--msgid|--hash] <maildir/file/hash/messageid>> [options]" @@ -93,6 +94,10 @@ op = OptionParser.new do |opts| opts.on('--readonly', 'Do not alter the maildir in any way') do $options.readonly = true end + + opts.on('--jobs', 'Number of parallel jobs to run (defaults to 75% of core count)') do |jobs| + $options.jobs = jobs + end end op.parse! @@ -110,6 +115,8 @@ $maildir.serializer = Maildir::Serializer::Mail.new $es = Elasticsearch::Client.new(log: false) $es.transport.reload_connections! +Ag::Utils.proc_count = $options.jobs + ############################################################################### def do_full diff --git a/lib/utils.rb b/lib/utils.rb index 0213c6d..b37437b 100644 --- a/lib/utils.rb +++ b/lib/utils.rb @@ -67,8 +67,15 @@ module Ag '' end + @proc_count = nil + def proc_count=(cnt) + cnt = nil if cnt == false + @proc_count = cnt + end + def proc_count + return @proc_count unless @proc_count.nil? or @proc_count == false (Parallel::ProcessorCount.processor_count.to_f * 0.75).floor end end -end \ No newline at end of file +end