-
Notifications
You must be signed in to change notification settings - Fork 295
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
performance degradation for extra fields #1117
Comments
Uh. I expected that the speed would be s bit lower but that is really slow. Thanks for identifying the commit. |
Any possibility you can help me with a quick resolution on this? |
Unfortunately not yet. It only affects extra fields and I suspect that the slow part is somewhere in the add-method (actually: some methods used by it): >>> timeit.timeit('msg.MessageFactory.from_dict({"__type": "Event", "extra.foo": "bar"})', setup='import intelmq.lib.message as msg', number=1000)
7.618276967999918
>>> timeit.timeit('msg.MessageFactory.from_dict({"__type": "Event", "source.abuse_contact": "bar"})', setup='import intelmq.lib.message as msg', number=1000)
0.1765257789993484
>>> timeit.timeit("ev = msg.Event(); ev.add('extra.foo', 'bar')", setup='import intelmq.lib.message as msg', number=100)
0.7326651559997117
>>> timeit.timeit("ev = msg.Event(); ev.add('source.abuse_contact', 'bar')", setup='import intelmq.lib.message as msg', number=100)
0.019149830000969814
>>> timeit.timeit("ev._Message__is_valid_key('extra.foo')", setup='import intelmq.lib.message as msg; ev = msg.Event()', number=100)
0.1854049479989044
>>> timeit.timeit("ev._Message__is_valid_key('source.abuse_contact')", setup='import intelmq.lib.message as msg; ev = msg.Event()', number=100)
0.0003554070008249255
>>> timeit.timeit("ev._Message__get_type_config('extra.foo')", setup='import intelmq.lib.message as msg; ev = msg.Event()', number=100)
0.07898436200048309
>>> timeit.timeit("ev._Message__get_type_config('source.abuse_contact')", setup='import intelmq.lib.message as msg; ev = msg.Event()', number=100)
0.0006972609990043566 |
Here is cProfile run, |
I did the
Notice the linear increase in time. This forced me to look away from the methods listed in above comment. I started to look at functool decorator lru_cache, here are the results with lru_cache decorator commented out
The only explanation I can think of is that I have submitted the PR #1119 for fix, in which I reordered the call to |
I reworked JSONDict a bit (without any changes at in these validation methods in the message class yet) and for the timeit-benchmark I am now as fast as on 1.0.x (actually ~5% faster, but that's nitpicking). |
see also #1252 for a possible fix |
Closing here, further improvements are on the roadmap |
I have noticed severe performance degradation in bots caused by commit 50eb548 to file
intelmq/lib/message.py
Here are two runs with commit 50eb548 and prior commit 6ccaf3b
Logging is set as follows
First run is with commit 6ccaf3b and the bot is run for 5 minutes
The bot processed approx 1,20,000 messages in 5 minutes.
Next run is with commit 50eb548 and the bt is run for 30 minutes
This time the bot only processed 20,000 messages in 30 minutes.
I haven't yet dissected deeper, I hope you can reproduce the results and pinpoint the cause of this issue.
The text was updated successfully, but these errors were encountered: