From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:400c:c0c::22a; helo=mail-wr0-x22a.google.com; envelope-from=arthompson1990@gmail.com; receiver= Received: from mail-wr0-x22a.google.com (mail-wr0-x22a.google.com [IPv6:2a00:1450:400c:c0c::22a]) by hurricane.the-brannons.com (Postfix) with ESMTPS id B8EE377CAA for ; Sun, 11 Feb 2018 11:42:21 -0800 (PST) Received: by mail-wr0-x22a.google.com with SMTP id b52so13139289wrd.10 for ; Sun, 11 Feb 2018 11:43:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=buU4KG1oMnRuY+xvKGrGEN5CSruup+fYAPZoEi9e8yQ=; b=sASRcp7tbSuVojcYYG8hSnQbfah9ri3mh9SNptu98ROf+//0hw9+97d3Gf1JP78hND OvjCrj1SVpbxc/kTpEDpW6MfmMSfLFe0Ctm0QYFtiy7cLvBVQhkrd9ofGfF2zhXtbfPT iL/O9sDaRMpLMSQZtSka/l+kXt3DUWIXveDjA00VksO6pcEy3FuDA8h2mg6+qwn60WO/ j32EY6xP+j4jND2v5z4SEk9nf9iVD4qM6HRF6CBsCQ3d7YmOTjnRldzVEndJ/g1GVdpk yNqevOwS6hdLnic6GBfCV8wv9pEDHUmFvlmsXgjpAsxswWyUkrxLDZLXZUw/NX42fncm 5tMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=buU4KG1oMnRuY+xvKGrGEN5CSruup+fYAPZoEi9e8yQ=; b=LP8036tCU2Xc4QLws1Gvu1aIF7+YhYsfSZKz3xXk/umrPm0WnkAM9GBSnRzuoXyTJ9 vBrF1E88lZW86lZrkgb0iQsiOLL3Kahd94i1dGRomifin6efKked+P73Pmcr/vGWPpar M0uk9xmEB5kJOiIxjsEvP80/uJ9QE2qbWFU92doFkDH1l0zosBstNfRwKCI8vO16BeBR rhvfZBp5CdTNDg/L/7UhusdhdpRW27KB8HB1Tm5sCKVvX6qPMOSn9mrpwmBaTUrHlMe5 GFKfxnjj0SdiXsn1lp9dVxICVK3UlWi31sEtFagfqkVqRrawvl711HeoTEsRs7XALKYG RJEw== X-Gm-Message-State: APf1xPA3GWJe6RyeqTlRUlMt1fR8qUG5sXxN0sPnyqHJwU1sZ3dy3nTp XqUEkvfQ9geGAc+Iuvrpu20= X-Google-Smtp-Source: AH8x224pIIWNU8oOHhrbkv4yVJSBBoRFAvCqBRrk3vSQq0HlKBYV8fmszDh95+99xh4f+bOKnzSOuw== X-Received: by 10.223.184.204 with SMTP id c12mr2278494wrg.253.1518378183958; Sun, 11 Feb 2018 11:43:03 -0800 (PST) Received: from toaster (a.5.9.3.b.f.e.f.f.f.4.4.2.d.a.2.2.4.0.9.2.4.1.1.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1142:9042:2ad2:44ff:fefb:395a]) by smtp.gmail.com with ESMTPSA id b65sm12841545wrd.26.2018.02.11.11.43.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 11:43:03 -0800 (PST) Date: Sun, 11 Feb 2018 19:43:01 +0000 From: Adam Thompson To: Karl Dahlke Cc: Edbrowse-dev@lists.the-brannons.com Message-ID: <20180211194301.gx6i6nago4ietkxo@toaster> References: <20180111135351.eklhad@comcast.net> <20180211192531.cfzkkzcrsw6k7vd2@toaster> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180211192531.cfzkkzcrsw6k7vd2@toaster> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [Edbrowse-dev] stackoverflow and css X-BeenThere: edbrowse-dev@lists.the-brannons.com X-Mailman-Version: 2.1.25 Precedence: list List-Id: Edbrowse Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Feb 2018 19:42:22 -0000 On Sun, Feb 11, 2018 at 07:25:31PM +0000, Adam Thompson wrote: > On Sun, Feb 11, 2018 at 01:53:51PM -0500, Karl Dahlke wrote: > > The css portion, that maps css attributes over to objects, takes 2 minutes to run. > > That's not the infinite loop, but it is intolerable nonetheless. > > Browse www.stackoverflow.com with db3 and watch 2 minutes go by between > > > > execute eb$qs$start > > execution complete > > Wow, yeah... that's not good. > > > The version we got was built to run and handle all situations, and be robust, but obviously not optimized. > > Optimizing things is something I'm good at, but it's a lot of code doing something I'm not entirely familiar with, so I would be taking a big bite. > > Could it be optimized and still be javascript? Is it primarily an algorithmic inefficiency? > > Or would it have to be rewritten in C? > > I hope the former, because turning all that into C would be a pain! > > There's no real reason to mess with the css parser, that runs once and pretty fast, > > but querySelectorAll compares every css directive against every node in the document, which is potentially an n^2 problem. > > Yeah, that sounds like an algorithm problem, I'll take a look and see if there's anything obvious. > May be there's some way to ignore certain directives, I'm not entirely sure yet. > > Thanks for looking at this. Ok, just had a quick look through the code, and my js is... not great... but I wonder if we could (may be lazily when we first traverse looking for selectors) hash element references based on selectors. That *should* save traversals in subsequent calls to querySelectorAll. That being said, I'm not entirely sure I can understand how that code does its job so I may be missing something important there. Cheers, Adam.