

Ask HN: What are the best optimizations you have made? - elwell

I recently added an index to a relatively large MySQL table that made a certain function go from taking about 15 seconds to less than 0.1 seconds.
======
professorTuring
I have changed the terrible workflow of the team I'm into. This is a group of
developers which development process was the following for more than 15 years:

1\. Programming with ultra-edit or similar on windows.

2\. Never use a library (like STL, boost, libxml, qt...). Big "not invented
here" problem.

3\. Never thinking about design. Just getting the work done quick and dirty.

4\. Copying the code to a remote Linux machine and compile with aged make
scripts nobody understands.

5\. Go through the whole development cycle without making a commit.

6\. Integrate the set of changes from different developers (a huge task in
this stage).

7\. Not keeping track of bugs or tasks.

8\. One meeting each 3 or 4 months.

It has been a job of years (I'm just one more into the team, I'm not the
manager and I am the youngest and the last to arrive). I have completely
changed their mentality about the development, now they:

1\. use a modern I.D.E. (eclipse and qt creator).

2\. use an automated tool to sync their code against the remote machine
(winscp).

3\. commit changes everyday and they integrate all changes everyday.

4\. use Trac to keep tracking of the issues and milestones.

5\. are starting to use the STL and they are willing to learn Qt and boost.

6\. are using Jenkins to automate the compiling and testing process.

7\. make code reviews and sometimes pair programming.

8\. We meet every two weeks to discuss the status of the project.

The question may be: how I made it?

Like two years ago I asked my boss to be the responsible for the configuration
management (a part of the enterprise had already implemented good development
practices, but in this enterprise my team is like an independent republic). So
I wrote some practices that I believed fitted the team and begin to apply them
one at a time. I was very flexible about them (anyway I don't have the power
to force my mates apply them).

Later I talked to my boss again and I told her that I wanted to take more
responsibility into the team, I told her that I consider myself a great
developer and that I was being given only small tasks to make with the team or
big projects to do by myself. She acknowledged and gave me the biggest project
(in which I'm currently working). With this project I took my chances and
began a big refactorization of the old code (believe it is bad as hell). I
could add some design patterns and explain them a few more, add some
libraries... I know they trust me now much more than before but also they
think I am a bit burdensome with all these changes...

Not everything is shiny and colorful anyways. My boss got promoted with more
responsibility and one of my team colleagues got the promotion to lead the
team (the organization is very big and old fashioned I had not even a chance
to get the promotion, before giving it to me all of my colleagues should be
retired).

I am very proud of myself achieving this great change into this big and slow
enterprise, this change in the mentality of my coworkers. And I do have been
rewarded with salary raises. I have greatly boosted the productivity of the
team.

I consider there is still a lot to do [my coworkers should be trained better
to do their everyday work (improve their c++ skills, they OO design ability,
get to know more tools...), add development metrics, static testing tools...
], but it is a bit frustrating and difficult continuing making changes without
the "manager title" and having to fight every battle against my coworkers.

Now I have asked for changing my role inside the enterprise to the Security
Team (after finishing my Master Degree in Information Security) where I
believe I can improve it in the same way I have improved this team (every
department has bad relations with the security team because the manager is
very theoretical and un-pragmatic) so I am sure I will be handy.

Or maybe I will find a CTO or CISO position in an startup =)

Edited: grammar and typos...

Since English is not my mother tongue any corrections are appreciated.

------
iSloth
I worked for a hosting company doing loads of boring provisioning stuff on
servers and the core network, not really a fan of repetition so I started to
slowly learn coding and replaced probably 80% of the jobs with scripts. So in
total I coded away most of my daily work, although there was plenty more to be
getting on with ;)

~~~
wikwocket
Always love stories like this. I never realized the truth of the expression
"Go away or I will replace you with a very small shell script" until I started
writing shell scripts!

Stories like this can be inspirational, and they reinforce one of my favorite
mottoes about computing: "Computers should work; people should think." Have
the machines do the rote calculations, and free people to work on challenging
creative tasks.

------
penguinlinux
Tweaked the caching layer for one of the busiest technology media site on the
Internet. using only 2 varnish servers I was able to front millions of hits to
5 web back end nodes running wordpress. The configuration for varnish was
tweaked so good that we even considered dropping Akamai.

------
tsahyt
No specific examples, but all of my best optimizations as in biggest-speedup
were of algorithmic nature that actually improved asymptotic complexity.

In terms of my favorite ones, it's probably a piece of C code using SSE
intrinsics to speed up intersection checking for a voxel raytracer I've been
playing with last summer. After about 1.5 days of hacking I've managed to
shave about 50% off the rendering time per frame. Nice learning experience but
completely pointless in the end. Since it was still way too slow for any
practical use, I started rewriting it and eventually stopped halfway through.

------
bret_maverick
Rewrote a process which took 6 hours to finish to a process which takes 1
minute to finish by using some basic data structures (like a tree).

------
mattwritescode
SQL server, query taking 24 minutes to run on a good day, when going down hill
wind assisted.

Made a few small alterations and got the query running in sub 1 second. Boss
had to have the code vetted 3 times because he could not believe it.

You have to take into consideration that it was originally written by an
absolute muppet, and then altered by an `database expert`.

------
japhyr
I take written notes in staff meetings when I see the same shit being
discussed over and over again.

When the subject comes up again I say, "We've been through this before. Does
anyone have anything new to add?"

Then we either pick up where we left off, or move on to more important issues.

------
mrlyc
The best optimisation I made was rewriting 2,650 lines of C as a seven line
shell script. The previous programming team had written a data transfer
program with its own implementation of ftp. I just used the one that was
already on the computer.

------
agibsonccc
Change my matrix library to a BLAS binding for machine learning. 150x speedup

------
sdogruyol
Just yesterday i made 2 slow MySQL queries perform nearly 100x faster by
replacing the reckless JOINs with smart subqueries.

------
kranner
Replaced a naïve very large chart-drawing function in an iOS app with an
implementation that uses CATiledLayer.

