News for hackers. Stuff that matters.
Re:Go Performance Tales by logicchains on Thursday April 17, 2014 @07:16AM (#7602906)
This is probably a stupid question, but I wonder if the author could have used slices instead of maps with integer keys. It would have used more memory, but it would probably also have been significantly faster. A significant proportion of the performance issues I see raised on the Go mailing list seem to involve maps.
Re:Go Performance Tales by cronos on Thursday April 17, 2014 @07:34AM (#7602964)
Probably no. Author says that he uses IDs as keys. I can assume that they are 32 or 64 bit long. So even if they are 32 bits, you would need a 4GB slice to hold any potential key. Or make a dynamic array (well, slice) that would give even more overhead than a map (and would closely resemble what map does internally better anyways). So only if those keys were really small, that would be a possible alternative.
Re:Go Performance Tales by awda on Thursday April 17, 2014 @08:25AM (#7603136)
If 'select min(keycolumn) from footable' is relatively stable and keys are created ascending (databases do this, right?), a resizing slice (with 0-min() elided from the bottom) seems like a good alternative to a hashing structure.

If the key-space is relatively sparse, this will waste more memory than the hash, of course.