Techrecipe

‘One line of code’ reduces program execution time by 99%

Engineers have to struggle to improve program execution speed and website display speed in a matter of seconds, but sometimes there are dramatic improvements that are ridiculously absurd. Photo-sharing service Pinterest, through its own blog, draws attention by introducing a case in which the execution time was reduced by 99% with a single line of code change.

One of the things that speeded up execution was an engineering productivity team that supports engineering related to software build and deployment in Pinterest. Pinterest operates six (Pinboard, Optimus, Cosmos, Magnus, iOS, Android) repositories on GitHub. The oldest of these is the pinboard storage. If the entire completion count of more than 350,000 is replicated, it is a huge storage with data size exceeding 20GB. The team is carrying out such storage maintenance and so on.

Pinterest builds and distributes software with Jenkins, an automation tool, and copies the latest packages from the GitHub repository by placing the code at the beginning of the automated process. We are devising to speed up the replication of a huge repository, such as specifying an option to obtain only the latest 50 commits (depth: 50) or only the latest commit history (shallow).

In the improved code of this code, “refspec:+refs/heads/master:refs/remotes/origin/master” has been added. An option added to the improved code is an option (refspec) that can specify the range of points to be processed. If you clone without specifying the git design and options (refspec), you get a commit history that fetches all branches of the remote repository. In the case of the Pinterest repository, it was inefficient to withdraw all of the 2,500 or more branches in the repository before the improvement, and to duplicate the master branch. The improved code limits the branch fetched by refspec to the master branch.

This one-line change takes 40 minutes and 30 seconds for storage replication. In terms of the ratio, it was successfully reduced by 99%. The overall speed of building software was also dramatically improved. Pinterest says that one line difference can sometimes make a big difference. Related information can be found here.

lswcap

lswcap

Through the monthly AHC PC and HowPC magazine era, he has watched 'technology age' in online IT media such as ZDNet, electronic newspaper Internet manager, editor of Consumer Journal Ivers, TechHolic publisher, and editor of Venture Square. I am curious about this market that is still full of vitality.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most discussed

%d 블로거가 이것을 좋아합니다: