Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Speed up start up time by batch querying ACL events #3334

Merged
merged 4 commits into from
Feb 21, 2024
Merged

Conversation

S7evinK
Copy link
Contributor

@S7evinK S7evinK commented Feb 20, 2024

This should significantly speed up start up times on servers with many rooms.

@S7evinK S7evinK added the X-Performance Issue/PR around something that is slow or taking lots of memory label Feb 20, 2024
@S7evinK S7evinK requested a review from a team as a code owner February 20, 2024 18:03
Copy link

codecov bot commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8f944f6) 67.41% compared to head (2c29e1c) 67.40%.

❗ Current head 2c29e1c differs from pull request most recent head 3125f4b. Consider uploading reports for the commit 3125f4b to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3334      +/-   ##
==========================================
- Coverage   67.41%   67.40%   -0.01%     
==========================================
  Files         518      518              
  Lines       46860    46847      -13     
==========================================
- Hits        31590    31579      -11     
+ Misses      11330    11328       -2     
  Partials     3940     3940              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@S7evinK S7evinK enabled auto-merge (squash) February 21, 2024 12:24
@S7evinK S7evinK disabled auto-merge February 21, 2024 13:10
@S7evinK S7evinK merged commit f4e7745 into main Feb 21, 2024
18 checks passed
@S7evinK S7evinK deleted the s7evink/startup-acls branch February 21, 2024 13:10
@S7evinK S7evinK mentioned this pull request Feb 22, 2024
S7evinK added a commit that referenced this pull request Feb 28, 2024
Since #3334 didn't change much on d.m.org, this is another attempt to
speed up startup.

Given moderation bots like Mjolnir/Draupnir are in many rooms with quite
often the same or similar ACLs, caching the compiled regexes _should_
reduce the startup time.

Using a pointer to the `*regexp.Regex` ensures we only store _one_
instance of a regex in memory, instead of potentially storing it hundred
of times. This should reduce memory consumption on servers with many
rooms with ACLs drastically. (5.1MB vs 1.7MB with this change on my
server with 8 ACL'd rooms [3 using the same ACLs])

[skip ci]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
X-Performance Issue/PR around something that is slow or taking lots of memory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants