Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
11–20 of 26 posts
Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#12I thought it was a Big O problem at first, because the code was hacky and used more Arrays that it needed. But it was because it was obtaining all images and then sorting them by time.
I sped it up to milliseconds by making the queries sorted by time.
Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#13Adding the right indexes in a relational database.
Converting from csv to parquet before querying large datasets on Apache Spark.
Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#14The process was loading 40GB files to database and aggregation took more than 5 hours.
Wrote a simple awk one liner with associate array and process was completed in minutes
Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#15Now, of course, there's zero reason to write every debug output with O_SYNC. Classical case of cargo-cult programming. I'd like to say I've never seen something like that again, but then I'd be lying.
Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#16I took their exact SQL commands and wrapped them in my own scripting, and the simplified single-threaded version was executing in about fifteen minutes.
I went back through and added some explicit parallelization combined with wait commands to ensure that everything in that stage was complete before going to the next stage. That improved version now executes in around 600 seconds.
Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#17Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#18Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#19Started a new job working on a company's API team. The API had out of memory issues and had processes crashing all the time. The code was PHP. All API calls ended like this: echo json_encode($data) . "\n"; Changed just one character, the period to a comma so the string wasn't duplicated before being output. Problem solved. Felt like a hero.
Re: Ask HN: Largest speedup you ever achieved by only changing a few lines of code?
#20If you're working on Django codebases, `select_related` and `prefetch_related` are going to be your friends. Maybe 70-80% of Django slowness I've encountered (back when I did Django) was because of something issuing hundreds of db calls unnecessarily.