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
[Filter] Performance increases. #2509
Conversation
The filter was already using re to split words, this just does the entire search in re instead. A further improvement to this would cache patterns used and update them if the wordlist changes.
|
The majority of the time difference without the cache was the generator expression which created the pattern. Adding a pattern cache makes the regex solution multiple orders of magnitude faster on any message other than the first received in a channel with a filter. (Side by side comparison from discord conversation, running the same above tests on the updated version, but in a profiler instead of just a straight time count.) Context: |
RE: 1, You seem to have fixed the issue now, the issue was not returning an empty set on no hits. I said the issue was it returned a non-empty set on everything when filter was loaded but there were no banned words. |
yeah, I realized I misunderstood your meaning on that, and added that, but forgot to comment 😓 |
…ince this is available to cogs
Moved actual set creation out of the inner portion. Reduced config lookups in case of no filter. Fixed channel wordlist fetching.
Type
Description of the changes
The filter was already using re to split words, this just does the entire search in re instead.