Ghazi Bouselmi's Pages


Here you can find out who I am. Well, also my CV, my publications 

LinkedIn : http://www.linkedin.com/in/ghazibouselmi  View Ghazi Bouselmi's profile on LinkedIn

07-11-2016 : first draft.

08-11-2016 : mini-detours.

10-11-2016 : first partially workable version.

10-11-2016-bis : full working version.

12-11-2016 : better memory profile management.

13-11-2016 : multiple heap-groups.

16-11-2016 : better multiple heaps management.

17-11-2016 : 2 Modes: cautious & fast.

18-11-2016 : bug correction in x64, x64 memory model.

19-12-2016 : small changes.

  • Tests are in 32 bits (if not mentioned otherwise), where memory is limited, and its fragmentation is a severe issue. 
  • As can be seen below, the application using the CRT memory manager fails to allocate a chunk of 8MB, despite 1.2GB is theoretically available.
  • On the other hand, with the private memory manager, the status of the process memory is very healthy, after 20 loops of intensive memory operations (note that the WinAPI heap is barely used, remnants of the CRT initialisations before the private manager detours).
    • CRT-memory manager: intensive memory usage - end of loop 1:
    • CRT-memory manager: intensive memory usage - end of loop 2:
    • CRT-memory manager: intensive memory usage - end of loop 3:
    • CRT-memory manager: intensive memory usage - crash !

    • Private-memory manager: 100 loops, still kicking !








x86: Testing memory operations speed (malloc & free)
CRT-memory manager V.S. New memory manager







chunnk size: 256B → 512B Time (ms) CPU-Usage

CRT: 4 threads, 10M op / thread 2300 49%

NEW: 4 threads, 10M op / thread
Cautious mode
7349 43%

NEW: 4 threads, 10M op / thread
Non-cautious mode
2547 50%

chunnk size: 256B → 2KB



CRT: 8 threads, 5M op / thread 3247 54%

NEW: 8 threads, 5M op / thread
Cautious mode
5848 82%

NEW: 8 threads, 5M op / thread
Non-cautious mode
2212 99%

chunnk size: 256B → 32KB



CRT: 10 threads, 1M op / thread 39511 27%

NEW: 10 threads, 1M op / thread
Cautious mode
1419 82%

NEW: 10 threads, 1M op / thread
Non-cautious mode
549 97%

chunnk size: 256B → 128KB



CRT: 12 threads, 200k op / thread 22064 15%

NEW: 12 threads, 200k op / thread
Cautious mode
332 83%

NEW: 12 threads, 200k op / thread
Non-cautious mode
208 67%

chunnk size: 256B → 512KB



CRT: 14 threads, 50k op / thread 9878 27%

NEW: 14 threads, 50k op / thread
Cautious mode
100 91%

NEW: 14 threads, 50k op / thread
Non-cautious mode
69 70%

chunnk size: 256B → 2MB



CRT: 16 threads, 20k op / thread 7846 26%

NEW: 16 threads, 20k op / thread
Cautious mode
48 92%

NEW: 16 threads, 20k op / thread
Non-cautious mode
33 69%











x86: Testing robustness of the memory managers V.S.
Memory-Fragmentation (allocate without deallocation) :
==> The CRT-Memory-manager crashes after few loops







2 threads, 2M pointers each,
Chunk sizes 128B → 256B ~ 750MB
Average
Time (ms)



CRT-memory-manager 1159


NEW-memory-manager-8-sub-heaps 1309


4 threads, 800k pointers each,
Chunk sizes 128B → 512B ~ 1GB




CRT-memory-manager 1301


NEW-memory-manager-8-sub-heaps 2129


8 threads, 200k pointers each,
Chunk sizes 128B → 1KB ~ 900MB




CRT-memory-manager 839


NEW-memory-manager-8-sub-heaps 2314


10 threads, 50k pointers each,
Chunk sizes 128B → 1.25KB ~ 343MB




CRT-memory-manager 155


NEW-memory-manager-8-sub-heaps 1046


12 threads, 15k pointers each,
Chunk sizes 128B → 1.5KB ~ 146MB




CRT-memory-manager 19


NEW-memory-manager-8-sub-heaps 124












x86: Testing robustness of the memory managers V.S.
Memory-Fragmentation (allocate without deallocation)
==> far from the 2GB limits







2 threads, 1M pointers each,
Chunk sizes 128B → 256B ~ 375MB
Average
Time (ms)



CRT-memory-manager 451


NEW-memory-manager 699


4 threads, 400k pointers each,
Chunk sizes 128B → 512B ~ 500MB




CRT-memory-manager 460


NEW-memory-manager 404


8 threads, 100k pointers each,
Chunk sizes 128B → 1KB ~ 450MB




CRT-memory-manager 263


NEW-memory-manager 305


10 threads, 50k pointers each,
Chunk sizes 128B → 1.25KB ~ 343MB




CRT-memory-manager 145


NEW-memory-manager 127


12 threads, 25k pointers each,
Chunk sizes 128B → 1.5KB ~ 250MB




CRT-memory-manager 73


NEW-memory-manager 69












x86: Pools of objects, using std::list, CRT-memory manager






4 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >279849%

Multi-pool< std::list, 4-sub-pools >272949%

Multi-pool< std::list, 8-sub-pools >227249%

Multi-pool< std::list, 16-sub-pools>215850%

Multi-pool< std::list, 32-sub-pools>199349%

Multi-pool< std::list, 64-sub-pools>203049%






8 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >740192%

Multi-pool< std::list, 4-sub-pools >504880%

Multi-pool< std::list, 8-sub-pools >387482%

Multi-pool< std::list, 16-sub-pools>354883%

Multi-pool< std::list, 32-sub-pools>300791%

Multi-pool< std::list, 64-sub-pools>284791%






16 threads, 300k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >445193%

Multi-pool< std::list, 4-sub-pools >286893%

Multi-pool< std::list, 8-sub-pools >249587%

Multi-pool< std::list, 16-sub-pools>216392%

Multi-pool< std::list, 32-sub-pools>186691%

Multi-pool< std::list, 64-sub-pools>172991%











x86: Pools of objects, using new/private list, 
CRT-memory manager







4 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >176849%

Multi-pool< , 4-sub-pools >227349%

Multi-pool< , 8-sub-pools >184149%

Multi-pool< , 16-sub-pools >168949%

Multi-pool< , 32-sub-pools >152849%

Multi-pool< , 64-sub-pools >144649%






8 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >431392%

Multi-pool< , 4-sub-pools >384988%

Multi-pool< , 8-sub-pools >313290%

Multi-pool< , 16-sub-pools >251989%

Multi-pool< , 32-sub-pools >237588%

Multi-pool< , 64-sub-pools >224791%






16 threads, 300k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >258793%

Multi-pool< , 4-sub-pools >250290%

Multi-pool< , 8-sub-pools >183192%

Multi-pool< , 16-sub-pools >158092%

Multi-pool< , 32-sub-pools >142990%

Multi-pool< , 64-sub-pools >134491%






x86: Pools of objects, using CRT-memory manager
Comparing std::list && new/private list



Time (ms)Time (ms)

4 threads, 1000k oper / threadstd::listnew-list

Baseline-pool< >27981768

Multi-pool< , 4-sub-pools >27292273

Multi-pool< , 8-sub-pools >22721841

Multi-pool< , 16-sub-pools >21581689

Multi-pool< , 32-sub-pools >19931528

Multi-pool< , 64-sub-pools >20301446






8 threads, 1000k oper / threadstd::listnew-list

Baseline-pool< >74014313

Multi-pool< , 4-sub-pools >50483849

Multi-pool< , 8-sub-pools >38743132

Multi-pool< , 16-sub-pools >35482519

Multi-pool< , 32-sub-pools >30072375

Multi-pool< , 64-sub-pools >28472247






16 threads, 300k oper / threadstd::listnew-list

Baseline-pool< >44512587

Multi-pool< , 4-sub-pools >28682502

Multi-pool< , 8-sub-pools >24951831

Multi-pool< , 16-sub-pools >21631580

Multi-pool< , 32-sub-pools >18661429

Multi-pool< , 64-sub-pools >17291344





















x86: Pools of objects, using std::list, NEW-memory Manager






4 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >268149%

Multi-pool< std::list, 4-sub-pools >303150%

Multi-pool< std::list, 8-sub-pools >258950%

Multi-pool< std::list, 16-sub-pools>246150%

Multi-pool< std::list, 32-sub-pools>239150%

Multi-pool< std::list, 64-sub-pools>226350%






8 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >867994%

Multi-pool< std::list, 4-sub-pools >582597%

Multi-pool< std::list, 8-sub-pools >413296%

Multi-pool< std::list, 16-sub-pools>374999%

Multi-pool< std::list, 32-sub-pools>369699%

Multi-pool< std::list, 64-sub-pools>361399%






16 threads, 300k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >618499%

Multi-pool< std::list, 4-sub-pools >336794%

Multi-pool< std::list, 8-sub-pools >288692%

Multi-pool< std::list, 16-sub-pools>257598%

Multi-pool< std::list, 32-sub-pools>276898%

Multi-pool< std::list, 64-sub-pools>250998%











x86: Pools of objects, using new/private list, 
NEW-memory manager







4 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >200249%

Multi-pool< , 4-sub-pools >237050%

Multi-pool< , 8-sub-pools >185849%

Multi-pool< , 16-sub-pools >164249%

Multi-pool< , 32-sub-pools >151249%

Multi-pool< , 64-sub-pools >139649%






8 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >479498%

Multi-pool< , 4-sub-pools >407798%

Multi-pool< , 8-sub-pools >292698%

Multi-pool< , 16-sub-pools >243597%

Multi-pool< , 32-sub-pools >221898%

Multi-pool< , 64-sub-pools >208299%






16 threads, 300k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >291795%

Multi-pool< , 4-sub-pools >259695%

Multi-pool< , 8-sub-pools >196897%

Multi-pool< , 16-sub-pools >153298%

Multi-pool< , 32-sub-pools >136699%

Multi-pool< , 64-sub-pools >127298%






x86: Pools of objects, using NEW-memory manager
Comparing std::list && new/private list



Time (ms)Time (ms)

4 threads, 1000k oper / threadstd::listnew-list

Baseline-pool< >26812002

Multi-pool< , 4-sub-pools >30312370

Multi-pool< , 8-sub-pools >25891858

Multi-pool< , 16-sub-pools >24611642

Multi-pool< , 32-sub-pools >23911512

Multi-pool< , 64-sub-pools >22631396






8 threads, 1000k oper / threadstd::listnew-list

Baseline-pool< >86794794

Multi-pool< , 4-sub-pools >58254077

Multi-pool< , 8-sub-pools >41322926

Multi-pool< , 16-sub-pools >37492435

Multi-pool< , 32-sub-pools >36962218

Multi-pool< , 64-sub-pools >36132082






16 threads, 300k oper / threadstd::listnew-list

Baseline-pool< >61842917

Multi-pool< , 4-sub-pools >33672596

Multi-pool< , 8-sub-pools >28861968

Multi-pool< , 16-sub-pools >25751532

Multi-pool< , 32-sub-pools >27681366

Multi-pool< , 64-sub-pools >25091272















x86: Overall Pools test results













CRT-Mem
Manager
NEW-Mem
Manager

CRT-Mem
Manager
NEW-Mem
Manager











Time (ms)Time (ms)
Time (ms)Time (ms)

4 threads, 1000k oper / threadstd::liststd::list
new-listnew-list

Baseline-pool< >27982681
17682002

Multi-pool< , 4 >27293031
22732370

Multi-pool< , 8 >22722589
18411858

Multi-pool< , 16 >21582461
16891642

Multi-pool< , 32 >19932391
15281512

Multi-pool< , 64 >20302263
14461396









8 threads, 1000k oper / threadstd::liststd::list
new-listnew-list

Baseline-pool< >74018679
43134794

Multi-pool< , 4 >50485825
38494077

Multi-pool< , 8 >38744132
31322926

Multi-pool< , 16 >35483749
25192435

Multi-pool< , 32 >30073696
23752218

Multi-pool< , 64 >28473613
22472082









16 threads, 300k oper / threadstd::liststd::list
new-listnew-list

Baseline-pool< >44516184
25872917

Multi-pool< , 4 >28683367
25022596

Multi-pool< , 8 >24952886
18311968

Multi-pool< , 16 >21632575
15801532

Multi-pool< , 32 >18662768
14291366

Multi-pool< , 64 >17292509
13441272

















x64: Testing memory operations speed (malloc & free)
CRT-memory manager V.S. New memory manager







chunnk size: 256B → 512B Time (ms) CPU-Usage

CRT: 4 threads, 10M op / thread 1371 49%

NEW: 4 threads, 10M op / thread 2082 44%

chunnk size: 256B → 2KB



CRT: 8 threads, 5M op / thread 2691 53%

NEW: 8 threads, 5M op / thread 1624 94%

chunnk size: 256B → 32KB



CRT: 10 threads, 1M op / thread 5561 39%

NEW: 10 threads, 1M op / thread 420 89%

chunnk size: 256B → 128KB



CRT: 12 threads, 200k op / thread 7318 25%

NEW: 12 threads, 200k op / thread 114 82%

chunnk size: 256B → 512KB



CRT: 14 threads, 50k op / thread 4363 24%

NEW: 14 threads, 50k op / thread 48 67%

chunnk size: 256B → 2MB



CRT: 16 threads, 20k op / thread 4591 27%

NEW: 16 threads, 20k op / thread 24 85%
















x64: Testing robustness of the memory managers V.S.
Memory-Fragmentation (allocate without deallocation)







2 threads, 2M pointers each,
Chunk sizes 128B → 256B ~ 750MB
Average
Time (ms)



CRT-memory-manager 1078


NEW-memory-manager-8-sub-heaps 734


4 threads, 800k pointers each,
Chunk sizes 128B → 512B ~ 1GB




CRT-memory-manager 1406


NEW-memory-manager-8-sub-heaps 472


8 threads, 200k pointers each,
Chunk sizes 128B → 1KB ~ 900MB




CRT-memory-manager 796


NEW-memory-manager-8-sub-heaps 241


10 threads, 50k pointers each,
Chunk sizes 128B → 1.25KB ~ 343MB




CRT-memory-manager 129


NEW-memory-manager-8-sub-heaps 63


12 threads, 15k pointers each,
Chunk sizes 128B → 1.5KB ~ 146MB




CRT-memory-manager 14


NEW-memory-manager-8-sub-heaps 26













x64: Pools of objects, using std::list, CRT-memory manager






4 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >259448%

Multi-pool< std::list, 4-sub-pools >238950%

Multi-pool< std::list, 8-sub-pools >225749%

Multi-pool< std::list, 16-sub-pools >199948%

Multi-pool< std::list, 32-sub-pools >199747%

Multi-pool< std::list, 64-sub-pools >194749%






8 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >721688%

Multi-pool< std::list, 4-sub-pools >471593%

Multi-pool< std::list, 8-sub-pools >390591%

Multi-pool< std::list, 16-sub-pools >338492%

Multi-pool< std::list, 32-sub-pools >322392%

Multi-pool< std::list, 64-sub-pools >300195%






16 threads, 300k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >420195%

Multi-pool< std::list, 4-sub-pools >286793%

Multi-pool< std::list, 8-sub-pools >252991%

Multi-pool< std::list, 16-sub-pools >209295%

Multi-pool< std::list, 32-sub-pools >190697%

Multi-pool< std::list, 64-sub-pools >181294%











x64: Pools of objects, using new/private list, 
CRT-memory manager







4 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >162149%

Multi-pool< private_list, 4-sub-pools196350%

Multi-pool< private_list, 8-sub-pools170150%

Multi-pool< private_list, 16-sub-pools152850%

Multi-pool< private_list, 32-sub-pools141749%

Multi-pool< private_list, 64-sub-pools133449%






8 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >395197%

Multi-pool< private_list, 4-sub-pools341899%

Multi-pool< private_list, 8-sub-pools259099%

Multi-pool< private_list, 16-sub-pools219197%

Multi-pool< private_list, 32-sub-pools222882%

Multi-pool< private_list, 64-sub-pools215881%






16 threads, 300k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >229788%

Multi-pool< private_list, 4-sub-pools222687%

Multi-pool< private_list, 8-sub-pools174294%

Multi-pool< private_list, 16-sub-pools149289%

Multi-pool< private_list, 32-sub-pools126198%

Multi-pool< private_list, 64-sub-pools117299%






x64: Pools of objects, using CRT-memory manager
Comparing std::list && new/private list



Time (ms)Time (ms)

4 threads, 1000k oper / threadstd::listnew-list

Baseline-pool< >25941621

Multi-pool< , 4-sub-pools >23891963

Multi-pool< , 8-sub-pools >22571701

Multi-pool< , 16-sub-pools >19991528

Multi-pool< , 32-sub-pools >19971417

Multi-pool< , 64-sub-pools >19471334






8 threads, 1000k oper / threadstd::listnew-list

Baseline-pool< >72163951

Multi-pool< , 4-sub-pools >47153418

Multi-pool< , 8-sub-pools >39052590

Multi-pool< , 16-sub-pools >33842191

Multi-pool< , 32-sub-pools >32232228

Multi-pool< , 64-sub-pools >30012158






16 threads, 300k oper / threadstd::listnew-list

Baseline-pool< >42012297

Multi-pool< , 4-sub-pools >28672226

Multi-pool< , 8-sub-pools >25291742

Multi-pool< , 16-sub-pools >20921492

Multi-pool< , 32-sub-pools >19061261

Multi-pool< , 64-sub-pools >18121172





















x64: Pools of objects, using std::list, NEW-memory Manager






4 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >235750%

Multi-pool< std::list, 4-sub-pools >274450%

Multi-pool< std::list, 8-sub-pools >264649%

Multi-pool< std::list, 16-sub-pools >253849%

Multi-pool< std::list, 32-sub-pools >250049%

Multi-pool< std::list, 64-sub-pools >233549%






8 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >778692%

Multi-pool< std::list, 4-sub-pools >542994%

Multi-pool< std::list, 8-sub-pools >419994%

Multi-pool< std::list, 16-sub-pools >404894%

Multi-pool< std::list, 32-sub-pools >415993%

Multi-pool< std::list, 64-sub-pools >392093%






16 threads, 300k oper / threadTime (ms)CPU-Usage

Baseline-pool< std::list >761797%

Multi-pool< std::list, 4-sub-pools >324289%

Multi-pool< std::list, 8-sub-pools >283592%

Multi-pool< std::list, 16-sub-pools >263896%

Multi-pool< std::list, 32-sub-pools >276795%

Multi-pool< std::list, 64-sub-pools >297396%











x64: Pools of objects, using new/private list, 
NEW-memory manager







4 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >208848%

Multi-pool< private_list, 4-sub-pools193750%

Multi-pool< private_list, 8-sub-pools163849%

Multi-pool< private_list, 16-sub-pools148349%

Multi-pool< private_list, 32-sub-pools137849%

Multi-pool< private_list, 64-sub-pools131649%






8 threads, 1000k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >461390%

Multi-pool< private_list, 4-sub-pools334496%

Multi-pool< private_list, 8-sub-pools262294%

Multi-pool< private_list, 16-sub-pools231492%

Multi-pool< private_list, 32-sub-pools208095%

Multi-pool< private_list, 64-sub-pools204189%






16 threads, 300k oper / threadTime (ms)CPU-Usage

Baseline-pool< private_list >333593%

Multi-pool< private_list, 4-sub-pools216391%

Multi-pool< private_list, 8-sub-pools173893%

Multi-pool< private_list, 16-sub-pools142897%

Multi-pool< private_list, 32-sub-pools127394%

Multi-pool< private_list, 64-sub-pools118493%






x64: Pools of objects, using NEW-memory manager
Comparing std::list && new/private list



Time (ms)Time (ms)

4 threads, 1000k oper / threadstd::listnew-list

Baseline-pool< >23572088

Multi-pool< , 4-sub-pools >27441937

Multi-pool< , 8-sub-pools >26461638

Multi-pool< , 16-sub-pools >25381483

Multi-pool< , 32-sub-pools >25001378

Multi-pool< , 64-sub-pools >23351316






8 threads, 1000k oper / threadstd::listnew-list

Baseline-pool< >77864613

Multi-pool< , 4-sub-pools >54293344

Multi-pool< , 8-sub-pools >41992622

Multi-pool< , 16-sub-pools >40482314

Multi-pool< , 32-sub-pools >41592080

Multi-pool< , 64-sub-pools >39202041






16 threads, 300k oper / threadstd::listnew-list

Baseline-pool< >76173335

Multi-pool< , 4-sub-pools >32422163

Multi-pool< , 8-sub-pools >28351738

Multi-pool< , 16-sub-pools >26381428

Multi-pool< , 32-sub-pools >27671273

Multi-pool< , 64-sub-pools >29731184















x64: Overall Pools test results













CRT-Mem
Manager
NEW-Mem
Manager

CRT-Mem
Manager
NEW-Mem
Manager











Time (ms)Time (ms)
Time (ms)Time (ms)

4 threads, 1000k
Oper / thread
std::liststd::list
new-listnew-list

Baseline-pool< >25942357
16212088

Multi-pool< , 4 >23892744
19631937

Multi-pool< , 8 >22572646
17011638

Multi-pool< , 16 >19992538
15281483

Multi-pool< , 32 >19972500
14171378

Multi-pool< , 64 >19472335
13341316









8 threads, 1000k
Oper / thread
std::liststd::list
new-listnew-list

Baseline-pool< >72167786
39514613

Multi-pool< , 4 >47155429
34183344

Multi-pool< , 8 >39054199
25902622

Multi-pool< , 16 >33844048
21912314

Multi-pool< , 32 >32234159
22282080

Multi-pool< , 64 >30013920
21582041









16 threads, 300k
Oper / thread
std::liststd::list
new-listnew-list

Baseline-pool< >42017617
22973335

Multi-pool< , 4 >28673242
22262163

Multi-pool< , 8 >25292835
17421738

Multi-pool< , 16 >20922638
14921428

Multi-pool< , 32 >19062767
12611273

Multi-pool< , 64 >18122973
11721184