Bug 143857 - Use less memory when compiling content extensions
Summary: Use less memory when compiling content extensions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-16 17:38 PDT by Alex Christensen
Modified: 2015-04-16 18:14 PDT (History)
1 user (show)

See Also:


Attachments
Patch (3.71 KB, patch)
2015-04-16 17:39 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (4.92 KB, patch)
2015-04-16 17:58 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (4.79 KB, patch)
2015-04-16 18:02 PDT, Alex Christensen
benjamin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2015-04-16 17:38:35 PDT
We keep a lot of things alive when compiling.  Using less memory would start with keeping fewer things alive.
Comment 1 Alex Christensen 2015-04-16 17:39:42 PDT
Created attachment 250983 [details]
Patch
Comment 2 Benjamin Poulain 2015-04-16 17:46:36 PDT
Comment on attachment 250983 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250983&action=review

Simon would like more info in the changelog.

I don't like the "// Free memory.", they are not adding any information.

> Source/WebCore/contentextensions/ContentExtensionCompiler.cpp:165
> +    parsedRuleList = Vector<ContentExtensionRule>(); // Free memory.
> +    actionLocations = Vector<unsigned>(); // Free memory.

Vector has clear().

A single comment on top of the two lines would be better.

> Source/WebCore/contentextensions/ContentExtensionCompiler.cpp:179
>      Vector<NFA> nfas = combinedURLFilters.createNFAs();
>      if (!nfas.size() && universalActionLocations.size())
>          nfas.append(NFA());
> +    combinedURLFilters.clear(); // Free memory.

I am unconvinced this is the right balance.

We should look into generating the NFAs one by one out of the combinedURLFilters, generate its DFA, clear the NFA, generate the bytecode, clear the DFA.

> Source/WebCore/contentextensions/ContentExtensionCompiler.cpp:240
> +    nfas = Vector<NFA>(); // Free memory.

nfas.clear()?
Comment 3 Alex Christensen 2015-04-16 17:58:39 PDT
Created attachment 250984 [details]
Patch
Comment 4 Alex Christensen 2015-04-16 18:02:23 PDT
Created attachment 250986 [details]
Patch
Comment 5 Alex Christensen 2015-04-16 18:14:13 PDT
http://trac.webkit.org/changeset/182935