From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.90.26.14 with SMTP id 14cs91667agz; Sun, 8 Nov 2009 22:03:09 -0800 (PST) Received: by 10.224.58.73 with SMTP id f9mr3863447qah.61.1257746589013; Sun, 08 Nov 2009 22:03:09 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 29si3203645qyk.134.2009.11.08.22.03.08; Sun, 08 Nov 2009 22:03:09 -0800 (PST) Received-SPF: pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-talk-bounces@rubyforge.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 6D0F118582CB; Mon, 9 Nov 2009 01:03:08 -0500 (EST) Received: from mail-px0-f201.google.com (mail-px0-f201.google.com [209.85.216.201]) by rubyforge.org (Postfix) with ESMTP id BDDAD1858267 for ; Mon, 9 Nov 2009 01:02:08 -0500 (EST) Received: by pxi39 with SMTP id 39so4310673pxi.30 for ; Sun, 08 Nov 2009 22:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=B4HuN622fNRgGVF61CnSKjaX8a9daz5ZmzO+sgN2UnQ=; b=gXMKRxgqml4eGW2XV+B0Etrs3Mjg6LQElAtQX7wa2oj+z7TDpILMXLGwy+HKkXyfKj 9goYxTEQOWgcauIgk59aYlbcMXjVjKJ1uJaWCgLOnw0xP/r8fFNcYct5AD5DUnbhUEA1 TwFsHKHvRvYLye3PmhLPy7F+yv7aRdSEZXwuw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=bNKFKhwddgUry8gfDp5qdoSgheu1pGAVr5Vdj/66Sh/TIDRz/ETd/IAkH9c5DSPopl 1vvA+nZybVIeW5q5HiUboRfDDjKvODqlcql1IM3Mi77z+LIOaDGXod07etJc37FXxgF/ +OFev/sLDOMXTqiVwkz4a/WB8klAC0ywg2how= MIME-Version: 1.0 Received: by 10.115.66.29 with SMTP id t29mr12863183wak.187.1257746527647; Sun, 08 Nov 2009 22:02:07 -0800 (PST) In-Reply-To: <1257399921-26813-2-git-send-email-rlane@club.cc.cmu.edu> References: <1257399921-26813-1-git-send-email-rlane@club.cc.cmu.edu> <1257399921-26813-2-git-send-email-rlane@club.cc.cmu.edu> Date: Sun, 8 Nov 2009 22:02:07 -0800 Message-ID: <69d60e3a0911082202t31561f18mf5e24dda7a108b58@mail.gmail.com> From: Eugene Marinelli To: Rich Lane Cc: sup-talk@rubyforge.org Subject: Re: [sup-talk] [PATCH 2/4] async thread indexing X-BeenThere: sup-talk@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: User & developer discussion of Sup List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: sup-talk-bounces@rubyforge.org Errors-To: sup-talk-bounces@rubyforge.org > - Index.save_thread t > + Index.save_thread_async t Where is the "save_thread_async" function? In patch 3/4, this looks like a syntax error: > - end > + threads.each { |t| Index.save_thread async t } > end - Eugene Marinelli On Wed, Nov 4, 2009 at 9:45 PM, Rich Lane wrote: > --- > =A0bin/sup =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 = =A02 ++ > =A0lib/sup/index.rb =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 26 ++++++++= +++++++++++++++++- > =A0lib/sup/modes/thread-index-mode.rb | =A0 =A02 +- > =A03 files changed, 28 insertions(+), 2 deletions(-) > > diff --git a/bin/sup b/bin/sup > index 78c396a..910ff12 100755 > --- a/bin/sup > +++ b/bin/sup > @@ -142,6 +142,7 @@ Index.lock_interactively or exit > =A0begin > =A0 Redwood::start > =A0 Index.load > + =A0Index.start_sync_worker unless $opts[:no_threads] > > =A0 $die =3D false > =A0 trap("TERM") { |x| $die =3D true } > @@ -335,6 +336,7 @@ ensure > > =A0 HookManager.run "shutdown" > > + =A0Index.stop_sync_worker > =A0 Redwood::finish > =A0 stop_cursing > =A0 Redwood::Logger.remove_all_sinks! > diff --git a/lib/sup/index.rb b/lib/sup/index.rb > index 5d8d714..1131ec7 100644 > --- a/lib/sup/index.rb > +++ b/lib/sup/index.rb > @@ -28,6 +28,8 @@ class BaseIndex > =A0 def initialize dir=3DBASE_DIR > =A0 =A0 @dir =3D dir > =A0 =A0 @lock =3D Lockfile.new lockfile, :retries =3D> 0, :max_age =3D> n= il > + =A0 =A0@sync_worker =3D nil > + =A0 =A0@sync_queue =3D Queue.new > =A0 end > > =A0 def lockfile; File.join @dir, "lock" end > @@ -175,10 +177,32 @@ class BaseIndex > > =A0 def save_thread t > =A0 =A0 t.each_dirty_message do |m| > - =A0 =A0 =A0update_message_state m > + =A0 =A0 =A0if @sync_worker > + =A0 =A0 =A0 =A0@sync_queue << m > + =A0 =A0 =A0else > + =A0 =A0 =A0 =A0update_message_state m > + =A0 =A0 =A0end > =A0 =A0 =A0 m.clear_dirty > =A0 =A0 end > =A0 end > + > + =A0def start_sync_worker > + =A0 =A0@sync_worker =3D Redwood::reporting_thread('index sync') { run_s= ync_worker } > + =A0end > + > + =A0def stop_sync_worker > + =A0 =A0return unless worker =3D @sync_worker > + =A0 =A0@sync_worker =3D nil > + =A0 =A0@sync_queue << :die > + =A0 =A0worker.join > + =A0end > + > + =A0def run_sync_worker > + =A0 =A0while m =3D @sync_queue.deq > + =A0 =A0 =A0return if m =3D=3D :die > + =A0 =A0 =A0update_message_state m > + =A0 =A0end > + =A0end > =A0end > > =A0index_name =3D ENV['SUP_INDEX'] || $config[:index] || DEFAULT_INDEX > diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-in= dex-mode.rb > index 370903a..d2b1651 100644 > --- a/lib/sup/modes/thread-index-mode.rb > +++ b/lib/sup/modes/thread-index-mode.rb > @@ -477,7 +477,7 @@ EOS > =A0 =A0 =A0 BufferManager.say("Saving threads...") do |say_id| > =A0 =A0 =A0 =A0 dirty_threads.each_with_index do |t, i| > =A0 =A0 =A0 =A0 =A0 BufferManager.say "Saving modified thread #{i + 1} of= #{dirty_threads.length}...", say_id > - =A0 =A0 =A0 =A0 =A0Index.save_thread t > + =A0 =A0 =A0 =A0 =A0Index.save_thread_async t > =A0 =A0 =A0 =A0 end > =A0 =A0 =A0 end > =A0 =A0 end > -- > 1.6.4.2 > > _______________________________________________ > sup-talk mailing list > sup-talk@rubyforge.org > http://rubyforge.org/mailman/listinfo/sup-talk > _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk