> From: Mattias Rönnblom [mailto:hof...@lysator.liu.se] > Sent: Sunday, 7 August 2022 22.41 > > On 2022-07-29 18:05, Stephen Hemminger wrote: > > > > It makes sense in a few select places to use non-temporal copy. > > But it would add unnecessary complexity to DPDK if every function in > DPDK that could > > cause a copy had a non-temporal variant. > > A NT load and NT store variant, plus a NT load+store variant. :)
I considered this, but it adds complexity, and our use case only needs the NT load+store. So I decided to only provide that variant. I can prepare the API for all four combinations. The extended function would be renamed from rte_memcpy_nt_ex() to just rte_memcpy_ex(). And the rte_memcpy_nt() would be omitted, rather than just perform rte_memcpy_ex(dst,src,len,F_DST_NT|F_SRC_NT). What does the community prefer in this regard? > > > > > Maybe just having rte_memcpy have a threshold (config value?) that if > copy is larger than > > a certain size, then it would automatically be non-temporal. Small > copies wouldn't matter, > > the optimization is more about not stopping cache size issues with > large streams of data. > > I don't think there's any way for rte_memcpy() to know if the > application plan to use the source, the destination, both, or neither > of > the buffers in the immediate future. Agree. Which is why explicit NT function variants should be offered. > For huge copies (MBs or more) the > size heuristic makes sense, but for medium sized copies (say a packet > worth of data), I'm not so sure. This is the behavior of glibc memcpy(). > > What is unclear to me is if there is a benefit (or drawback) of using > the imaginary rte_memcpy_nt(), compared to doing rte_memcpy() + > clflushopt or cldemote, in the typical use case (if there is such). > Our use case is packet capture (copying) to memory, where the copies will be read much later, so there is no need to pollute the cache with the copies. Our application also doesn't look deep inside the original packets after copying them, there is also no need to pollute the cache with the originals. And even though the application looked partially into the packets before copying them (and thus they are partially in cache) using NT load (instead of normal load) has no additional cost.