3 ms·
I would never write something like this in java, but to be fair, a program shouldn't be written like this in the first place. If you "need" a billion strings in
by CyberDildonics 5y ago
I would never write something like this in java, but to be fair, a program shouldn't be written like this in the first place. If you "need" a billion strings in memory and you didn't design for that with something that would scale better, you messed up a long time ago.
- marginalia_nu 5y agoHuh, I didn't really have a problem solving the problem as it came up. Like many scaling problems, it wasn't a problem until it was. Then I fixed it. Now I have a solution that can deal with ten times as many strings as before. If I grow out of that one, I'll come up with a better design. I could have gotten 10 times as much hardware instead, but that would be an incredible waste of money compared to just spending a few days writing more hardware-efficient code.
- sitkack 5y agoI have addressed similar problems using a typed array of contiguous memory and another array of lengths.
- marginalia_nu 5y agoI did try exactly that, but the GC overhead was still prohibitively high for my use case, made because big arrays in practice are composed from shorter non-contiguous arrays to make garbage collection even remotely possible.
- sitkack 5y agoHmmm, if the typed array only contains primitives, the GC isn't looking inside the array. If the thing pointed to, can never contain a pointer, it won't need to be scanned.