Hacker News new | past | comments | ask | show | jobs | submit login

Do you have any references for this? I'd like to understand better



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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: