Slow memory allocation ( new/delete) under wine.

Questions about Wine on Linux
Locked
alon
Newbie
Newbie
Posts: 2
Joined: Mon Aug 26, 2019 1:13 am

Slow memory allocation ( new/delete) under wine.

Post by alon »

Hi,

I have a windows program I am trying to run under wine, I noticed it runs mush slower under wine.
I can reproduce this behavior in a small demo program. I know this program is not efficient, this is only to make a point.

This program runs at about 18 secs under windows, and 446 secs under wine.
when I run this program natively ( compiled with g++) it takes about 21 seconds, only slightly slower than windows.

Is there a way to improve memory allocation speed under wine?
Are there any additional runtime checks under wine, I can disable?

below is the windows code.

Regards,
Alon.

Code: Select all

#include <windows.h>
#include <omp.h>
#include <vector>
#include <tchar.h>

#define NUM_ALLOC 10000000

int do_work()
{
  int size = (rand() % 100)+10;
  int ret = 0;

  std::vector < std::vector<int>> TempBuffer(size);
  for (auto& it : TempBuffer)
    it.push_back(rand() % 100);
  for (auto& it : TempBuffer)
    ret += it[0];
  return ret;
}

int main()
{
  LARGE_INTEGER t1;
  LARGE_INTEGER t2;
  LARGE_INTEGER f;
  ::QueryPerformanceCounter(&t1);


  std::vector<int> Alloc(NUM_ALLOC);
#pragma omp parallel for schedule(dynamic,1)
  for (int i = 0; i < NUM_ALLOC; i++)
  {
    Alloc[i]=do_work();
    if ((i% (NUM_ALLOC/100))==0)
      _tprintf(_T("."));
  }

  ::QueryPerformanceCounter(&t2);
  ::QueryPerformanceFrequency(&f);
  _tprintf(_T("\nAlloc %lf \n"), ((double)(t2.QuadPart - t1.QuadPart)) / (double)f.QuadPart);

}

alon
Newbie
Newbie
Posts: 2
Joined: Mon Aug 26, 2019 1:13 am

Re: Slow memory allocation ( new/delete) under wine.

Post by alon »

answering to myself:

https://github.com/r-lyeh-archived/mall ... hreadalloc

Adding this to the project with REDEFINE_DEFAULT_NEW_OPERATOR defined does magic, in both windows and wine.
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: Slow memory allocation ( new/delete) under wine.

Post by DarkShadow44 »

Would you mind attaching a compiled binary? Because I can't reproduce the discrepancy here. But I'm using mingw, so maybe that's the issue.
Locked