From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.devel Subject: Re: NS port: How to debug excessive garbage collection? Date: Sat, 13 Apr 2019 11:07:55 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="201873"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Alex Gramiak Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 13 20:08:11 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hFN4U-000qNe-Oj for ged-emacs-devel@m.gmane.org; Sat, 13 Apr 2019 20:08:10 +0200 Original-Received: from localhost ([127.0.0.1]:54432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hFN4T-00046Q-Ki for ged-emacs-devel@m.gmane.org; Sat, 13 Apr 2019 14:08:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hFN4J-00046I-Ux for emacs-devel@gnu.org; Sat, 13 Apr 2019 14:08:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hFN4I-0004qj-P3 for emacs-devel@gnu.org; Sat, 13 Apr 2019 14:07:59 -0400 Original-Received: from gateway32.websitewelcome.com ([192.185.145.187]:29727) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hFN4I-0004pp-7k for emacs-devel@gnu.org; Sat, 13 Apr 2019 14:07:58 -0400 Original-Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 4716C1487C9 for ; Sat, 13 Apr 2019 13:07:57 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id FN4GhBz4dYTGMFN4HhK4nG; Sat, 13 Apr 2019 13:07:57 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+Bde624u3kD1fZX5Yg/zxrjxPreVODL35KsiYTidzAY=; b=PzGqYb/EIIvARlCv1hJN8fctGz Y8Rk8AIHRmhw+FF726LrQcFO87//Fwa4obazlXEDaQ3UQAJEG+ZYM+/EounBlOOgz/pXX6TwmE37R zrzw+Ns7ufQ32bEPwmmSOYixPKjjUJXvkcU1TgTQtoThEmesEyUeYOJJ89ENwR6ab8RoUuxs7SHVk qAAvILY9pUnzI5VWMPkOm0dEZRKDlgKkhdZB0lHZba6ChY22URpfix74pe6EJKk0DSwk2FMCOp1ew 6pbIAXnwXGqL7Q02tfpVrGr1kzgKMMfgSWNMOFAWJaY5swqqLtEQrB+NtdZjljRpYFKvqG7wy9nMP KioBdHyg==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50591 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.91) (envelope-from ) id 1hFN4G-000NmZ-Dz; Sat, 13 Apr 2019 13:07:56 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Source-L: No X-Exim-ID: 1hFN4G-000NmZ-Dz X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:50591 X-Source-Auth: lawlist X-Email-Count: 2 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 192.185.145.187 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235406 Archived-At: Thank you, Alex, for helping to diagnose the issue of excessive garbage collection. I observe the issue when building Emacs on an OSX machine using the --with-ns flag. The issue may also occur on the w32 and X11 builds of Emacs, but it is not noticeable to my naked eye. The NS build, on the other hand, permits me to see an appreciable pause for garbage collection every few keystrokes. The garbage collection tests with *_consed that I performed today were on the NS port of Emacs. The usage of Ftruncate in the 04/08/2019 proof concept patch of fake cursors occurs only in w32term.c and xterm.c. My general understanding is as follows: 1. Emacs uses nsterm.m/h when building on an OSX machine and the --with-ns flag. 2. Emacs uses xterm.c when building on an OSX machine that has X11 installed and the following flags are used: --with-x (yes) and --with-ns (no). 3. Emacs uses w32term.c when building on a Windows machine. I would be pleased to remove Ftruncate and replace it with roundf. Thank you for the suggestion. The development of the fake cursors feature has been a work in progress for a little over 3 years now ... learning some C coding along the way. I have seen roundf in a few internet examples over the years, and have a vague recollection of trying to use it somewhere -- however, I cannot remember in what context. Perhaps there is a similar mistake I have made that would affect the NS build of Emacs, or perhaps would affect all of the builds (NS/w32/X11). It is interesting that excessive garbage collection occurs even with the fake cursors feature turned _off_, and it gets much worse when that feature is turned _on_. Keith ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > Date: [04-13-2019 10:02:07] <13 Apr 2019 11:02:07 -0600> > From: Alex Gramiak > To: Keith David Bershatsky > Cc: Eli Zaretskii , emacs-devel@gnu.org > Subject: Re: NS port: How to debug excessive garbage collection? > > Keith David Bershatsky writes: > > > ;;; begin STOCK / UNMODIFIED > > [...] > > ((cons_cells_consed 2455285) > > (symbols_consed 16084) > > (strings_consed 104220) > > (string_chars_consed 2152636) > > (vector_cells_consed 6884284) > > (floats_consed 572) > > (intervals_consed 112)) > > > > > > ;;; end STOCK UNMODIFIED > > > > ============================ > > > > ;;; begin MODIFIED -- CROSSHAIRS "OFF" > > > [...] > > ((cons_cells_consed 2408250) > > (symbols_consed 16120) > > (strings_consed 112081) > > (string_chars_consed 2208228) > > (vector_cells_consed 6903029) > > (floats_consed 23104) > > (intervals_consed 112)) > > > > ;;; end MODIFIED -- CROSSHAIRS "OFF" > > > > ============================ > > > > ;;; begin MODIFIED -- CROSSHAIRS "ON" > > > > [...] > > ((cons_cells_consed 2471395) > > (symbols_consed 16122) > > (strings_consed 111473) > > (string_chars_consed 2209234) > > (vector_cells_consed 6898322) > > (floats_consed 19817) > > (intervals_consed 112)) > > Your floats look out of control. I checked your latest diff, and found > this: > > + int int_red = XFIXNUM (Ftruncate (make_float (term_red), Qnil)); > + int int_green = XFIXNUM (Ftruncate (make_float (term_green), Qnil));; > + int int_blue = XFIXNUM (Ftruncate (make_float (term_blue), Qnil));; > > Why do you make a Lisp float just to truncate it? Can you run your test > again using one of the following? > > https://en.cppreference.com/w/c/numeric/math/round