Live data from Hacker News

Ask HN: What is your go to performance optimization?

news.ycombinator.com

11–20 of 47 posts

Re: Ask HN: What is your go to performance optimization?

#12
post #4

umm this is kinda tongue-in-cheek ``` #include #include int main(int argc, char argv[]) { int i = 0; time_t timep; /* * ok so now we are printing something **/ printf("Greetings!\n"); /* * this is a for loop from 0..9 **/ for(i=0; i } ``` now, the canonical ``` $> gcc tz-test.c -o obj/tz-test ``` now do this ``` $> unset TZ $> strace -ff ./obj/tz-test 2>&1 | grep 'local' | wc 10 77 851 $> export TZ=:/etc/localtime $>…

lol never knew about this thanks. Has this actually slowed down someone's code?

Re: Ask HN: What is your go to performance optimization?

#15
post #9

Reduce how often something runs and the amount of work it does when it does run. Sometimes, things are done too often, or process unnecessary data. I once had a project where a SAP system was crawling and literally causing company-wide stoppages. We found a job that literally ran every minute of every day and it processed a table that contained a few thousand tasks. This was something that could be done once per hour…

How it usually goes for me.

I ask business how often should something be updated - they say “real time” (not going into details what real time means really) - it is hard to explain processing all data all the time so everything is fresh takes forever….

After couple of months it turns out they never ever open their “super important dashboard” or do it once in 6 months.

Great after a year of bogging down everything I can clean up and make jobs run once a day instead of once a minute because now it is acceptable.

Re: Ask HN: What is your go to performance optimization?

#17
post #5

I've spent the last couple of years identifying and resolving N+1 problems in a Django codebase. https://planetscale.com/blog/what-is-n-1-query-problem-and-h... Aside from the performance gains, it's very satisfying to go from 1,000+ inefficient DB queries to 1-2 optimized queries.

That's a well written article. For developers newer to relational databases, there's a heuristic at the beginning which I remember hearing elsewhere and keeping it in mind when I'm doing query work.

"You might expect that many small queries would be fast and one large, complex query will be slow. This is rarely the case. In practice, the opposite is true."

Re: Ask HN: What is your go to performance optimization?

#19

The fastest code is code that isn't executed.

Related: do only what is necessary. This works on so many levels and is my magic trick to make software faster.

It's a pity computers are so fast and have so much memory that people can get away with not caring about minimalism.

Post reply on HN