-5

This is more of a Computer Engineering question, but what is the feature of a CPU to run Javascript fast? I use to access the internet with an AMD Phenom II with 6 cores and I could almost have as much tabs open and almost everything is instantaneous. Then for the past 3 or so years, I've been accessing the internet with laptops and netbooks, which were Intel Celerons and Atoms and i just isn't like before. Supposing AMD Phenoms are comparable with Intel Cores (i3, i5 or i7s), what exactly does make these more powerful CPUs faster with Javascript?

I've always assumed them as high performance threading (Hyper-threading in the case of Intel) and multi-coring. I've thought of branch prediction for a while, but I know that most of AMD's architectures aren't as aggressive in branch prediction compared to Intels.

But does SIMD (MMX, eMMX, etc) performance also count? Does GPU performance matter?

  • It'd vary, but I'd suspect that single-core performance is the biggest factor when comparing CPU's with the same architecture. This follows from most JavaScript engines basically being single-threaded. So, a gaming-computer CPU with a few fast cores will likely outperform an extremely expensive server CPU that has many cores. – Nat Jun 14 '17 at 5:43
  • What you just said does not make sense. – Dehbop Jun 14 '17 at 7:24
2

tl;dr- This is a complex, involved issue with a lot of variance. But for the sake of an answer here, CPU's with faster clock speeds are faster for JavaScript in most cases. Extra cores won't help much.

Very simplified answer

The full story's pretty involved and would be too much to fit into a short answer on StackExchange. Below, most of the statements are simplified, and shouldn't be taken as technically correct so much as to give a gist.

what is the feature of a CPU to run Javascript fast?

JavaScript programs are basically a series of instructions that the CPU executes in order. You want a CPU that executes those instructions fast. So, get a CPU with a fast clock rate.

I use to access the internet with an AMD Phenom II with 6 cores and I could almost have as much tabs open and almost everything is instantaneous. Then for the past 3 or so years, I've been accessing the internet with laptops and netbooks, which were Intel Celerons and Atoms and i just isn't like before.

Celeron's are cheap, low-end CPU's. Computers that contain them will generally be built from cheap, low-end parts. Atom's are meant to be small, portable, and low-power.

Neither will give you performance desktop results. That's not what they're for.

Supposing AMD Phenoms are comparable with Intel Cores (i3, i5 or i7s)

They're not. As far as I can find, they stopped making Phenom's quite a while ago, so they're old processors. AMD chips from 10 years ago aren't comparable to modern Intel i7's.

what exactly does make these more powerful CPUs faster with Javascript?

AMD Phenom's and Intel Core's use the same basic CPU architecture, x86-64, so we're able to compare them based on their metrics with some reasonable accuracy.

The big thing here is core speed, because JavaScript engines tend to be single-threaded which basically means that they only use one core. So if you've got a fancy million-core CPU, awesome, but it won't help you.

Variations in chip features (e.g. cache, pipelining, branch prediction) will cause further variation. Recently, Intel's been doing better than AMD with regards to this stuff, so Intel chips will tend to do better than comparable AMD chips with this sorta thing. Usually AMD helps to make up for this by offering more cores in their CPU's, which is great for other stuff, but irrelevant here.

I've always assumed them as high performance threading (Hyper-threading in the case of Intel) and multi-coring.

Nope. Lots of cores and Hyper-Threading-like features can be useful for multi-threaded workloads, but not most JavaScript stuff.

I've thought of branch prediction for a while, but I know that most of AMD's architectures aren't as aggressive in branch prediction compared to Intels.

Yup, that's a minor factor in Intel's favor. But, you can mostly ignore it for now since it's probably not as large as other factors.

But does SIMD (MMX, eMMX, etc) performance also count?

Depends on the JavaScript engine since that's what makes the choice between using those features or not. But, in general, I'd expect that, no, these aren't a major source of difference.

Does GPU performance matter?

Only if GPU acceleration's a bottleneck. I don't think that that's usually true for most JavaScript apps.

  • Don't forget better branch predictions and especially memory paging systems. Javascript is the kind of indirection – Alexander Jun 14 '17 at 20:26
  • If W3C won't draft a FULLY dynamic CSS version for interactive GUI, thus relieving Javascript the duty of creating interactive GUI, then you'd think web browsers will have some sort of "Javascript" compiler? Sure, it's a total waste of time if you consider that a fully dynamic CSS is an option, but nobody's even throwing around the idea. – Dehbop Jun 17 '17 at 7:02
  • @Dehbop It's been discussed, and there're some weird reasons that JavaScript compilation's received less attention than it might seem to merit at first. The big thing's that JavaScript's usually sent with webpages every time a user visits, so the goal's generally to optimize to reduce server load. If you compile, you can blow up the file size, plus compiling results in machine-specific instructions, which would put a major burden on the server to satisfy a whole bunch of different clients. – Nat Jun 17 '17 at 7:05
  • @Dehbop If you want to send compiled stuff, what you really need is some sort of compiled format that clients all recognize - some sort of common Assembly language that works across devices. This has been a major interest lately, and now Web Assembly's becoming standardized. – Nat Jun 17 '17 at 7:06
  • @Dehbop So, you're probably more interested in Web Assembly than JavaScript itself. Or, maybe there's a transpiler that converts JavaScript into Web Assembly, which would be pretty much exactly what you want. – Nat Jun 17 '17 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.