From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: string_char_to_byte and string_byte_to_char micro-optimisation Date: Fri, 14 Jun 2019 14:37:58 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="147458"; mail-complaints-to="usenet@blaine.gmane.org" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 14 14:44:43 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.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hblZS-000cGu-WF for ged-emacs-devel@m.gmane.org; Fri, 14 Jun 2019 14:44:43 +0200 Original-Received: from localhost ([::1]:51208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hblZR-00022T-Sa for ged-emacs-devel@m.gmane.org; Fri, 14 Jun 2019 08:44:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58803) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hblT3-0005i2-BH for emacs-devel@gnu.org; Fri, 14 Jun 2019 08:38:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hblT2-00073E-CF for emacs-devel@gnu.org; Fri, 14 Jun 2019 08:38:05 -0400 Original-Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:41100) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hblT2-0006y6-3P for emacs-devel@gnu.org; Fri, 14 Jun 2019 08:38:04 -0400 Original-Received: by mail-wr1-x434.google.com with SMTP id c2so2360885wrm.8 for ; Fri, 14 Jun 2019 05:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:mail-followup-to:mail-copies-to:gmane-reply-to-list :date:message-id:mime-version:content-transfer-encoding; bh=tNTTo9Tgqt4u22lux81aSyZM4fTCkrRoXuzXiKazTos=; b=rOpv7f6BCOelmiToj7kA9Cgfmmj2WrfYjl7kVupZnToZfR4HkOVmi2e7n3osaZc9n0 +9mD23Ji9cjrFrlYBw4IwUTZWF5HBt4ZjjSeuVB+JUXRjA8DvbgoygTqyVmYTowUBg09 wIthVJkSqo/ajUc774O03xau0Ba1AiQ2W0p0VeNkkXL/pKzUZLUdrOH0pPqmHsiOdbXQ fD5icSZ18XFEOA4T3flidF8Lf0p0HlUVdtrmkSJ/rdoSWrWxsRP+M+r5Wz9vchXoR+oK A5jxRwtKDqacPMTSVGMANWlY6bGOuZ5oAWjuK4jR1M+YpGfrxzcnZFJ9q6A7xWGir6J1 PKKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:mail-followup-to:mail-copies-to :gmane-reply-to-list:date:message-id:mime-version :content-transfer-encoding; bh=tNTTo9Tgqt4u22lux81aSyZM4fTCkrRoXuzXiKazTos=; b=HvcjZoadHpqYMoFE4Y+juUTvHdzu+d53H/dk+RWIim+37oZE1eeLPF++Be7IQU9UC3 LkaPdKEbp0SNSDWFlKeRqZMmFXS3z45tq4y+yokkEODufKwJzElzNpvTnqQOMZJh7tGG zfpoPjC5kW5tuNmXgTS3TXOOGbsEwhNhJXY0/hfELz5+ayg2UGNi3UVH5kV0njWRUvj4 fivn2KAgdR81pQ5j8BxwkXX2xkE/tHH0rNiimFMWi/L5U1/b6ULY6C6GPgRObMSSEmeP sxRXumr8zZ510h5tdUUuYM4N/Vn7gocYtBOGrkKxEF6suKLuP16rvUiBHvjB+H/SbkxS VDbw== X-Gm-Message-State: APjAAAUVXJSDbnxlc2FmKronHlMKjrXGOloxgB1noAD9y7XFLwLEpof3 UbtBi9WuXRI9n8SZ32Do1QY8ywp5J+0= X-Google-Smtp-Source: APXvYqyL2K/o+gBR423D0heSb7An/iQJgDb0FKrCWCsVtt6Jzt+mPtC3TY4UC4U30wLjYSahuWYAEQ== X-Received: by 2002:adf:aa09:: with SMTP id p9mr7360862wrd.59.1560515880295; Fri, 14 Jun 2019 05:38:00 -0700 (PDT) Original-Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id x129sm4330745wmg.44.2019.06.14.05.37.59 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 05:37:59 -0700 (PDT) Mail-Followup-To: emacs-devel@gnu.org Mail-Copies-To: never Gmane-Reply-To-List: yes X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:237605 Archived-At: Hi, in a benchmark is shown: (defun compare (string-a string-b) (cl-loop for a being the elements of string-a for b being the elements of string-b unless (eql a b) return (cons a b))) (benchmark-run (let ((a (make-string 100000 0)) (b (make-string 100000 0))) (setf (aref a (1- (length a))) 256 (aref b (1- (length b))) 256) (compare a b))) which runs very slowly because string_char_to_byte and string_byte_to_char only cache the found values for 1 previous string. I have a patch which extends this cache to two (count 'em, two!) previous strings, which fixes this particular benchmark. What I don=CA=BCt have is any intuition on whether such a change actually makes any difference in real-world Emacs usage. Can anyone suggest any benchmarks? Thanks Robert