RAM has become very slow low write speed and high latency

This is more of a long comment than an answer. Maybe it will stimulate other suggestions. The basic idea being to reserve and allocate memory such that sysbench then has to use a different area of memory for its memory block buffer to observe if the performance is the same over all memory.

The test system only has 32G of memory on 4X8G DIMMs.

First, just run sysbench normally, but increase the test duration enough for time to acquire some information while it executes:

doug@s19:~/c$ sysbench --test=memory --memory-block-size=4G --memory-total-size=512G --num-threads=1 --time=60 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.18 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Running memory speed test with the following options:
  block size: 4194304KiB
  total size: 524288MiB
  operation: write
  scope: global

Initializing worker threads...

Threads started!

Total operations: 128 (    3.05 per second)

524288.00 MiB transferred (12509.51 MiB/sec)


General statistics:
    total time:                          41.9101s
    total number of events:              128

Latency (ms):
         min:                                  327.22
         avg:                                  327.42
         max:                                  328.09
         95th percentile:                      325.98
         sum:                                41909.72

Threads fairness:
    events (avg/stddev):           128.0000/0.00
    execution time (avg/stddev):   41.9097/0.00

And during the 41 seconds that the test took to execute and in another terminal I did this:

doug@s19:~$ ps aux | grep sysbench
doug       10489 92.2 12.8 4227496 4204436 pts/1 Sl+  09:48   0:03 sysbench --test=memory --memory-block-size=4G --memory-total-size=512G --num-threads=1 --time=60 run
doug       10492  0.0  0.0   9040   732 pts/2    S+   09:48   0:00 grep --color=auto sysbench
doug@s19:~$ pmap 10489 | grep anon | grep " 4195"
00007f25cbb5a000 4195456K rw---   [ anon ]

I did the whole cycle a few times:

00007fa4bd7b4000 4195456K rw---   [ anon ]
00007f32c9878000 4195456K rw---   [ anon ]
00007f4837211000 4195456K rw---   [ anon ]

which shows we really don't know what memory is used or the mapping back to DIMM. Let's continue anyhow.

EDIT: the above can be made repeatable, by disabling Address Space Layout Randomization (ASLR):

sudo sysctl kernel.randomize_va_space=0

Now, reserve some chunk of memory so as to force the sysbench buffer to be allocated elsewhere. Someone might have a better idea, but I wrote a program:

doug@s19:~/c$ cat reservem.c
/*****************************************************************************
*
* reservem.c 2021.07.20 Smythies
*       allocate a chunk of memory for a while.
*       current use is to force another program to use a different area
*       of memory.
*       see also: https://askubuntu.com/questions/1352756/ram-has-become-very-slow-low-write-speed-and-high-latency
*       see slao testm.c from which this code started.
*
*****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(){
   char *fptr;
   long i, k;

/* Adjust as needed for use requirements */
   i = 8589934592;

   if(( fptr = (char *)malloc(i)) == NULL){
      printf("reservem: memory allocation failed, Exiting...\n");
      exit(-1);
   }
   while (( fptr == NULL) && (i > 0));
   for(k = 0; k < i; k++){   /* so that the memory really gets allocated and not just reserved */
      fptr[k] = (char) (k & 255);
   } /* endfor */
   printf("reservem: memory reserved and allocated. now sleeping...\n");
   sleep(180);  /* so other tests and observation can be done. Adjust as required. */
   free(fptr);
   printf("reservem: memory has been set free. Done and exiting...\n");
   return(0);
} /* endprogram */

Compiled it:

doug@s19:~/c$ cc reservem.c -o reservem

then ran it and then redid the previous steps while the memory block was reserved and allocated. Getting:

doug@s19:~$ ps aux | grep sysbench
doug       11324 93.8 12.8 4227496 4204340 pts/1 Sl+  13:58   0:09 sysbench --test=memory --memory-block-size=4G --memory-total-size=512G --num-threads=1 --time=60 run
doug       11327  0.0  0.0   9040   664 pts/2    S+   13:59   0:00 grep --color=auto sysbench
doug@s19:~$ pmap 11324 | grep anon | grep " 4195"
00007fc5f2df8000 4195456K rw---   [ anon ]

And for the memory reserved:

doug@s19:~$ ps aux | grep reservem
doug       11314 55.0 25.6 8391108 8389584 pts/0 S+   13:57   0:11 ./reservem
doug       11318  0.0  0.0   9040   740 pts/2    S+   13:57   0:00 grep --color=auto reservem
doug@s19:~$ pmap 11314 | grep anon | grep " 8388612K"
00007f11a6bfc000 8388612K rw---   [ anon ]

And:

524288.00 MiB transferred (12499.79 MiB/sec)

Similarly for reserving and allocating 2 and 3 times 8G:

doug@s19:~$ ps aux | grep reservem
doug       11335 85.0 25.6 8391108 8389704 pts/0 S    14:07   0:11 ./reservem
doug       11336 92.0 25.6 8391108 8389672 pts/0 S    14:07   0:11 ./reservem
doug       11340  0.0  0.0   9040   736 pts/2    S+   14:08   0:00 grep --color=auto reservem
doug@s19:~$ pmap 11335 | grep anon | grep " 8388612K"
00007fae2ce3f000 8388612K rw---   [ anon ]
doug@s19:~$ pmap 11336 | grep anon | grep " 8388612K"
00007f20cb627000 8388612K rw---   [ anon ]
doug@s19:~$ ps aux | grep sysbench
doug       11347 96.6 12.8 4227496 4204468 pts/1 Sl+  14:08   0:12 sysbench --test=memory --memory-block-size=4G --memory-total-size=512G --num-threads=1 --time=60 run
doug       11350  0.0  0.0   9040   740 pts/2    S+   14:08   0:00 grep --color=auto sysbench
doug@s19:~$ pmap 11347 | grep anon | grep " 4195"
00007f37dbe3c000 4195456K rw---   [ anon ]

and:

524288.00 MiB transferred (12521.74 MiB/sec)

3X:

doug@s19:~$ ps aux | grep reservem
doug       11388  100 21.0 8391108 6889064 pts/0 R    14:12   0:09 ./reservem
doug       11389  103 19.2 8391108 6292368 pts/0 R    14:12   0:08 ./reservem
doug       11390  100 16.3 8391108 5334328 pts/0 R    14:12   0:07 ./reservem
doug       11392  0.0  0.0   9040   724 pts/2    S+   14:12   0:00 grep --color=auto reservem
doug@s19:~$ pmap 11388 | grep anon | grep " 8388612K"
00007f2b83d2d000 8388612K rw---   [ anon ]
doug@s19:~$ pmap 11389 | grep anon | grep " 8388612K"
00007f2921e0c000 8388612K rw---   [ anon ]
doug@s19:~$ pmap 11390 | grep anon | grep " 8388612K"
00007f2a23f2b000 8388612K rw---   [ anon ]
doug@s19:~$ ps aux | grep sysbench
doug       11402  107 12.8 4227496 4204420 pts/1 Sl+  14:12   0:07 sysbench --test=memory --memory-block-size=4G --memory-total-size=512G --num-threads=1 --time=60 run
doug       11405  0.0  0.0   9040   672 pts/2    S+   14:12   0:00 grep --color=auto sysbench
doug@s19:~$ pmap 11402 | grep anon | grep " 4195"
00007fe64b54b000 4195456K rw---   [ anon ]

and:

524288.00 MiB transferred (12504.34 MiB/sec)

For reference, performance on this system verses memory-block-size:

Block-size: performance (MiB/sec):
256            2750.99
512            4937.70
  1K           8216.82
  2K          12290.93
  4K          16334.92
  8K          19498.37
 16K          21663.68
 32K          22514.94
 64K          23372.45
128K          23815.14
256K          23967.98
512K          24126.43
  1M          24226.70
  2M          24279.93
  4M          24310.19
  8M          23632.07
 16M          20622.04
 32M          16149.71
 64M          14206.06
128M          13303.15
256M          12853.12
512M          12720.34
  1G          12584.68
  2G          12538.66
  4G          12502.66
  8G          12490.63
 16G          12482.25