Lurker News
I'm very interested in what types of interesting data structures are out there HN. Totally your preference.

I'll start: bloom filters. Lets you test if a value is definitely NOT in a list of pre-stored values (or POSSIBLY in a list - with adjustable probability that influences storage of the values.)
Good use-case: routing. Say you have a list of 1 million IPs that are black listed. A trivial algorithm would be to compare every element of the set with a given IP. The time complexity grows with the number of elements. Not so with a bloom filter! A bloom filter is one of the few data structures whose time complexity does not grow with the number of elements due to the 'keys' not needing to be stored ('search' and 'insert' is based on the number of hash functions.)
Bonus section: Golomb Coded Sets are similar to bloom filters but the storage space is much smaller. Worse performance though.

Comments (753) 253 threads

Show all comments

Showing thread 135 of 253

winReInstall1 reply#
Input, Output Unionnions. basically a input struct into a algorith, layed out in such a way, that the algorithms output, always only overwrites input no longer needed. If done well, this allows for hot-loops that basically go over one array for read & write-backs. After all, its all just memory and to use what you got in situ is the fastet way one can go.

No pointers to dereference and wait, just the input, computated, stored back into the same cacheline- to be used for the next part of the hot loop. If the hot-loop is multi staged and the output continously decreases in size, one can even "compress" the data, by packing an array of orgMaxisze/outputSize subunits into the unit.

TristanBall1 reply#
Do you have any references for this? I'd like to understand better
winReInstall#
https://hackaday.com/2018/03/02/unionize-your-variables-an-i...

https://en.wikipedia.org/wiki/Test-driven_development
This is unsafe C Code by nature, but test driven development on platform can make it "safe".
Now you start with a struct in the union: {inputA, inputB, inputC}
and pad the intermediate struct
{Padding against Overlap, resultB, result C}
and end up with the result struct in the same union.
{outputA, outputB, outputC} .
The trick is to keep track of the state and validate the "purity" via automated tests.
Then you have it all in one L1 Cache Line, pumping through a algo, no dereferences, no huge stack structures, its all there, as long sas the size of input output does not differ wildly.
Remember down there its all just bytes accessed by code. There is no such concept as objects or even variables. All those mental pots to grab things out and put things back in, are artificial constructs needed by us.
The machine down there, can go to work like a line cooking shiva in a trailer. And doing so and having this in view, makes it faster.
PS: Pointers within the struct nullifys the advantages gained here, because every pointer is a memory load and thus "relatively" slow.