Changes between Version 5 and Version 6 of Ticket #6710


Ignore:
Timestamp:
05/30/2018 02:08:18 PM (2 years ago)
Author:
mjethani
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #6710

    • Property Priority changed from Unknown to P3
    • Property Ready set
  • Ticket #6710 – Description

    v5 v6  
    2323 - We might be able to save more if we're handle subdomains more cleverly, for example we might be able to avoid storing both "foo.example.com" and "example.com". 
    2424 - For this idea to help we also need to be careful to avoid holding on to any references to the complete filter text. 
     25 
     26=== More details === 
     27 
     28In V8, when a string is sliced, the VM creates a new string object, but the object points to the same memory on the heap as the "parent" string (see [https://bugs.chromium.org/p/v8/issues/detail?id=2869 Chromium bug #2869]). 
     29 
     30{{{ 
     31let domain = filterText.substring(domainStartIndex, domainEndIndex); 
     32}}} 
     33 
     34When two different strings are sliced to extract identical substrings, each of those substrings points to memory in its respective parent string. This is the case with Adblock Plus filters and domain names. Therefore, in order for this optimization to truly work, first of all we would have to ''really'' slice out the domain name from the filter text. 
     35 
     36{{{ 
     37let domain = [...filterText.substring(domainStartIndex, domainEndIndex)].join(""); 
     38}}} 
     39 
     40This would still create duplicate string objects for each recurring domain, but as long as the only place where the string is actually stored is the aforementioned map, the VM should discard any duplicates during garbage collection. 
     41 
     42But if we hold on to the original filter text, then this "optimization" will only add to the memory usage. For this to show results, we would first have to find a way to discard the reference to the original filter text that every `Filter` object currently holds. The original filter text is also used as the key in the `Filter.knownFilters` map. There are a number of ways of avoiding the storage of the original filter text in memory (e.g. using a [https://en.wikipedia.org/wiki/Trie trie]), but please see other related Trac issues for the details.