4 ms·
Cool idea, but sounds detrimental in terms of cache efficiency. Typically processing a string by reading it sequentially is quite cache efficient as the process
by cherryteastain 2y ago
Cool idea, but sounds detrimental in terms of cache efficiency. Typically processing a string by reading it sequentially is quite cache efficient as the processor will prefetch, but with this method it seems like the string will not be contiguous in memory which will lead to more cache misses.
- SwiftyBug 2y agoSeems like the classic trade-off of compute time x memory.
- pimeys 2y agoIt's quite common if you need to parse a schema and keep it in memory for a long time. We're working on GraphQL federation gateway and interning strings is really useful there due to schemas sometimes being hundreds of megabytes. Writing your own interner is under hundred lines of code and takes about 15 minutes. Writing a thread-safe interner is a bit trickier problem, but there are good libraries for that.
- ctz 2y agoLots of small strings sparsely spread over 282MB is pretty cache inefficient? Whereas the separate small allocations will likely end up close together, which gives a better chance that a given cache line will contain several rather than just one.