U++ framework
Do not panic. Ask here before giving up.

Home » Community » U++ community news and announcements » Core 2019
Re: Core 2019 [message #51934 is a reply to message #51926] Fri, 21 June 2019 19:58 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Fri, 21 June 2019 03:23
Anyway, peak and final memory profiles would be nice to know... Smile

(Although one problem is that only calling thread's memory is in the profile).

I've attached a profile ...


Regards,
Novo
Re: Core 2019 [message #51935 is a reply to message #51934] Fri, 21 June 2019 20:28 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
My version of libc:

$ /lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Ubuntu GLIBC 2.29-0ubuntu2) stable release version 2.29.


Regards,
Novo
Re: Core 2019 [message #51936 is a reply to message #51935] Sat, 22 June 2019 02:51 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
U++, RSS, collected as "top -d 0.5".

index.php?t=getfile&id=5864&private=0
  • Attachment: upp.png
    (Size: 26.27KB, Downloaded 1076 times)


Regards,
Novo
Re: Core 2019 [message #51937 is a reply to message #51936] Sat, 22 June 2019 02:53 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
glibc, RSS, collected the same way.

index.php?t=getfile&id=5865&private=0
  • Attachment: glibc.png
    (Size: 42.89KB, Downloaded 935 times)


Regards,
Novo
Re: Core 2019 [message #51938 is a reply to message #51937] Sat, 22 June 2019 10:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Well, from what I see, the real difference is that U++ "keeps" the address space...

Maybe you can strace both allocators and grep for mmap / munmap?

Also, profile after the CoWork would be nice to know.

Mirek

[Updated on: Sat, 22 June 2019 10:57]

Report message to a moderator

Re: Core 2019 [message #51939 is a reply to message #51938] Sat, 22 June 2019 17:49 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Sat, 22 June 2019 04:23
Well, from what I see, the real difference is that U++ "keeps" the address space...

Maybe you can strace both allocators and grep for mmap / munmap?

Also, profile after the CoWork would be nice to know.

Mirek


Attached.
Just mmap and munmap do not tell much.
glibc calls brk a lot as well.
Profile after the CoWork was posted in this message.


Regards,
Novo
Re: Core 2019 [message #51940 is a reply to message #51939] Sat, 22 June 2019 22:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Sat, 22 June 2019 17:49

Profile after the CoWork was posted in this message.


I believe that is just peak profile, but I might be looking at it wrong.

strace logs seem weird a bit - I do not see enough allocations (either way) for 4GB.
Re: Core 2019 [message #51941 is a reply to message #51940] Sat, 22 June 2019 23:44 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Sat, 22 June 2019 16:22

I believe that is just peak profile, but I might be looking at it wrong.

What is "Profile after the CoWork"? I do know only about MemoryUsedKb(), MemoryUsedKbMax(), PeakMemoryProfile() ...
In this log-file all three of them are called after CoWork.

mirek wrote on Sat, 22 June 2019 16:22

strace logs seem weird a bit - I do not see enough allocations (either way) for 4GB.

My bad. I didn't follow the threads ...
New logs are attached.
  • Attachment: 02.zip
    (Size: 419.52KB, Downloaded 317 times)


Regards,
Novo
Re: Core 2019 [message #51942 is a reply to message #51941] Sun, 23 June 2019 08:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Sat, 22 June 2019 23:44
mirek wrote on Sat, 22 June 2019 16:22

I believe that is just peak profile, but I might be looking at it wrong.

What is "Profile after the CoWork"? I do know only about MemoryUsedKb(), MemoryUsedKbMax(), PeakMemoryProfile() ...
In this log-file all three of them are called after CoWork.


"MemoryProfile()" Smile

The differnce is that PeakMemoryProfile returns snapshot at point where maximum memory is allocated, while "MemoryProfile" returns current status.

Mirek
Re: Core 2019 [message #51943 is a reply to message #51941] Sun, 23 June 2019 09:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Sat, 22 June 2019 23:44

My bad. I didn't follow the threads ...
New logs are attached.


Well, GCC definitely unmaps regions before mapping them back again, so the original hypothesis holds.

Now the interesting question is "are we doing something wrong?". Perhaps we do... Maybe 224MB is too big chunk and it is true that it will waste swap space....

Mirek
Re: Core 2019 [message #51944 is a reply to message #51943] Sun, 23 June 2019 10:19 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
It would probably be worth to experiment with HPAGE constant... Can be any number >16.

Mirek

Re: Core 2019 [message #51946 is a reply to message #51942] Sun, 23 June 2019 21:26 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Sun, 23 June 2019 02:21

"MemoryProfile()" Smile

Attached Embarassed


Regards,
Novo
Re: Core 2019 [message #51947 is a reply to message #51944] Mon, 24 June 2019 06:13 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Sun, 23 June 2019 04:19
It would probably be worth to experiment with HPAGE constant... Can be any number >16.

I'm afraid I cannot afford to spend time on U++'s allocator anymore.
I'm switching to the glibc's one for the time being.
It would be great to see jemalloc and tcmalloc integrated into U++ because they are supposed to be better at avoiding fragmentation.


Regards,
Novo
Re: Core 2019 [message #51949 is a reply to message #51946] Mon, 24 June 2019 09:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Sun, 23 June 2019 21:26
mirek wrote on Sun, 23 June 2019 02:21

"MemoryProfile()" Smile

Attached Embarassed


Huge block count 4, total size 1951 KB
Huge fragments count 424, total size 4810724 KB

Basically means that all the memory is really freed, as expected. Fragments list also reveals that fragmentation is not really too bad (a lot of big blocks).

Based on this, I do not see any defect or deficiency, except the choosen one (keep the memory).

Mirek
Re: Core 2019 [message #51950 is a reply to message #51949] Mon, 24 June 2019 17:36 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Mon, 24 June 2019 03:22

Based on this, I do not see any defect or deficiency, except the choosen one (keep the memory).

Well, I do not think that taking from the system 4.6Gb when the app is allocating ~400Mb is acceptable. Cool
Default behavior of glibc's allocator is optimized for huge enterprise-level apps, but with some manual tweaking it performs fine with small apps. jemalloc would perform even better, I believe.


Regards,
Novo
Re: Core 2019 [message #51951 is a reply to message #51950] Mon, 24 June 2019 18:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Mon, 24 June 2019 17:36
mirek wrote on Mon, 24 June 2019 03:22

Based on this, I do not see any defect or deficiency, except the choosen one (keep the memory).

Well, I do not think that taking from the system 4.6Gb when the app is allocating ~400Mb is acceptable. Cool
Default behavior of glibc's allocator is optimized for huge enterprise-level apps, but with some manual tweaking it performs fine with small apps. jemalloc would perform even better, I believe.


Well, app actually IS allocating ~4.5 GB at the peak, that is what all indicators show - or have I got that wrong?

So it is really a question of priorities. Do we want to unmap that memory or keep it for the future use as mmap/munmap are quite expensive calls? This was the question I have asked and at that time the answer was: "we want to keep it". Now I am not so sure... Smile

Looks like we need MemoryOptions and/or MemoryShrink...

Anyway, back to drawing board...

Mirek
Re: Core 2019 [message #51952 is a reply to message #51951] Mon, 24 June 2019 19:36 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Mon, 24 June 2019 12:42

Well, app actually IS allocating ~4.5 GB at the peak, that is what all indicators show - or have I got that wrong?

Top with default options gives me 4.6GB, 4.5GB or 4.4GB. It depends on a run. Rolling Eyes


Regards,
Novo
Re: Core 2019 [message #51953 is a reply to message #51952] Mon, 24 June 2019 20:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Mon, 24 June 2019 19:36
mirek wrote on Mon, 24 June 2019 12:42

Well, app actually IS allocating ~4.5 GB at the peak, that is what all indicators show - or have I got that wrong?

Top with default options gives me 4.6GB, 4.5GB or 4.4GB. It depends on a run. Rolling Eyes


Of course, as it is MT and allocation/deallocation order is not fixed...
Re: Core 2019 [message #51956 is a reply to message #51947] Wed, 26 June 2019 08:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Mon, 24 June 2019 06:13
mirek wrote on Sun, 23 June 2019 04:19
It would probably be worth to experiment with HPAGE constant... Can be any number >16.

I'm afraid I cannot afford to spend time on U++'s allocator anymore.
I'm switching to the glibc's one for the time being.


Redesign finished. Address space is now returned to OS when possible.

There is now MemorySetOptions to finetune behaviour. There are 4 parameters, low values should in general result in slower allocator with less memory consumption...

Mirek
Re: Core 2019 [message #51963 is a reply to message #51956] Thu, 27 June 2019 09:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
In addtion to USEMALLOC there is now HEAPOVERRIDE flag that kicks out all Memory* definitions, allowing you to replace the whole allocator with something else than malloc.
Re: Core 2019 [message #51968 is a reply to message #51963] Fri, 28 June 2019 09:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
I have got another idea. In order to reproduce allocation pattern, there is now

HEAPLOG

flag. If in main config, heap will produce a log of allocation (to heap.log file at exe dir) so that it can be reproduced and optimized.

heap.log is long, but should be highly compressible.
Re: Core 2019 [message #51970 is a reply to message #51968] Fri, 28 June 2019 16:56 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

My application started to crash maybe about a week or so ago after updating uppsrc from SVN. Now I got some time to investigate and it seems my app:

- Crashes strangely in different places with current SVN if I compile MSBT19x64 Release
- Works OK with current SVN when compiling with MSBT17x64 Debug or MSBT19x64 Debug
- Works OK with current SVN if I use flag USEMALLOC and compile with MSBT19x64 Release
- Works OK with SVN 13068 compiling with MSBT17x64 Release

Any idea what's wrong? Is it related to the new allocator?

I added some RLOGs and found that it might crash even somewhere in BufferPainter during Stroke... (did not track it all the way down though). Debugger does not help as it does not crash when compiled in debug mode.

Best regards,

Tom
Re: Core 2019 [message #51971 is a reply to message #51970] Fri, 28 June 2019 17:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Fri, 28 June 2019 16:56
Hi Mirek,

My application started to crash maybe about a week or so ago after updating uppsrc from SVN. Now I got some time to investigate and it seems my app:

- Crashes strangely in different places with current SVN if I compile MSBT19x64 Release
- Works OK with current SVN when compiling with MSBT17x64 Debug or MSBT19x64 Debug
- Works OK with current SVN if I use flag USEMALLOC and compile with MSBT19x64 Release
- Works OK with SVN 13068 compiling with MSBT17x64 Release

Any idea what's wrong? Is it related to the new allocator?

I added some RLOGs and found that it might crash even somewhere in BufferPainter during Stroke... (did not track it all the way down though). Debugger does not help as it does not crash when compiled in debug mode.

Best regards,

Tom


Probably allocator, thanks for reporting. It is under active development. It would be worth quoting the revision tested - even today I have fixed / changed some things...

Mirek
Re: Core 2019 [message #51972 is a reply to message #51970] Fri, 28 June 2019 17:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Fri, 28 June 2019 16:56
though). Debugger does not help as it does not crash when compiled in debug mode.


You can activate debug info for release mode. Sometimes it is very useful.

Mirek
Re: Core 2019 [message #51973 is a reply to message #51972] Fri, 28 June 2019 17:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
For what is worth, I have quickly checked PainterExamples and all is working...
Re: Core 2019 [message #51974 is a reply to message #51973] Fri, 28 June 2019 18:38 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

Thanks for your reply. I will update from SVN again on Monday morning in the office. Then I will check again. I will also try enabling debug info for release mode.

Thanks and best regards,

Tom
Re: Core 2019 [message #51987 is a reply to message #51974] Sun, 30 June 2019 19:02 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
I'm getting a crash with a stack trace below when using MemoryAllocPermanent:

Upp::Heap::RemoteFlushRaw (this=<optimized out>) at HeapImp.h:481
Upp::Heap::RemoteFree (this=<optimized out>, ptr=<optimized out>, size=<optimized out>) at HeapImp.h:498
Upp::Heap::Free (this=<optimized out>, ptr=<optimized out>, page=<optimized out>, k=<optimized out>) at sheap.cpp:216
Upp::Heap::Free (this=0x7ffff7a15a10, ptr=<optimized out>) at sheap.cpp:237
Upp::MemoryFree (ptr=<optimized out>) at sheap.cpp:420
judy_close (judy=<optimized out>) at lib/judy.c:147
judy::Map<long long, long long>::~Map (this=<optimized out>) at /home/ssg/dvlp/cpp/sergey/upp/dvlp/plugin/judy/judy.h:48
ConsoleMainFn_ () at test_ht_perf.cpp:98
Upp::AppExecute__ (app=0xfffffffffffffffd) at App.cpp:343
main (argc=-3, argv=0x7ff0b0b5b000, envptr=0x7ffff7a167e8) at test_ht_perf.cpp:8

MemoryAllocPermanent seems to be a replacement for malloc.
The same code using MemoryAlloc works fine.
svn@13460, git@cb77bd58b76a15
Am I doing something wrong or is this a bug?


Regards,
Novo
Re: Core 2019 [message #51988 is a reply to message #51987] Sun, 30 June 2019 19:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Sun, 30 June 2019 19:02
I'm getting a crash with a stack trace below when using MemoryAllocPermanent:

Upp::Heap::RemoteFlushRaw (this=<optimized out>) at HeapImp.h:481
Upp::Heap::RemoteFree (this=<optimized out>, ptr=<optimized out>, size=<optimized out>) at HeapImp.h:498
Upp::Heap::Free (this=<optimized out>, ptr=<optimized out>, page=<optimized out>, k=<optimized out>) at sheap.cpp:216
Upp::Heap::Free (this=0x7ffff7a15a10, ptr=<optimized out>) at sheap.cpp:237
Upp::MemoryFree (ptr=<optimized out>) at sheap.cpp:420
judy_close (judy=<optimized out>) at lib/judy.c:147
judy::Map<long long, long long>::~Map (this=<optimized out>) at /home/ssg/dvlp/cpp/sergey/upp/dvlp/plugin/judy/judy.h:48
ConsoleMainFn_ () at test_ht_perf.cpp:98
Upp::AppExecute__ (app=0xfffffffffffffffd) at App.cpp:343
main (argc=-3, argv=0x7ff0b0b5b000, envptr=0x7ffff7a167e8) at test_ht_perf.cpp:8

MemoryAllocPermanent seems to be a replacement for malloc.
The same code using MemoryAlloc works fine.
svn@13460, git@cb77bd58b76a15
Am I doing something wrong or is this a bug?


MemoryAllocPermanent is for allocating memory that is not to be freed (aka is "permanent"). You cannot call MemoryFree on it (as it is "permanent" Smile.

Mirek
Re: Core 2019 [message #51990 is a reply to message #51988] Sun, 30 June 2019 20:12 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Sun, 30 June 2019 13:11
MemoryAllocPermanent is for allocating memory that is not to be freed (aka is "permanent"). You cannot call MemoryFree on it (as it is "permanent" Smile.

Mirek

Thanks! A couple of lines of documentation would be really helpful ... Rolling Eyes


Regards,
Novo
Re: Core 2019 [message #51992 is a reply to message #51990] Mon, 01 July 2019 00:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Sun, 30 June 2019 20:12
mirek wrote on Sun, 30 June 2019 13:11
MemoryAllocPermanent is for allocating memory that is not to be freed (aka is "permanent"). You cannot call MemoryFree on it (as it is "permanent" Smile.

Mirek

Thanks! A couple of lines of documentation would be really helpful ... Rolling Eyes


You are right. Done.
Re: Core 2019 [message #51996 is a reply to message #51974] Mon, 01 July 2019 09:14 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

I just downloaded SVN 13462 and now it all works OK again... No crashes.

Thanks and best regards,

Tom
Re: Core 2019 [message #52048 is a reply to message #51963] Thu, 11 July 2019 19:55 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Thu, 27 June 2019 03:44
In addtion to USEMALLOC there is now HEAPOVERRIDE flag that kicks out all Memory* definitions, allowing you to replace the whole allocator with something else than malloc.

Thanks a lot!

P.S. Documentation for MemoryLimitKb has a typo ...


Regards,
Novo
Re: Core 2019 [message #52049 is a reply to message #52048] Thu, 11 July 2019 20:14 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Thu, 11 July 2019 19:55
mirek wrote on Thu, 27 June 2019 03:44
In addtion to USEMALLOC there is now HEAPOVERRIDE flag that kicks out all Memory* definitions, allowing you to replace the whole allocator with something else than malloc.

Thanks a lot!

P.S. Documentation for MemoryLimitKb has a typo ...


Must be blind, do not see it....
Re: Core 2019 [message #52050 is a reply to message #52049] Thu, 11 July 2019 20:53 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Thu, 11 July 2019 14:14
Novo wrote on Thu, 11 July 2019 19:55
mirek wrote on Thu, 27 June 2019 03:44
In addtion to USEMALLOC there is now HEAPOVERRIDE flag that kicks out all Memory* definitions, allowing you to replace the whole allocator with something else than malloc.

Thanks a lot!

P.S. Documentation for MemoryLimitKb has a typo ...


Must be blind, do not see it....

"defualt values"


Regards,
Novo
Re: Core 2019 [message #52060 is a reply to message #52048] Fri, 12 July 2019 10:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Thu, 11 July 2019 19:55
mirek wrote on Thu, 27 June 2019 03:44
In addtion to USEMALLOC there is now HEAPOVERRIDE flag that kicks out all Memory* definitions, allowing you to replace the whole allocator with something else than malloc.

Thanks a lot!


Any chance to get allocator retested? If still unsatisfactory, send me allocation log?

Mirek
Re: Core 2019 [message #52063 is a reply to message #52060] Fri, 12 July 2019 16:50 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
mirek wrote on Fri, 12 July 2019 04:09
Novo wrote on Thu, 11 July 2019 19:55
mirek wrote on Thu, 27 June 2019 03:44
In addtion to USEMALLOC there is now HEAPOVERRIDE flag that kicks out all Memory* definitions, allowing you to replace the whole allocator with something else than malloc.

Thanks a lot!


Any chance to get allocator retested? If still unsatisfactory, send me allocation log?

Mirek

Yes, I can do that, but that will take me a few weeks. My apps are currently in broken state.

Could you please add info about HEAPOVERRIDE and MemoryOptions (it is just briefly mentioned in docs) to documentation?

Also linking to / embedding of Resolving memory leaks into Heap docs would be great because otherwise this info is distributed among multiple topics and is hard to find. I personally didn't know about the --memory-breakpoint__ trick.

And, I guess, it is possible to add new allocators to U++ via plugins now ...


Regards,
Novo
Re: Core 2019 [message #52197 is a reply to message #52063] Thu, 08 August 2019 21:47 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1432
Registered: December 2006
Ultimate Contributor
I checked "Heap implementation" article from "Help Topics" (which for some reason is not published on web), and it looks like it doesn't match current state of the allocator.

I'm trying to get minimum value of alignment of allocated memory. From a simple test below
	size_t sz = 0;
	void* m = nullptr;
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);

I got that min alignment is 32. Is this correct?
And min block size is 28. This is a little bit weird.
This message states that "the smallest allocation has size 32 and is 32 bytes aligned", which doesn't match the help topic.

Is it possible to expose allocator-related info via a public enum?
Knowing min alignment is critical. Info about block sizes is also important.

TIA


Regards,
Novo
Re: Core 2019 [message #52198 is a reply to message #52197] Thu, 08 August 2019 22:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Novo wrote on Thu, 08 August 2019 21:47
I checked "Heap implementation" article from "Help Topics" (which for some reason is not published on web), and it looks like it doesn't match current state of the allocator.

I'm trying to get minimum value of alignment of allocated memory. From a simple test below
	size_t sz = 0;
	void* m = nullptr;
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);
	m = MemoryAlloc(1);
	sz = GetMemoryBlockSize(m);

I got that min alignment is 32. Is this correct?
And min block size is 28. This is a little bit weird.
This message states that "the smallest allocation has size 32 and is 32 bytes aligned", which doesn't match the help topic.

Is it possible to expose allocator-related info via a public enum?
Knowing min alignment is critical. Info about block sizes is also important.

TIA


The problem is that the minimal block size is different in debug, as it adds fences everywhere.

In release, 32 holds true.

Mirek
Re: Core 2019 [message #52199 is a reply to message #52198] Thu, 08 August 2019 22:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
PS.: Guaranteed alignment is 16.
Re: Core 2019 [message #52200 is a reply to message #52199] Thu, 08 August 2019 22:59 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Commited:

enum {
	UPP_HEAP_ALIGNMENT = 16,
	UPP_HEAP_MINBLOCK = 32,
};
Previous Topic: ide: Assist / Display/apply patch
Next Topic: ide: pkg_config support
Goto Forum:
  


Current Time: Mon Jun 22 06:13:52 GMT+2 2026

Total time taken to generate the page: 0.01121 seconds