Improve performance of BulkTracking and QueuedTracking #7688
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.
I profiled QueuedTracking with Redis (actually inserting the requests from Redis to DB) and made some improvements that as well effect mainly BulkTracking but also normal tracking. In some cases it improved performance by 30-70%.
For example 50% of the total time (180seconds) is spent in https://github.com/piwik/piwik/blob/2.13.0-b2/core/UrlHelper.php#L153 (down to 20% wall time now) . 33.3% of total time is spent in
Common::sanitizeInputValue
https://github.com/piwik/piwik/blob/2.13.0-b2/core/Common.php#L342 (which is also called by UrlHelper partially), 21% is spent inCommon::sanitizeString
https://github.com/piwik/piwik/blob/2.13.0-b2/core/Common.php#L314 .Also
Common::getRequestVar
is very expensive when performed a million times (eg 20% wall time easily), same forPiwik::postEvent()
(> 10% of the time) etc.Those changes are needed by Thursday/Friday for a client to make inserting tracking requests fast enough.