buying hardware to speed up your software

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

30 Replies - 3173 Views - Last Post: 24 July 2018 - 12:28 PM

#1 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 314
  • Joined: 14-February 17

buying hardware to speed up your software

Posted 20 May 2018 - 09:56 PM

Til now I've always succeeded in writing software which has taken less than 10 seconds to execute. But I can easily foresee a day in the future where it might take me 30 seconds to execute a code. All that time adds up and it is very damaging to morale. I'm not the type of guy that has a lot of money but still one of these days I'm going to have to invest in some equipment which will make my code run faster. How do I go about doing this? Right now, I have a Macbook Pro from Late 2011, 16 GB in memory, 2.2 GHz Intel Core i7 processor. Is it really worth buying a top of the line mac? Is there some sort of external harddrive that I can buy which will speed things up?

Is This A Good Question/Topic? 0
  • +

Replies To: buying hardware to speed up your software

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14425
  • View blog
  • Posts: 57,820
  • Joined: 12-June 08

Re: buying hardware to speed up your software

Posted 20 May 2018 - 10:30 PM

Where is the bottle neck? Disk io or processing?
Was This Post Helpful? 0
  • +
  • -

#3 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 314
  • Joined: 14-February 17

Re: buying hardware to speed up your software

Posted 20 May 2018 - 11:29 PM

don't know what you mean
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6451
  • View blog
  • Posts: 22,083
  • Joined: 05-May 12

Re: buying hardware to speed up your software

Posted 21 May 2018 - 04:27 AM

In general, finding a faster/better algorithm is the first recourse. That means understanding where the bottleneck(s) are. Is the code IO bound (e.g. are you waiting for the disk to read or write? do you have too much UI feedback where you are spending more time updating the UI instead of doing computational work?) Is the code CPU bound? (e.g. are you doing a lot of computations) Is the code memory bound? (e.g. do you use a lot of memory? Is the memory page faulting often effectively making you IO bound? Are you using CPU cache unfriendly data structures?)
Was This Post Helpful? 3
  • +
  • -

#5 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6698
  • View blog
  • Posts: 31,070
  • Joined: 10-May 07

Re: buying hardware to speed up your software

Posted 21 May 2018 - 04:50 AM

View Postbobsmith76, on 21 May 2018 - 12:56 AM, said:

But I can easily foresee a day in the future where it might take me 30 seconds to execute a code.


Based on what?

If this is a web application, have you looked into setting up a CDN? Load balancing?

Without knowing how it's going to slow down, it's difficult to suggest the best way to speed it back up.
Was This Post Helpful? 1
  • +
  • -

#6 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6451
  • View blog
  • Posts: 22,083
  • Joined: 05-May 12

Re: buying hardware to speed up your software

Posted 21 May 2018 - 05:01 AM

For the price of a top end MacBook, you could get a very good gaming laptop whose hardware can run circles around the MacBook. Are you willing to give up your Mac for that power, though?

As for your current hardware, you do know that MacOS deliberately slows down the CPU on the MacBooks to keep them cool, right? So ensuring that your intakes and vents are clean will help. Try bring it in to a pro to have it cleaned. A cooling laptop pad may help you if you do discover that it is the OS is slowing down your CPU to keep cool.

The MacOS also tries to conserve battery power. It'll slowdown your CPU to try to give you that legendary MacBook battery longevity. When you are doing your work, are you running on battery or are you plugged in?

If your machine currently does not have an SSD, bite the bullet and get one. Technically, it will only help with IO bound code, but for day to day use, you'll feel better about using your machine because you spend less time waiting for things to load and start running. Compiling and linking will also be faster.
Was This Post Helpful? 1
  • +
  • -

#7 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11224
  • View blog
  • Posts: 19,242
  • Joined: 19-March 11

Re: buying hardware to speed up your software

Posted 21 May 2018 - 08:08 AM

When did it start getting slow, and how did the slowness manifest? Was it a gradual degradation as you added features, or did it suddenly get bad after one change?
Was This Post Helpful? 1
  • +
  • -

#8 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 314
  • Joined: 14-February 17

Re: buying hardware to speed up your software

Posted 21 May 2018 - 02:53 PM

View PostSkydiver, on 21 May 2018 - 04:27 AM, said:

In general, finding a faster/better algorithm is the first recourse. That means understanding where the bottleneck(s) are. Is the code IO bound (e.g. are you waiting for the disk to read or write?

do you have too much UI feedback where you are spending more time updating the UI instead of doing computational work?) Is the code CPU bound? (e.g. are you doing a lot of computations) Is the code memory bound? (e.g. do you use a lot of memory? Is the memory page faulting often effectively making you IO bound? Are you using CPU cache unfriendly data structures?)


Thanks for your input. I've never taken a course in computer programming and I have trouble reading coding books so some of the jargon you're using is a bit strange to me.
Really, the only question I understood was: "are you doing a lot of computations". In that case, yes. I have been able to speed up the algorithm. For example, at one time in my career, just 6 lines out of 5000 were eating up 85% of the code. It was due to the deepcopy function, so I was able to work around that and speed up the code by a factor of 4. I'm using Python by the way. I know that Python is meant to be user friendly not fast, but I would not abandon Python for any other language currently available. I also know that you can drop down in C if you want to speed up the code but I'm not interested in learning C right now. Still, I am doing a lot of calculations. I am doing natural language processing, more specifically trying to calculate whether or not a given sentence is contradictory even though grammatical. Right now, I have a dictionary of about 100 popular words and another 300 technical terms. I then divide everything up into distinct predicates which right now is about 800. I then go through each combination of two predicates which is (800 * 800)/2 and calculate whether the two predicates can both be predicated of the same thing. Anyway you cut the cake, (800 * 800) / 2 is a lot of calculations. Right now, I can calculate 140,000 predicate combinations per second, which means the total time is 2.75 seconds but that number is only get slower as time goes on because I have not yet even explained how I justify whether the predicate combination is true or false. In the future I could very easily have 3000 predicate combinations. So sooner or later I'm going to have to find a way around this problem. For example, over at

https://corpus.byu.edu/now/

the guy downloads each night 5 million words worth of text and runs through it all and parses it for part of speech. It takes 4 hours. No amount of speeding up the algorithm is going to make that process quick and easy.

View Postjon.kiparsky, on 21 May 2018 - 08:08 AM, said:

When did it start getting slow, and how did the slowness manifest? Was it a gradual degradation as you added features, or did it suddenly get bad after one change?


I know what you mean, that's why I time each calcuation and whenever the time jumps up dramatically I look for the culprit and try to put a stop to it.

View PostSkydiver, on 21 May 2018 - 05:01 AM, said:

For the price of a top end MacBook, you could get a very good gaming laptop whose hardware can run circles around the MacBook. Are you willing to give up your Mac for that power, though?

Probably not. This is what Gates calls technological lock in.

Quote

As for your current hardware, you do know that MacOS deliberately slows down the CPU on the MacBooks to keep them cool, right?

No, as a matter of fact I did not. Thanks for the info.


Quote

So ensuring that your intakes and vents are clean will help. Try bring it in to a pro to have it cleaned. A cooling laptop pad may help you if you do discover that it is the OS is slowing down your CPU to keep cool.

The MacOS also tries to conserve battery power. It'll slowdown your CPU to try to give you that legendary MacBook battery longevity. When you are doing your work, are you running on battery or are you plugged in?

Usually the latter.

Quote

If your machine currently does not have an SSD, bite the bullet and get one.

This is exactly the type of advice I was looking for. I don't know what an SSD is but I found this article

https://9to5mac.com/...ld-mac-macbook/

And it seems that this is what I need.


Quote

Technically, it will only help with IO bound code, but for day to day use, you'll feel better about using your machine because you spend less time waiting for things to load and start running. Compiling and linking will also be faster.

Was This Post Helpful? 0
  • +
  • -

#9 Salem_c   User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2221
  • View blog
  • Posts: 4,304
  • Joined: 30-May 10

Re: buying hardware to speed up your software

Posted 22 May 2018 - 12:16 PM

Quote

Right now, I can calculate 140,000 predicate combinations per second, which means the total time is 2.75 seconds but that number is only get slower as time goes on because I have not yet even explained how I justify whether the predicate combination is true or false

Buying faster hardware will not solve your problem.

Every additional predicate is basically doubling the amount of time your program takes.

Even if you manage say an extreme x100 increase in performance, the brutal doubling nature of your code means you can only add 7 more predicates before you're back where you started.

You need to figure out what order your algorithm is -> https://rob-bell.net...big-o-notation/
My guess is it's something like O(Nē) based on what you describe.

If you want to run code which scales much better, you need a better algorithm. Throwing silicon and money at it won't help.
https://en.wikipedia...rting_algorithm
The archetype "bad boy" is bubble sort. It's dead easy to implement in it's naive simplicity, but it's absolutely awful in performance terms on any reasonable sized data set.
Was This Post Helpful? 4
  • +
  • -

#10 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6451
  • View blog
  • Posts: 22,083
  • Joined: 05-May 12

Re: buying hardware to speed up your software

Posted 22 May 2018 - 05:56 PM

Technically the combination 800C2 is only 800 * 799 / 2. Or generically nC2 is: n * (n-1) / 2. But yes, to the point, it is close enough to essentially give you a O(n2) if you need to check every combination.
Was This Post Helpful? 0
  • +
  • -

#11 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6451
  • View blog
  • Posts: 22,083
  • Joined: 05-May 12

Re: buying hardware to speed up your software

Posted 22 May 2018 - 06:02 PM

My gut feel is that if you used a database, you don't have to check all the combinations every time you pick up new predicates. You only need to check combinations of the old predicates with the new predicates added. You shouldn't have to re-check the combinations of the old predicates in combination with the old predicates.
Was This Post Helpful? 0
  • +
  • -

#12 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6451
  • View blog
  • Posts: 22,083
  • Joined: 05-May 12

Re: buying hardware to speed up your software

Posted 22 May 2018 - 07:16 PM

Also, if your predicates exhibit transitive properties then you may be able cut out a lot of comparisons. E.g. If A and B is true, and if B and C is true, then A and C should also be true if the predicates are transitive. Later when you compare C and X and discover that it is true, there is no need to test A and X and B and X.
Was This Post Helpful? 0
  • +
  • -

#13 CTphpnwb   User is online

  • D.I.C Lover
  • member icon

Reputation: 3802
  • View blog
  • Posts: 13,800
  • Joined: 08-August 08

Re: buying hardware to speed up your software

Posted 25 May 2018 - 10:35 PM

View PostSkydiver, on 21 May 2018 - 07:01 AM, said:

For the price of a top end MacBook, you could get a very good gaming laptop whose hardware can run circles around the MacBook. Are you willing to give up your Mac for that power, though?

I've been hearing this for years, but have never seen it in action. My MacBook Pro is a 2015 with a 2.5 ghz i7 and it's significantly faster than the PC laptop I'm using at work, which is a newer 2.8 ghz i7. Both have 16 GB RAM and SSDs. I use PHPStorm on both, and it's the PC that lags most with that, so I can't blame it all on Java. Some of it has to be Windows slowing things down.
Was This Post Helpful? 0
  • +
  • -

#14 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6451
  • View blog
  • Posts: 22,083
  • Joined: 05-May 12

Re: buying hardware to speed up your software

Posted 26 May 2018 - 06:03 AM

Let me guess: The PC has Symantec or McAfee running as AV software, while there is no AV software running on the Mac.

My personal laptop running on battery with a max speed of 2.1GHz and only 8GB of RAM used to out perform my old work laptop plugged in and running at 3.0GHz and 32GB RAM. The difference when both used to run Win7: I used Avast, while work used McAfee. Nowadays, my personal laptop is running Win10 with Avast (yes, I know the dangers of that combo with some of Spectre and Meltdown patches) is running circles around new work laptop has Win7 with McAfee AV, Symantec Endpoint, and McAfee Solidcore, and a bunch of other nannyware. For a while the same work laptop had Win10 and it finally out ran my personal laptop even with all the AV and nanny ware, but IT security and desktop engineering couldn't deal with the number of calls/tickets where the were incompatibilities between Win10 and their chosen AV and nanny ware, and the lockdown settings they wanted. (If you saw my Developer Mode post in the Corner Cubicle, that was one of the examples.)

Also, are you using Win7 or older on the PC? *nix tends to be less demanding on hardware with less stuff running. It was only at around the Win8 time that MS started looking at trimming all the excess because of the original plan to also run on ARM based devices with slower CPUs, as well as conserve energy. That is for desktop. In general, the Windows server platforms are more efficient than the desktop for to less stuff running by default, but as you alluded to, the Mac would still have even less than that due to its *nix origins.
Was This Post Helpful? 0
  • +
  • -

#15 CTphpnwb   User is online

  • D.I.C Lover
  • member icon

Reputation: 3802
  • View blog
  • Posts: 13,800
  • Joined: 08-August 08

Re: buying hardware to speed up your software

Posted 26 May 2018 - 07:45 AM

What you're saying amounts to: Windows has problems that add additional overhead. That's basically what I said. In the end it doesn't matter why it's slower. What matters is that it is slower.

It's Win 10, and some sort of AV (I could boot it up and get the full specs, but I'm not working now, and unless someone is paying me, I don't do Windows.) which is basically required on a PC. Macs may not be 100% immune, but they're secure enough, and software updates are both easy to do and usually come with security updates, so AV is really not necessary.

And speaking of updates: I HATE Windows updates. The other day it booted me out of something I was working on to do one. It popped up a notice with an ok/cancel type button setup, but while displaying that it forced quit all my apps! Heads would roll at Apple if the Mac OS did that.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3