Pro-tip. Ever wonder what a structure _actually_ looks like in memory when it's full of unions, typedefs, etc? The `pahole` command (from the `dwarves` package) can take in an ELF with DWARF symbols and output the structures unrolled recursively. Example:https://gist.github.com/gamozolabs/0ec182194706b6e0a3a1ee1a5ae09e17 …
-
-
Odgovor korisnicima @gamozolabs @thegrugq
Do I really *need* to know what a struct actually look like in memory? That is: isn’t it enough to understand the semantics of the struct and operate on that?
1 reply 0 proslijeđenih tweetova 0 korisnika označava da im se sviđa -
even outside re/exploitation, consider cache effects, plus finding out how much space alignment padding wastes (pahole's original purpose)
1 reply 0 proslijeđenih tweetova 0 korisnika označava da im se sviđa -
What I’m saying is that, professionally, I’ve found myself rarely having to worry about space wastage
What I didn’t say is also that discovering how a structure is mapped into memory leads to the (wrong!) conclusion, more often than not, that one can just cast a struct... 1/21 reply 0 proslijeđenih tweetova 0 korisnika označava da im se sviđa -
Odgovor korisnicima @bertrandmt @XMPPwocky i sljedećem broju korisnika:
... into a byte pointer for the purpose of “serializing” the struct. This kind of approach is an abomination that has no place outside extremely specialized contexts that the common developer is unlikely to encounter.
1 reply 0 proslijeđenih tweetova 0 korisnika označava da im se sviđa -
Odgovor korisnicima @bertrandmt @XMPPwocky i sljedećem broju korisnika:
It's not just about struct holes, think about false sharing, for instance.
0 proslijeđenih tweetova 1 korisnik označava da mu se sviđa -
Odgovor korisnicima @acmel @XMPPwocky i sljedećem broju korisnika:
Ok, just to make sure I understand what you are saying: once you’ve detected false sharing, you resolve it by “placing” your variables in memory, and you do that with struct management?, which you check with pahole & co.?
1 reply 0 proslijeđenih tweetova 0 korisnika označava da im se sviđa -
Odgovor korisnicima @bertrandmt @XMPPwocky i sljedećem broju korisnika:
Yes, one can use visual inspection, look at the codepaths, find related fields, move them around so that related fields share a cacheline, rebuild your software, use pahole to see the result. Then run it and use 'perf stat' to check if there is a reduction in cache misses, etc.
1 reply 0 proslijeđenih tweetova 0 korisnika označava da im se sviđa
Take a look at this Linux kernel commit by @edumazet, that has pahole output describing some field reorganizations that resulted in ~20% UDP speedup in some scenario: https://git.kernel.org/torvalds/c/9115e8cd2a0c6ea … #pahole #linux
-
-
Odgovor korisnicima @acmel @XMPPwocky i sljedećem broju korisnika:
Fascinating. Also... completely irrelevant for my day to day, which explains my initial skepticism
Not all of us get to be kernel warriors!
At any rate, thanks for the explanations.0 replies 0 proslijeđenih tweetova 0 korisnika označava da im se sviđaHvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.