Bug 143857

Summary: Use less memory when compiling content extensions
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: WebCore Misc.Assignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch benjamin: review+

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