News for hackers. Stuff that matters.
Re:JavaScript Array.push is 945x faster than Array.concat by DrJokepu on Thursday May 23, 2019 @11:28AM (#19992630)
It really does depend on the implementation. Only the logical address space needs to be contiguous, not the underlying physical memory. A clever enough implementation could work hand-in-hand with a clever enough allocator, so that realloc would just add new logical pages to the end of the underlying buffer when it’s time to double its size without having to copy anything.
Re:JavaScript Array.push is 945x faster than Array.concat by seanmcdirmid on Thursday May 23, 2019 @11:51AM (#19992840)
Your virtual address space needs room for that, clever allocators can’t violate the laws of physics. Also, you can only do this at page size granules.

At any-rate, it’s not like copying will happen anyways during GC.

Re:JavaScript Array.push is 945x faster than Array.concat by skohan on Thursday May 23, 2019 @11:39AM (#19992724)
Is this really done? It seems like this approach would require all arrays to be allocated with at least a page's worth of memory, which seems incredibly wasteful if you have a bunch of small arrays with a handful of floats or something.
Re:JavaScript Array.push is 945x faster than Array.concat by Someone on Thursday May 23, 2019 @02:37PM (#19994553)
”It seems like this approach would require all arrays to be allocated with at least a page's worth of memory”

I don’t know whether it is done in practice, but you can postpone doing that until the array gets ‘big’, for some definition of ‘big’.

Re:JavaScript Array.push is 945x faster than Array.concat by BubRoss on Thursday May 23, 2019 @02:59PM (#19994792)
Allocating a bunch of small arrays is going to be wasteful (performance wise) anyway. That being said, I'm not sure if this is done frequently or not.