Live data from Hacker News

Ask HN: Which line of code you have written will be executed the most?

news.ycombinator.com

11–20 of 21 posts

Re: Ask HN: Which line of code you have written will be executed the most?

#11
I spent a week or so pouring through valgrind and profile output optimising the very heart of the code for a Monte Carlo simulation at a major investment bank. Some of the lines of code I wrote in that week will have been executed billions of times per day since I pushed them back in 2007 or so. They are still being used.

I got a good overall speedup (over 5% in code that was already pretty well-optimised) but by far the most valuable optimisation I did was one of the most basic - hoisting variables out of for loops. This kind of thing

    for(int i=0; i
changes to...

    int x;
    for(int i=0; i
There are slightly more subtle versions of that, but at the time none of the compilers we were using (gcc 3.2, solaris 8 C++ compiler or Visual C++ 7) could optimise that without you doing the hoist yourself.

Re: Ask HN: Which line of code you have written will be executed the most?

#15
For me it has to be the data analysis pipeline I wrote for one of the biggest semiconductor manufacturing fabs in the world. Its is triggered for every lot they produce (a lot is usually 25 wafers). This company holds the majority market share in semi manufacturing space, so it is more than coin flip likely that the device you are using to read this contains a chip which was analyzed by my pipeline. (So if it breaks due to thermal issues... sorry).

Re: Ask HN: Which line of code you have written will be executed the most?

#16
20+ years ago, I wrote the Fortran code that polls the vibration of a turbine shaft every 1/100th of second. That facility is still in operation, the system I worked on is still in operation, those type of facilities run 24x7x365 and rarely have a downtime where system or turbine might be taken offline for long. I guess my code has been running every 1/100th of second for 20 years or so. I don't think I can write any code that will beat that little piece of code in frequency of use.
Post reply on HN