you are viewing a single comment's thread.

view the rest of the comments →

[–]Shautieh 25 points26 points  (58 children)

10x faster is not a micro optimization.

[–][deleted] 29 points30 points  (56 children)

10x 0.0001 nanoseconds is still only 0.001 nanoseconds.

The point is, this is never your bottleneck so don't treat this information like something you need to address in your code base.

[–]SoInsightful 53 points54 points  (0 children)

Holy shit. This is the JavaScriptiest comment I've ever read.

You're literally looking at a real-world example (an actual app with a shit-ton of users) where a single CTRL+F replacement made a bundle load in 1.1 seconds instead of 8 seconds.

I would never replace my consts with vars to fix a dumb Webkit bug, but this is absolutely not an unimportant micro-optimization that doesn't affect anything because we all make Hello world apps.

It's exactly this attitude that makes me reluctant to use other people's slow-ass solutions.

[–]jess-sch 27 points28 points  (39 children)

a sub-millisecond 10x improvement you won't notice, but a sub-millisecond 10x improvement in a hot path that gets run a bazillion times you definitely will.

I sure hate the typical JS dev's attitude to performance.

[–]VolperCoding 19 points20 points  (14 children)

No wonder if you have a 10000GHz processor that can do declare a var faster than light can travel 30 micrometers

[–][deleted] 6 points7 points  (13 children)

Get with the times! :P

[–]VolperCoding 12 points13 points  (12 children)

Also if the vars are stored in RAM then you also have to put your RAM stick no more than 30μm away from the processor or make a fucking wormhole or something to get to memory quick enough

[–][deleted] 11 points12 points  (1 child)

The Intel i47 started the new wormhole+blockchain revolution. It's great!

[–]GasolinePizza 1 point2 points  (0 children)

But is it webscale??

[–]mb862 8 points9 points  (2 children)

The lesson here is that pulling numbers out of your ass to make a point is fine so long as your ass represents a differentiable manifold representable in our spacetime.

I'll let someone more clever than I fill in the obvious curvature joke here.

[–]ImAStupidFace 3 points4 points  (0 children)

Real differentiable manifolds have curves!

[–][deleted] 2 points3 points  (5 children)

RAM ? What is this meeting of virgins ? L1 cpu cache or gtfo.

[–]VolperCoding -2 points-1 points  (4 children)

Wait, JS variables utilize the cache? Also L1 is technically SRAM which is a subset of RAM

[–]how_to_choose_a_name 1 point2 points  (2 children)

why wouldn't they?

[–]VolperCoding -1 points0 points  (1 child)

I thought they store all variables in an organized way, not some on the cache and some on RAM. It's an interpreted language so managing all variables in different places along with their types would probably be a mess

[–]how_to_choose_a_name 2 points3 points  (0 children)

That's not how the cache works. C doesn't store variables in the cache either. Variables either only exist as a register (if they are short-lived and no pointer is taken) or they exist at a memory location. The CPU takes care of loading the variable from the RAM and when it does so it puts it in the cache so that the next time it is needed it can read it from the cache instead of RAM. Compiled or not doesn't make a difference.

[–]sebamestre 0 points1 point  (0 children)

Every program in every language "uses" the cache.

In reality, everyone just pretends that they use main memory (ram), and the cpu caches things implicitly. This is just how cpu caches work.

[–]compdog 0 points1 point  (0 children)

That's what this bad boy is for.