top | item 42523449

(no title)

laladrik | 1 year ago

> The author isn’t talking about implementing an ECS or b-tree here.

Do you mean that b-tree might work here better?

> They’re just populating an array from a file when the program launches, then freeing the whole thing when the program terminates. It’s really not rocket science.

That's exactly why I consider indices.

> since they assumed memory allocated by vec would be pinned (it isn’t)

Could you tell me, please, where you read in the article that I assume it? I wrote in the article "I realized that the problem is related to the fact that vectors of children move in the memory if they don't have enough space to extend." and even made an animation for clarity https://laladrik.xyz/VectorMove.webm. However, if you see the assumption in the article, please, let me know. I correct it or elaborate.

discuss

order

josephg|1 year ago

Yes, in your article you consider indexes then ultimately decide not to use them in favor of Vec<Box<T>> & pointers. I recommend that you use indexes instead. I think they’re the better choice.

> Could you tell me, please, where you read in the article that I assume it?

You assume it in your first attempt at solving this problem. You describe that attempt in detail. That’s what I’m referring to.

The code you ended up with is still dangerous code, because your boxes are still not guaranteed to remain pinned in memory.

laladrik|1 year ago

A clear. I hid it in my mind. I haven't tried the approach with indices, because... well, I was lazy to do it. However, I agree that this approach would be better, then the current one.

> You describe that attempt in detail.

I appreciate if you put a quote, because I fail to find the description of the attempt in detail. In fact, instead of assuming that a vector is pinned I wrote this "I realized that the problem is related to the fact that vectors of children move in the memory if they don't have enough space to extend."

> The code you ended up with is still dangerous code, because your boxes are still not guaranteed to remain pinned in memory.

You are right, boxes are not pinned, but the data, which the point to, is pinned, isn't it? My pointers point to that part of memory.