From: Adam Thompson <arthompson1990@gmail.com>
To: Karl Dahlke <eklhad@comcast.net>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] stackoverflow and css
Date: Sun, 11 Feb 2018 19:43:01 +0000 [thread overview]
Message-ID: <20180211194301.gx6i6nago4ietkxo@toaster> (raw)
In-Reply-To: <20180211192531.cfzkkzcrsw6k7vd2@toaster>
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.
next prev parent reply other threads:[~2018-02-11 19:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-11 18:53 Karl Dahlke
2018-02-11 19:25 ` Adam Thompson
2018-02-11 19:43 ` Adam Thompson [this message]
2018-02-11 21:03 ` Karl Dahlke
2018-02-11 21:24 ` Karl Dahlke
2018-02-13 19:05 ` Adam Thompson
2018-02-11 23:08 ` Karl Dahlke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180211194301.gx6i6nago4ietkxo@toaster \
--to=arthompson1990@gmail.com \
--cc=Edbrowse-dev@lists.the-brannons.com \
--cc=eklhad@comcast.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).