Выигрыши в производительности строгого искажения

Скорее всего, он пытается загрузить данные во временную папку / tmp. Я предполагаю, что настройки по умолчанию (обычно половина вашей оперативной памяти) слишком малы для обработки загрузки.

Вы можете отключить монтирование tmp с помощью следующей команды: systemctl mask tmp.mount. Будьте внимательны и сделайте свое исследование, прежде чем делать это.

В качестве альтернативы вы можете установить каталог TMPDIR на /var/tmp, выполнив следующее export TMPDIR='/var/tmp'

17
задан emlai 20 December 2015 в 16:11
поделиться

1 ответ

There is a page that describes aliasing very thoroughly here.

There are also some SO topics here and here.

To summarize, the compiler cannot assume the value of data when two pointers of different types are accessing the same location (i.e. it must read the value every time and therefore cannot make optimizations).

This only occurs when strict aliasing is not being enforced. Strict aliasing options:

  • gcc: -fstrict-aliasing [default] and -fno-strict-aliasing
  • msvc: Strict aliasing is off by default. (If somebody knows how to turn it on, please say so.)

Example

Copy-paste this code into main.c:

void f(unsigned u)
{
    unsigned short* const bad = (unsigned short*)&u;
} 

int main(void)
{
    f(5);

    return 0;
}

Then compile the code with these options:

gcc main.c -Wall -O2

And you will get:

main.c:3: warning: dereferencing type-punned pointer will break strict-aliasing rules

Disable aliasing with:

gcc main.c -fno-strict-aliasing -Wall -O2

And the warning goes away. (Or just take out -Wall but...don't compile without it)

Try as I might I could not get MSVC to give me a warning.

19
ответ дан 30 November 2019 в 13:54
поделиться
Другие вопросы по тегам:

Похожие вопросы: