Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce adblock filter memory usage by optimizing unused regex rules #21970

Closed
antonok-edm opened this issue Mar 30, 2022 · 6 comments · Fixed by brave/brave-core#12824 or brave/brave-core#12901

Comments

@antonok-edm
Copy link
Collaborator

As discovered by @atuchin-m, there is an extra ~7MB that can be saved by optimizing the regex field of NetworkFilter in adblock-rust. This was fixed in adblock-rust as of v0.5.2.

@atuchin-m
Copy link
Contributor

atuchin-m commented Mar 30, 2022

For QA: we should verify, that browser process memory consumption became 7mb less.
A possible scenario:

  1. Launch browser without the fix with one saved tab about:blank
  2. Wait 15 sec.
  3. Check browser process memory footprint in the internal task manager (see a screenshot)
  4. Repeat a few times to make the results stable (3-5 times)
  5. Repeat 1-4 for browser with the fix

image

@MadhaviSeelam
Copy link

MadhaviSeelam commented Apr 29, 2022

Verified PASSED with

Brave 1.39.86 Chromium: 101.0.4951.41 (Official Build) beta (64-bit)
Revision 93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS Windows 11 Version 21H2 (Build 22000.613)

Below builds do not have fix

Brave 1.38.109 Chromium: 101.0.4951.41 (Official Build) (64-bit)
Revision 93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS Windows 11 Version 21H2 (Build 22000.613)

And

Brave 1.37.105 Chromium: 100.0.4896.46 (Official Build) (64-bit)
Revision 5ca33821b2211805855c77d334353d27c616a7ca-refs/branch-heads/4896@{#584}
OS Windows 11 Version 21H2 (Build 22000.613)

Verified test plan from #21970 (comment).

Compared browser memory consumption on 1.39.86 to 1.38.109 and 1.37.105 and consumption is significantly less in Beta.

1.39.86 Chromium: 101.0.4951.41

ex1 ex2 ex3 ex4 ex5
Beta Beta2 Beta3 Beta4 Beta5

1.38.109 Chromium: 101.0.4951.41

ex1 ex2 ex3 ex4 ex5
138-1 138-2 138-3 138-4 138-2

@LaurenWags
Copy link
Member

LaurenWags commented May 2, 2022

Verified with

Brave | 1.39.87 Chromium: 101.0.4951.41 (Official Build) beta (x86_64)
-- | --
Revision | 93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS | macOS Version 12.3.1 (Build 21E258)

Verified test plan from #21970 (comment).

Compared 1.38.109 (current Release channel version) and 1.39.87 (current Beta channel version).
Browser memory footprint was decreased in 1.39.x.

1.38.109 1.39.87
1 38 108 1 39
Brave	1.39.84 Chromium: 101.0.4951.41 (Official Build) beta (arm64) 
Revision	93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS	macOS Version 12.3.1 (Build 21E258)

Verified test plan from #21970 (comment).

Compared 1.38.109 (current Release channel version) and 1.39.84 (recent Beta channel version).
Browser memory footprint was decreased in 1.39.x.

1.38.109 1.39.84
1 38 109 1 39 x
Brave	1.39.87 Chromium: 101.0.4951.41 (Official Build) beta (x86_64) 
Revision	93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS	macOS Version 10.15.7 (Build 19H1824)

Verified test plan from #21970 (comment).

Compared 1.38.109 (current Release channel version) and 1.39.87 (current Beta channel version).
Browser memory footprint was decreased in 1.39.x.

1.38.109 1.39.87
1 38 x 1 39 x

@stephendonner
Copy link

stephendonner commented May 2, 2022

Verified PASSED using

Brave 1.39.87 Chromium: 101.0.4951.41 (Official Build) beta (x86_64)
Revision 93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS macOS Version 11.6.5 (Build 20G527)

to compare against

Brave 1.38.109 Chromium: 101.0.4951.41 (Official Build) (x86_64)
Revision 93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS macOS Version 11.6.5 (Build 20G527)

Confirmed, for my setup, that we dropped around 15MB in resident-set-size, on average.

Build Median
1.38.109 120 (120.4)
1.39.87 105 (105.4)

Breakdown:

1.38.109 (in MB) 1.39.87 (in MB)
119 110
121 105
119 105
124 103
119 104

Verified PASSED using

Brave 1.39.84 Chromium: 101.0.4951.41 (Official Build) beta (arm64)
Revision 93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS macOS Version 11.6.4 (Build 20G417)

Confirmed, for my setup, that we dropped around 114MB in resident-set-size, on average.

Build Median
1.38.109 113 (113.2)
1.39.84 ** 99 (98.98)**

Breakdown:

1.38.109 (in MB) 1.39.84 (in MB)
116 101
113 101
112 95.1
112 96.8
113 101

@btlechowski
Copy link

Verification passed on

Brave 1.39.100 Chromium: 101.0.4951.61 (Official Build) beta (64-bit)
Revision 3b3633b32c491b4cba5fd7df3c7c0f628547cbcc-refs/branch-heads/4951@{#1189}
OS Ubuntu 18.04 LTS

On 5 point average, 1.39.x uses 8MB less memory

Example 1.38.x:
image

Example 1.39.x
image

@kjozwiak
Copy link
Member

kjozwiak commented May 23, 2022

Verification PASSED on Samsung S10+ running Android 12 using the following build(s):

Brave | 1.39.111 Chromium: 102.0.5005.61 (Official Build) (64-bit)
--- | ---
Revision | 0e59bcc00cc4985ce39ad31c150065f159d95ad3-refs/branch-heads/5005@{#819}
OS | Android 12; Build/SP1A.210812.016
1.38.119 (370.2 MB) 1.38.119 (318 MB) 1.38.119 (304.5 MB) 1.38.119 (302.4 MB) 1.38.119 (316.2 MB)
image image image image image
1.39.111 (310.6 MB) 1.39.111 (314 MB) 1.39.111 (312 MB) 1.39.111 (297.7 MB) 1.39.111 (308.3 MB)
image image image image image

Verification PASSED on Samsung Galaxy Tablet A running Android 11 using the following build(s):

Brave | 1.39.111 Chromium: 102.0.5005.61 (Official Build) (64-bit)
--- | ---
Revision | 0e59bcc00cc4985ce39ad31c150065f159d95ad3-refs/branch-heads/5005@{#819}
OS | Android 11; Build/RP1A.200720.012
1.38.119 (214.3 MB) 1.38.119 (176.2 MB) 1.38.119 (232.6 MB) 1.38.119 (204.4 MB) 1.38.119 (202.4 MB)
image image image image image
1.39.111 (154 MB) 1.39.111 (177.6 MB) 1.39.111 (161.4 MB) 1.39.111 (160.9 MB) 1.39.111 (149.5 MB)
image image image image image

avinassh pushed a commit to avinassh/brave-browser-hardening that referenced this issue May 29, 2022
 - Added Solana support for account creation, sending SOL and sending SPL tokens with Brave Wallet. ([#22348](brave/brave-browser#22348))
 - Added the ability to buy with Ramp using Brave Wallet. ([#21639](brave/brave-browser#21639))
 - Added JSONSanitizer to API helper requests for Brave Wallet. ([#21831](brave/brave-browser#21831))
 - Added Dapp UI for requesting a public key and for decrypting ciphers using Brave Wallet. ([#21177](brave/brave-browser#21177))
 - Added web3_clientVersion support for Brave Wallet. ([#19278](brave/brave-browser#19278))
 - Added the ability to allow users to search sites for RSS feeds for Brave News. ([#21768](brave/brave-browser#21768))
 - Added support for blob partitioning. ([#21746](brave/brave-browser#21746))
 - Added minimum macOS version for Sparkle update process. ([#22918](brave/brave-browser#22918))
 - [Security] Blocked "window.ethereum" completely in third party iframes. ([#22686](brave/brave-browser#22686))
 - [Security] Updated Brave Wallet panel to prominently display eTLD+1 as reported on HackerOne by renekroka. ([#21787](brave/brave-browser#21787))
 - [Security] Fixed incorrect origin being displayed in Brave Wallet when a spend approval is pending. ([#19557](brave/brave-browser#19557))
 - Implemented eth_getEncryptionPublicKey for Brave Wallet. ([#19276](brave/brave-browser#19276))
 - Implemented account discovery when restoring Brave Wallet. ([#18104](brave/brave-browser#18104))
 - Updated Omaha installer version for Windows to v1.3.36.113. ([#22060](brave/brave-browser#22060))
 - Updated default IPFS configuration values. ([#22068](brave/brave-browser#22068))
 - Updated Gas Limit validation and error messaging for unapproved transactions with Brave Wallet. ([#21714](brave/brave-browser#21714))
 - Updated Brave Wallet to automatically add swap taker asset to the visible asset list. ([#21428](brave/brave-browser#21428))
 - Updated Brave Wallet portfolio network filter for multichain support. ([#20780](brave/brave-browser#20780))
 - Reduced adblock filter memory usage by optimizing unused regex rules. ([#21970](brave/brave-browser#21970))
 - Removed known Dialog Insight user tracking parameters from URLs. ([#22082](brave/brave-browser#22082))
 - Removed ability to swap ERC721 tokens with Brave Wallet. ([#21550](brave/brave-browser#21550))
 - Fixed crash which occurred when opening Brave Shields while using Google Meet. ([#22814](brave/brave-browser#22814))
 - Fixed inability to rename Solana account in Brave Wallet after it has been created. ([#22958](brave/brave-browser#22958))
 - Fixed incorrectly computed insufficient funds errors in Brave Wallet. ([#22877](brave/brave-browser#22877))
 - Fixed ERC20 and ERC721 transfers being incorrectly displayed as ETH transfers in the Brave Wallet transactions panel. ([#22044](brave/brave-browser#22044))
 - Fixed text alignment issues under the Brave Wallet "Recent transactions" panel when using long account names. ([#21216](brave/brave-browser#21216))
 - Fixed breakage in webpack build caused by OpenSSL 3.0. ([#22305](brave/brave-browser#22305))
 - Fixed two windows being opened on launch when the browser was installed without administrator privileges on Windows. ([#22179](brave/brave-browser#22179))
 - Upgraded Chromium to 102.0.5005.61. ([#22923](brave/brave-browser#22923)) ([Changelog for 102.0.5005.61](https://chromium.googlesource.com/chromium/src/+log/101.0.4951.67..102.0.5005.61?pretty=fuller&n=1000))
avinassh pushed a commit to avinassh/brave-browser-hardening that referenced this issue May 29, 2022
 - Added Brave Firewall + VPN. ([#12197](brave/brave-browser#12197))
 - Added support for blob partitioning. ([#21746](brave/brave-browser#21746))
 - Implemented eth_getEncryptionPublicKey for Brave Wallet. ([#19276](brave/brave-browser#19276))
 - Reduced adblock filter memory usage by optimizing unused regex rules. ([#21970](brave/brave-browser#21970))
 - Removed known Dialog Insight user tracking parameters from URLs. ([#22082](brave/brave-browser#22082))
 - Fixed breakage in webpack build caused by OpenSSL 3.0. ([#22305](brave/brave-browser#22305))
 - Fixed pending bell icon under Brave Wallet not being displayed when new unapproved requests are created. ([#21654](brave/brave-browser#21654))
 - Fixed expand icon under Brave Shields using incorrect color when the Privacy Hub has been enabled. ([#22049](brave/brave-browser#22049))
 - Upgraded Chromium to 102.0.5005.61. ([#22923](brave/brave-browser#22923)) ([Changelog for 102.0.5005.61](https://chromium.googlesource.com/chromium/src/+log/101.0.4951.67..102.0.5005.61?pretty=fuller&n=1000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment