Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

337
Visualizações
How can I prevent compiler and JIT optimization from breaking my hardware test in java?

I recently found out that bits in DRAMs can be randomly flipped by the decay of particles in it or by cosmic rays. And I wondered how often this errors occur.

Unfortunately, the most recent statistic I found is from the year 1990 (source), which states that an error should occur every month per 128MB of memory.

Since I couldn't find any recent statistic of soft error rates in modern RAMs, I tried to write a program in java to measure the soft error frequency on 4GB of my RAM. I expect the program to work to detect every soft error in the allocated 4GB of RAM, if it weren't optimized in any way.

The problem is, I have no idea how to check if the program works (I assume it doesn't because of optimization), and I don't know how to change it to work as expected.

Based on the 1990's statistic I should expect to detect an error every 22 hours, thus I would need to run the program for almost a week to state with a 99% confidence that it works. Assuming that modern hardware doesn't have a better soft error rate than in the 90s.

The following loop is the most important part of my program:

int[] memory = new int[1_073_741_824]; // 4GB array, each value initialized to 0
while (true) {
   for (int i = 0; i < memory.length; i++) {
        if (memory[i] != 0) {
            // soft error found
            memory[i] = 0;
            // print information about the error in a log file
        }
    }
    // Sleep for a minute
}

What can I do to avoid optimization to break the intended use of the program?

P.S. If you think that my code wouldn't even work without optimization, please explain why.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Simple: as soon as your loop body does something (like just printing the index it failed on) , optimizing away the loop body would be invalid!

And if at all, it would be the JIT optimizing away things, javac is not doing much more than constant folding in regard of optimizations.

But of course, you would be on the safe side using languages where you have full control over such things.

Beyond that: I rather doubt that you will ever hit an error with such code.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda