From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#20154: 25.0.50; json-encode-string is too slow for large strings Date: Sat, 21 Mar 2015 22:25:48 +0200 Message-ID: <83zj76rtbn.fsf@gnu.org> References: <86twxf68zk.fsf@yandex.ru> <83384zwxdx.fsf@gnu.org> <550C3218.4000903@yandex.ru> <831tkjww0y.fsf@gnu.org> <550C3AB9.7020403@yandex.ru> <83wq2bveq6.fsf@gnu.org> <550C491A.6000909@yandex.ru> <83siczvcss.fsf@gnu.org> <550C504A.10708@yandex.ru> <83r3sjva0q.fsf@gnu.org> <550C6A06.6040203@yandex.ru> <83fv8zv0b1.fsf@gnu.org> <550C990B.8080505@yandex.ru> <838ueqvl1o.fsf@gnu.org> <550DCDEE.4090900@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1426969655 31091 80.91.229.3 (21 Mar 2015 20:27:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Mar 2015 20:27:35 +0000 (UTC) Cc: 20154@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 21 21:27:24 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YZPzK-0001T0-8D for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Mar 2015 21:27:18 +0100 Original-Received: from localhost ([::1]:48924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZPzJ-0004o5-Kl for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Mar 2015 16:27:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZPz9-0004cN-0Z for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2015 16:27:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZPz4-00028c-Vr for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2015 16:27:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZPz4-00028N-Rn for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2015 16:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YZPz4-0007oC-H7 for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2015 16:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Mar 2015 20:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20154 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20154-submit@debbugs.gnu.org id=B20154.142696957229960 (code B ref 20154); Sat, 21 Mar 2015 20:27:02 +0000 Original-Received: (at 20154) by debbugs.gnu.org; 21 Mar 2015 20:26:12 +0000 Original-Received: from localhost ([127.0.0.1]:60076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YZPyF-0007n9-J6 for submit@debbugs.gnu.org; Sat, 21 Mar 2015 16:26:11 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:62051) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YZPyC-0007mv-M6 for 20154@debbugs.gnu.org; Sat, 21 Mar 2015 16:26:09 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NLK00100WFSB400@a-mtaout22.012.net.il> for 20154@debbugs.gnu.org; Sat, 21 Mar 2015 22:26:02 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NLK001R8WRD2N90@a-mtaout22.012.net.il>; Sat, 21 Mar 2015 22:26:02 +0200 (IST) In-reply-to: <550DCDEE.4090900@yandex.ru> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:100756 Archived-At: > Date: Sat, 21 Mar 2015 22:00:46 +0200 > From: Dmitry Gutov > CC: 20154@debbugs.gnu.org > > On 03/21/2015 09:58 AM, Eli Zaretskii wrote: > > > It depends on your requirements. How fast would it need to run to > > satisfy your needs? > > In this case, the buffer contents are encoded to JSON at most once per > keypress. So 50ms or below should be fast enough, especially since most > files are smaller than that. So each keypress you need to encode the whole buffer, including the last keypress and all those before it? I guess I don't really understand why each keypress should trigger encoding of the whole buffer. > > You don't really need regexp replacement functions with all its > > features here, do you? What you need is a way to skip characters that > > are "okay", then replace the character that is "not okay" with its > > encoded form, then repeat. > > It doesn't seem like regexp searching is the slow part: save for the GC > pauses, looking for the non-matching regexp in the same string - > > (replace-regexp-in-string "x" "z" s1 t t) > > - only takes ~3ms. Then a series of calls to replace-regexp-in-string, one each for every one of the "special" characters, should get you close to your goal, right? > And likewise, after changing them to use `concat' instead of `format', > both alternative json-encode-string implementations that I have "encode" > a numbers-only (without newlines) string of the same length in a few > milliseconds. Again, save for the GC pauses, which can add 30-40ms. So does this mean you have your solution?