From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Surprisingly high use of file descriptors Date: Thu, 05 May 2022 10:47:26 +0300 Message-ID: <83ee182zg1.fsf@gnu.org> References: <874k25726k.fsf@gmail.com> <87r1585u5k.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39303"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 05 09:49:52 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nmWFC-000A38-6h for ged-emacs-devel@m.gmane-mx.org; Thu, 05 May 2022 09:49:50 +0200 Original-Received: from localhost ([::1]:60738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nmWFA-00068q-Uj for ged-emacs-devel@m.gmane-mx.org; Thu, 05 May 2022 03:49:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWD9-0004tS-GI for emacs-devel@gnu.org; Thu, 05 May 2022 03:47:44 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:45610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWD8-0001lb-E8; Thu, 05 May 2022 03:47:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=djqkr3H+a72ISeZY1hqhKlRjnCI22Vk2hFsh9zlZpc0=; b=XghbCh2z+W/f7T24MTGC aEwnsn/TYzsm55aAoN4LeaOTJDyCkgZQ9ifEZc2j8WuLjSa3E/sPEmbVkKHZdCBAI6T+1cfYSxs1H Eovat5sJbFohJMkPZZZOM2NmXIYEJgJj7iDNuobDBzY6rU8SXlYt/zx5PO/HPJnz3vOfBWN12QCLt uldVQ87bxJJtM+3g6C6HHEOkThFJ3vw6Zl90YK1McMm//dKAQL9FEzDj2kw4TeH0Dr5j+elnxMqTn wETO5GWFIWpOHJ+lIxrnceXcsDsagc9Z9rLA/B/NCuHSS4Nw/zR/KdOTvQ3ycYTlaNa28Ot7x1j3g 13Dq+sFN44t4Nw==; Original-Received: from [87.69.77.57] (port=3941 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmWD7-0006YR-V0; Thu, 05 May 2022 03:47:42 -0400 In-Reply-To: <87r1585u5k.fsf@gmail.com> (message from Robert Pluim on Thu, 05 May 2022 09:13:27 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289229 Archived-At: > From: Robert Pluim > Cc: emacs-devel@gnu.org > Date: Thu, 05 May 2022 09:13:27 +0200 > > Stefan> Why would ``lsp-mode` or `eglot` consume anywhere near 1024 file descriptors? > Stefan> Are they launching a separate LSP server process per buffer? > > They use filenotify.el to watch for the changes to all the files in > their project, which on some platforms consumes a file descriptor per > file (at least macOS, and anything kqueue based like FreeBSD). On > other platforms it uses one per directory, and Iʼm sure people have > codebases with >1024 directories. FTR, on MS-Windows the implementation uses a file handle per watch (one watch for each directory), but that handle is not monitored by the emulated pselect. It also creates one thread per each watch. The maximum number of file handles per process on MS-Windows is AFAIK very large (in the millions), and the maximum number of threads per process is on the order of tens of thousands.