Consider V8 code caching for extensions |
|||||||
Issue descriptionWhile doing deep dives on Loading tracing, I noticed that we spend a non trivial amount of time for parsing and compiling JS from extensions. Has anyone given any thoughts about using V8 code caching for these? Sadly, extensions have their own storage. That's the second time this comes up as an issue (i.e. CacheStorage). Perhaps, it might make sense to find a common solution for all of these. Or not, if we think it will be the last instance.
,
Jun 23 2016
+rdevlin.cronin, do you have any context for this design decision?
,
Jun 23 2016
I'm not very familiar with v8 code caching - which code exactly are you suggesting we cache? Our generation code, the extension's code...? The generation code is very tricky. As vogelheim@ mentioned, there *are* a bunch of security concerns, since extension apis are initialized lazily, so malicious code can already run and do all kinds of fun stuff to intercept or modify our initialization process (there have been a ton of security bugs in here already). Additionally, different extension contexts and web pages have different access to APIs. Can you give me a little more detail on how exactly the v8 caching route would work? Also note that we're looking into converting extension bindings into blink-style bindings ( issue 616765 ), which should greatly reduce the amount of time parsing/compiling the js generation code.
,
Jun 23 2016
V8 code caching: The idea is to cache the machine code generated for (the extensions') JavaScript sources, so it can be read & executed directly, in lieu of re-parsing and re-compiling the JS sources again. This is massively faster, provided the cache is actually hit. The resulting machine code is independent of the context (at least, the context as V8 understands it). Caching shouldn't per se change the security properties, since that code would be read/executed at exactly the same time as it would be without cache. Of course, since I don't understand the extensions system much, it's hard for me to say whether my analysis really translates into that space. Background on V8 code caching: - tracking bug: crbug.com/399580 - design doc: https://docs.google.com/a/chromium.org/document/d/1HY4jVB3mCoYWADaZgmRxFmC2vm8qFKUzdC4NZN5oVZA/view
,
Jun 23 2016
Ah, okay. For the extension's code itself, the risk is smaller, I think (and is orthogonal to our bindings work). That sounds interesting, and could definitely help in the case of extensions that execute on every page. +creis and nasko from a security perspective for their thoughts.
,
Jun 24 2016
Bumping priority given the general sense that this is indeed a valuable opportunity to improve performance (hopefully we can resolve the security concerns).
,
Jun 24 2016
Reading the comment #1 looks like the biggest concern was to have an arbitrary renderer (which happened to be the first one to run the extension code for the page) might send back compromised compiled code to the browser disk cache, and then the same code could be used in other renderer processes for again totally different sites/origin, due to extension nature? As suggested by vogelheim@ it feels compiling it in a separate utility process and maybe also expiring periodically / somewhat aggressively might mitigate the threat? (vogelheim@-- do you remember who were in the look when the security concern was discussed?)
,
Jun 24 2016
Curious to hear the previous security considerations as well. I agree with Kenji that this would be very valuable for those with many extensions installed.
,
Jun 24 2016
Hey, the security concern is that if a web page manages to attack (through a bug in chrome) an content script, and that content script gets compiled and written back to disk, the web page now effectively has access to everything the extension had access to. This can be somewhat mitigated by storing the compiled code per origin and deduplicating entries to save space... but overall, this is a lot of work (there is currently no way to write out data to extensions, they are read only), and from my experience, code caching also comes with a certain ongoing maintenance overhead. I think overall the idea of speeding up content scripts is good, however, I don't see us having the resources right now to support it, given possible other work that would also benefit users on mobile or without extensions.
,
Jun 24 2016
,
Jun 27 2016
Thanks Jochen for the extra insights. I definitely agree that this is lower priority than mobile or across the board improvements. Does the V8 team have a backlog?
,
Jun 27 2016
yes, go/v8-backlog - I've added an entry for this to the list
,
Aug 2 2017
Ping! This bug is assigned and has an owner, but hasn't been updated in over 180 days. Is this still something we want to do?
,
Dec 13 2017
|
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by vogelheim@chromium.org
, Jun 23 2016