Cache result of "isIpInRanges" for faster tracking in Bulk / Queue #7757
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See screenshot of a profile of a
./console queuedtracking:process
run. The time spent in$ip->isInRanges()
is about 10% time of the total time. That's the same amount of time needed to recognize all visitors (and that queries the database etc).Background: When using eg
queuedtracking:process
we sometimes insert 25k tracking requests at once or maybe even more. In the attached profile we processed 16.000 tracking requests so this method was called 16.000 times (it is used inVisitExcluded
). It took 10% of total time or 27 seconds. When we process so many tracking requests we have very likely the same IP given multiple times which it makes it worth caching. All actions of the same visitor are inserted in the same queue therefore it is likely that the same IP is given multiple times. This means when there are eg 8k different visitors of those 16k tracking requests we gain 50% performance improvement. If there are 4k different visitors we gain a 75% percent improvement.