-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Process img tags in parallel before sequential traversal
no issue Switching to `probe-image-size` dramatically cut the time spent fetching images and the amount of network traffic used when calculating image dimensions but we were still performing requests sequentially which is really slow. This commit takes advantage of `async.parallel` to run up to 10 requests at a time to make better use of the available network capacity. - move img tag handling out of the sequential traversal loop - use `domutils` to pull out an array of img elements for processing - create an async task for processing each img element - use `async.parallelLimit` to process 10 img tasks at a time Continuation of performance testing using the same example content for the previous `probe-image-size` commit... ``` image-size only: INFO amp.parse http://ghost.blog/2019/06/08/test/ 52278ms INFO amp.parse http://ghost.blog/2019/06/08/test/ 52717ms INFO amp.parse http://ghost.blog/2019/06/08/test/ 50582ms average: 51,859ms probe-image-size w/ image-size fallback: INFO amp.parse http://ghost.blog/2019/06/08/test/ 11147ms INFO amp.parse http://ghost.blog/2019/06/08/test/ 12297ms INFO amp.parse http://ghost.blog/2019/06/08/test/ 11188ms average: 11,544ms speedup: ~4.5x parallel image fetch before traversal: INFO amp.parse http://ghost.blog/2019/06/08/test/ 1629ms INFO amp.parse http://ghost.blog/2019/06/08/test/ 1744ms INFO amp.parse http://ghost.blog/2019/06/08/test/ 1398ms average: 1,590ms speedup: ~7.2x total speedup: ~32.5x ```
- Loading branch information
1 parent
c9879b1
commit e09da2f
Showing
3 changed files
with
145 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters