From: Victor Leschuk Subject: RE: [PATCH v4] Add git-grep threads param Date: Mon, 9 Nov 2015 09:28:12 -0800 Message-ID: <6AE1604EE3EC5F4296C096518C6B77EE5D0FDABA18@mail.accesssoftek.com> References: <1445980944-24000-1-git-send-email-vleschuk@accesssoftek.com> <20151104064021.GB16605@sigill.intra.peff.net> <6AE1604EE3EC5F4296C096518C6B77EE5D0FDABA15@mail.accesssoftek.com> <20151109155538.GC27224@sigill.intra.peff.net> <6AE1604EE3EC5F4296C096518C6B77EE5D0FDABA17@mail.accesssoftek.com>,<20151109165343.GA29179@sigill.intra.peff.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT Cc: Junio C Hamano , Victor Leschuk , "git@vger.kernel.org" , "torvalds@linux-foundation.org" , "john@keeping.me.uk" To: Jeff King X-From: git-owner@vger.kernel.org Mon Nov 09 18:28:32 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZvqEx-0005DL-3N for gcvg-git-2@plane.gmane.org; Mon, 09 Nov 2015 18:28:23 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752118AbbKIR2R (ORCPT ); Mon, 9 Nov 2015 12:28:17 -0500 Received: from mail.accesssoftek.com ([12.202.173.171]:33486 "EHLO mail.accesssoftek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751980AbbKIR2O convert rfc822-to-8bit (ORCPT ); Mon, 9 Nov 2015 12:28:14 -0500 Received: from mail.accesssoftek.com ([172.16.0.71]) by mail.accesssoftek.com ([172.16.0.71]) with mapi; Mon, 9 Nov 2015 09:28:13 -0800 Thread-Topic: [PATCH v4] Add git-grep threads param Thread-Index: AdEbDzMp7vyMKPUTSJ610CKsqgeg4QAAc532 In-Reply-To: <20151109165343.GA29179@sigill.intra.peff.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: > if (list.nr || cached) > num_threads = 1; > if (!num_threads) > num_threads = GREP_NUM_THREADS_DEFAULT; > and then later, instead of use_threads, do: > if (num_threads <= 1) { ... do single-threaded version ... > } else { ... do multi-threaded version ... > } > That matches the logic in builtin/pack-objects.c. Maybe use the simplest version (and keep num_numbers == 0 also as flag for all other checks in code like if(num_flags) .... ): if (list.nr || cached ) num_threads = 0; // do not use threads else if (num_threads == 0) num_threads = online_cpus() <= 1 ? 0 : GREP_NUM_THREADS_DEFAULT; else if (num_threads < 0) die(...) // here we are num_threads > zero, so do nothing