Changes between Version 1 and Version 2 of Ticket #6729


Ignore:
Timestamp:
06/05/2018 07:57:12 AM (2 years ago)
Author:
mjethani
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #6729 – Description

    v1 v2  
    2222 3.  '''Slicing''': After the above optimizations, some of the code would still hold on to the entire filter text due to [https://bugs.chromium.org/p/v8/issues/detail?id=2869 Chromium bug #2869]. When a string is sliced (via `String.substring`, `String.match`, and so on) in V8, the VM creates a new [https://mrale.ph/blog/2016/11/23/making-less-dart-faster.html "sliced" string] object that still points to memory in the "parent" string. Even if the reference to the parent string is lost, the parent string remains in memory. In order to avoid this situation, the code could "really" slice the string using `[...string].join("")` or something more efficient and elegant. 
    2323 
    24  4.  '''Interning''': When `"hello world".substring(0, 5)` and `"hello universe".substring(0, 5)` are executed, V8 creates two "sliced" string objects with the content `"hello"`. Even after the substrings are separated from their respective parent strings, there would still be two identical string objects in memory. This is particularly true for domain names in filter text, which recur a lot. In order to ensure that all of the code references only one and the same copy of the substring, the substring could be entered into and retrieved out of a global `Map` instance as and when necessary (see #6710). 
     24 4.  '''Interning''': When `"hello world".substring(0, 5)` and `"hello universe".substring(0, 5)` are executed, V8 creates two "sliced" string objects with the content `hello`. Even after the substrings are separated from their respective parent strings, there would still be two identical string objects in memory. This is particularly true for domain names in filter text, which recur a lot. In order to ensure that all of the code references only one and the same copy of the substring, the substring could be entered into and retrieved out of a global `Map` instance as and when necessary (see #6710). 
    2525 
    2626 5.  '''Implementation in C++''': It may not be feasible to achieve the above in JavaScript alone, owing to the fact that each JavaScript object is quite heavy and even a trie containing all filter text would result in tens of thousands of nodes; but this could be done efficiently in C++ using Emscripten and Web Assembly. The C++ version of the trie could cast the leaf node pointer to `uintptr_t` and return that value. At the time of retrieval, the function could accept a `uintptr_t`, cast it back to a leaf node pointer, and retrieve the key from the leaf node by walking up the tree.