• Re: Scanning memory forward vs. reverse

    From Marcel Mueller@21:1/5 to All on Sun Jan 28 11:32:56 2024
    Am 28.01.24 um 11:19 schrieb Bonita Montero:
    A deque usually consists of a number of linear parts in memory. This
    lead me to the question if scanning memory is faster forward or back-
    ward. I tried to test this with the below program:

    On my Windows 7050X Zen4 computer scanning memory in both directions
    has the same speed. On my Linux 3990X Zen2 computer scanning forward
    is 22% faster. On my small Linux PC, a HP EliteDesk Mini PC with a
    Skylake Pentium G4400 scanning memory forward is about 38% faster.

    I'd first have guessed that the prefetchers between the memory-levels
    are as effective for both directions. So I'd like to see some results
    from you.

    Reverse memory access is typically slower simply because the last data
    of a cache line (after a cache miss) arrives at last. If you read
    forward the process continues when the first few bytes of the cache line
    are read. The further data is read in parallel.

    But details depend on many other factors. First of all the placement of
    the memory chunks and the used prefetching technique (if any).


    Marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vir Campestris@21:1/5 to Bonita Montero on Wed Jan 31 15:56:01 2024
    On 28/01/2024 10:19, Bonita Montero wrote:
    On my Windows 7050X Zen4 computer scanning memory in both directions
    has the same speed. On my Linux 3990X Zen2 computer scanning forward
    is 22% faster. On my small Linux PC, a HP EliteDesk Mini PC with a
    Skylake Pentium G4400 scanning memory forward is about 38% faster.
    I'd first have guessed that the prefetchers between the memory-levels
    are as effective for both directions. So I'd like to see some results
    from you.

    On my Linux box with an AMD Ryzen 5 3400G it's about 11% slower for the
    second number. But that's a very about, it's doing something else right
    now and that's the average from several runs - where the ratio is
    between 97% and 130%.

    Andy

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)