Open root-11 opened 9 months ago
Proposals: Disable line 755:
self.subscribe(subscriber=agent.uuid, receiver=None, topic=agent.__class__.__name__)
After extensive testing, see results.
To benchmark a counter was placed on the distribution of the original message (in send_to_recipients in the Scheduler) - this avoids counting the message duplicates which are sent to subscribers.
Subscribers can subscribe to 2 of sender, receiver, topic. In the table below (True, True, False) indicates a subscriber to the sender receiver combination for any message topic.
Profiling the get_mail_recipients function showed that it was responsible for 14 - 16% of the total runtime.
I opted for updating the get_mail_recipients function to deliver an equivalent minimum functionality (akin to that shown in the bare bone benchmark). The function was as follows:
def get_mail_recipients(self, message): return [message.receiver]
The result for direct messages performance was 540, 311 msgs/second.
This is interesting for 2 reasons:
Targeting improvements to get_mail_recipients function:
One final investigation I carried out to shed a little more light on the efficiency of the nested dict vs the flag system By counting the conditionals we can see how many calls are made using each of the methods and whether or not the flags add value.
{'results_no_flag': {'mean': 7.165354330708661, 'median': 5.0, 'mode': 5, 'min': 2, 'max': 13, 'complete_miss_mean': 4.267716535433071, 'complete_miss_median': 5, 'complete_miss_mode': 5, 'complete_miss_min': 2, 'complete_miss_max': 5, 'hit_mean': 10.062992125984252, 'hit_median': 11, 'hit_mode': 11, 'hit_min': 2, 'hit_max': 13, ('fff_fft', 'complete_miss'): 5, ('fff_fft', 'hit'): 5}, 'results_with_flag': {'mean': 13.05511811023622, 'median': 12.0, 'mode': 12, 'min': 6, 'max': 24, 'complete_miss_mean': 11.039370078740157, 'complete_miss_median': 11, 'complete_miss_mode': 10, 'complete_miss_min': 6, 'complete_miss_max': 16, 'hit_mean': 15.070866141732283, 'hit_median': 15, 'hit_mode': 15, 'hit_min': 6, 'hit_max': 24, ('fff_fft', 'complete_miss'): 9, ('fff_fft', 'hit'): 9}}
The results show that in all cases we are processing more conditional statements with the flags than without.
I have pushed a release which takes advantage of the direct message style (2023.1.0), the new benchmarked results are:
python3.9 benchmarks.py - 480,440.9 messages/second
pypy3 benchmarks.py - 6,441,251.9 messages/second
minimal test benchmark
barebone benchmark
Summarized:
Based on this observation I would like the workgroup to consider changing the implementation to use at 3 message types
as I believe that these three message types will cover all needs and not slow down maslite to the degree which the current patch does.