Changes between Version 5 and Version 6 of Ticket #6710

05/30/2018 02:08:18 PM (2 years ago)


  • 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 "" and "". 
    2424 - For this idea to help we also need to be careful to avoid holding on to any references to the complete filter text. 
     26=== More details === 
     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 [ Chromium bug #2869]). 
     31let domain = filterText.substring(domainStartIndex, domainEndIndex); 
     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. 
     37let domain = [...filterText.substring(domainStartIndex, domainEndIndex)].join(""); 
     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. 
     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 [ trie]), but please see other related Trac issues for the details.