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

Optimize message filters to reduce CPU load #885

Merged
merged 6 commits into from
Jan 30, 2024

Conversation

ArneBab
Copy link
Contributor

@ArneBab ArneBab commented Jan 26, 2024

In profiling with instrumentation, this reduces the cost for MessageFilter::match by factor 4. It might reduce the total CPU needs of fred by factor 2.

In the profiling with jvisualvm this reduces the total time for
MessageFilter::match from 5x the self-time to about 1.2x the self-time

In profiling with instrumentation, MessageFilter::match is the most
expensive method call, because it is called millions of times in a
tight inner loop while handling messages.
Match is called so often, that the match-method with two arguments
took 20% of the self-time of the match-method with three arguments.

This may be inflated due to the instrumentation, though, because the
method with two arguments does nothing except for running the method
with three arguments with the default (false), so I expect less than
those 20% in wins.
To evaluate the logs this produces:

grep -Eo or-match.* ~/Freenet/logs/freenet-latest.log | \
  sort | uniq -c | sort -h \
  > misordered-MessageFilter-or-matches.log
cat misordered-MessageFilter-or-matches.log

this produces a list of MessageFilters with the frequency for pairs
where the first is the one that did not match and the second is the
filter that did match.
@ArneBab ArneBab changed the title Optimize message filters Optimize message filters to reduce CPU load Jan 26, 2024
@ArneBab
Copy link
Contributor Author

ArneBab commented Jan 30, 2024

I removed the TODOs again (reverted the commit adding them). These were just notes to myself, but I am not likely to get to them in the next few weeks, so they actually serve no purpose. When I get into that part of the code again at another time, I’ll see how to improve it.

Thank you for reminding me!

@ArneBab ArneBab force-pushed the optimize-MessageFilters branch from 7e57e79 to d1eeb8c Compare January 30, 2024 08:59
@ArneBab ArneBab force-pushed the optimize-MessageFilters branch from d1eeb8c to d06857d Compare January 30, 2024 09:00
@ArneBab ArneBab merged commit 374ef2c into hyphanet:next Jan 30, 2024
1 check passed
@ArneBab
Copy link
Contributor Author

ArneBab commented Jan 30, 2024

Merged — thank you very much for your review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants