public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Robin H. Johnson" <robbat2@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/ag:master commit in: /, lib/
Date: Mon, 23 Feb 2015 22:44:20 +0000 (UTC)	[thread overview]
Message-ID: <1424731454.45f28da0876f572b0bc5d81b7baeefda1b2b108f.robbat2@gentoo> (raw)

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


             reply	other threads:[~2015-02-23 22:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-23 22:44 Robin H. Johnson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-02-24  2:17 [gentoo-commits] proj/ag:master commit in: /, lib/ Robin H. Johnson
2015-02-24  2:00 Robin H. Johnson
2015-02-23 20:59 Alex Legler
2015-02-23  0:05 Alex Legler
2015-02-23  0:05 Alex Legler
2015-02-21 21:45 Robin H. Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1424731454.45f28da0876f572b0bc5d81b7baeefda1b2b108f.robbat2@gentoo \
    --to=robbat2@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox