DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 50JH5RKx1799918 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 50JH5RKx1799918 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=Io+QkN+l X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 106BE3858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1737306327; bh=9mstjJzSf8H+Qym+ASRpSJcjeK2P6sYxCBtrcLYkEoA=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Io+QkN+lb1m44e3RWKWVoN9fFMcHqqPEaFWAahg+RuLgcRMeCUOSns+UMYHqAtvLa pLKAQnKQstjCPm8d8NdrIuNqBRhtzRPHzLwVwxZSwk2cNF8lFqu4DohBie1hHpmkq1 6NDFXceEapSMV7BnZjiEGT0m02wI7iFPs7TbPvjc= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E56713858D21 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E56713858D21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737306263; cv=none; b=b0DD+DrQ6Y5bIbrji7u3MqZ2qqtFssxPqTqlLVOvPme2NPQVNFhtVKQGaBUIdecwiy7luOfYK1+UxcO5uKZLL9JmvTxblSDuY9EEPjZljQBmhg+umTzf8HtBBTyB/dWOTAYdeyq/34O062o43hGWjKa6OV0ycAe6CPcfOMhCJcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737306263; c=relaxed/simple; bh=Dw3uOjctISNMS6vc0PLl4pX9+/qb6TCYLOd3KABL2rk=; h=Message-ID:Date:MIME-Version:From:Subject:To:DKIM-Signature; b=khrWJc3S0hBZbhBE7tzJlKs6CVpUBhjeJu+ibOKhqiQjPW1uFy21vrSscRdTbQyN4bU6MzhqTO/4nRIIxUiZsEaNBRG4gwTffaAwB47yjT+saeHjQkCg72N0faeiZJ1Aj8c9pck4GX1e2KyZ23lpcdwLyz/3yzwhMLK76pYB39c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E56713858D21 Message-ID: Date: Sun, 19 Jan 2025 10:04:20 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Improvement] Cache user auth and converted paths for child-processes Content-Language: en-CA To: cygwin AT cygwin DOT com References: Organization: Systematic Software In-Reply-To: X-Rspamd-Queue-Id: 3794E20013 X-Rspamd-Server: rspamout07 X-Stat-Signature: c5b8ozxb548ahhu59m8izxhtydc99jxa X-Session-Marker: 427269616E2E496E676C69734053797374656D6174696353572E61622E6361 X-Session-ID: U2FsdGVkX18fjtwcCp9lHFv1oCC17zVvwco4oXZQF2w= X-HE-Tag: 1737306261-220145 X-HE-Meta: U2FsdGVkX19tDEOpyammWsLivLv/FHsFACUnhfmKxgyOvrEkIwZrOaDo2Sf9n7ECJ8uJY6HHCu7FlAn5jXVBxO5U3xAD1pf/Wa7ly/QcmOpNXeyvT1RyWDDsvHZCx3mBJsLfoyZwoYqfsjfxB3sbIFvRpZQKJMg93ocmm8fWnHwtvmSkDpXPOekh7wNFbeT7Tl164gdkNJX9PcrMIGONWg3aSdn1xRJAK9tkfJ4NOa0I3O7/IKNenXXPr2nH6nksFpOXlpEJ29ukAtPt++9AqjzdQGnMBiPJNbDRBO6a1aHAdKGuZ89K8oIhVNTxUKc369z17FzOOT3jzrGwurQFqVD9fSTbECkYSzuuOJDi/WlkfjVr51Sw/dpGCHY1Cgi9tTYr23NeLYdD+rCFGYq7VA== X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Brian Inglis via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Brian Inglis Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 50JH5RKx1799918 On 2025-01-19 05:56, Devste Devste via Cygwin wrote: > strace -o strace.log dirname -- /some/path/here > There are 2 points that could make it significantly faster and > shouldn't be too hard to implement? Criticisms as expected to be accompanied by code and all Patches are Thoughtfully Considered (PTC - see https://cygwin.com/acronyms/) - git format-patch/send-email against repo main branch to cygwin-patches@... ML. All contributors are volunteers working when they have spare time available. > 1) A significant amount of time is spent on user auth (as seen in > various github issues the infamous /etc/passwd nsswitch.conf fix) > Wouldn't it be possible to just reuse the auth data from the current > shell for the subshell, e.g. for > basename -- $(dirname -- /some/path/here) Some of this is done for each child in a Cygwin process tree, and for all Cygwin processes if you run cygserver. You can also decide to limit what sources should be used in nsswitch.conf. > 2) why are unix/dos path conversions of environment variables not > cached? A significant amount of time (15-30%, depending on the number > of environment variables) is spent on the conversion for every > invocation. > However, this would be extremely simple to cache and reusable even on > completely unrelated subshells. > cache key = original path > cache value = converted value > e.g. > > ``` > 44 12839 [main] dirname 16929 mount_info::conv_to_posix_path: > conv_to_posix_path (C:\Users\User123\bin, 0x10000100, no-add-slash) > 44 12883 [main] dirname 16929 normalize_win32_path: > C:\Users\User123\bin = normalize_win32_path (C:\Users\User123\bin) > 44 12927 [main] dirname 16929 mount_info::conv_to_posix_path: > mount[0] .. checking / -> C:\Program Files\Git > 44 12971 [main] dirname 16929 mount_info::conv_to_posix_path: > mount[1] .. checking /bin -> C:\Program Files\Git\usr\bin > 44 13015 [main] dirname 16929 mount_info::conv_to_posix_path: > mount[2] .. checking /tmp -> C:\Users\User123\AppData\Local\Temp > 44 13059 [main] dirname 16929 mount_info::conv_to_posix_path: > /c/Users/User123/bin = conv_to_posix_path (C:\Users\User123\bin) > ``` > could be cached with key > C:\Users\User123\bin > and value > /c/Users/User123/bin > at least for the current process (e.g. a bash script and it's > children) without risking any noticeable outdated cache issues > (probably even longer, however we want to keep it simple and don't > want to worry about cache invalidation too much) Any process can change the environment, so contents can not be assumed, and everything has to be rechecked each time. It is probably quicker (44µs) to check for paths and convert. Drop all the Windows paths and variables from your Cygwin environment, unless you intend to run Windows programs from there, and you will not have so much overhead. For a cache, you would want to key from the env var name, have a path flag, and keep Windows and Cygwin alternatives, but that only helps if you have child processes where the environment stays the same, so the penalty should be paid in any children. -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retrancher but when there is no more to cut -- Antoine de Saint-Exupéry -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple