Skip to content

Commit a519513

Browse files
author
Arnaud Bouchez
committed
small x86_64 MM change in BOOST/BOOSTER mode
1 parent 46a1ca5 commit a519513

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/core/mormot.core.fpcx64mm.pas

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,8 @@ procedure NotifyMediumLargeFree(var Arena: TMMStatusArena; Size: PtrUInt);
761761
const
762762
// (sometimes) the more arenas, the better multi-threadable
763763
{$ifdef FPCMM_BOOSTER}
764-
NumTinyBlockTypesPO2 = 4;
765-
NumTinyBlockArenasPO2 = 4; // will probably end up with Medium lock contention
764+
NumTinyBlockTypesPO2 = 4; // tiny are <= 256 bytes
765+
NumTinyBlockArenasPO2 = 4; // 16 arenas
766766
{$else}
767767
{$ifdef FPCMM_BOOST}
768768
NumTinyBlockTypesPO2 = 4; // tiny are <= 256 bytes
@@ -988,7 +988,7 @@ procedure GetSmallLockLessFreeBlock; nostackframe; assembler;
988988
xor ecx, ecx
989989
xchg [rbx].TSmallBlockType.LockLessFree, rcx // atomic rcx = to free
990990
test rcx, rcx
991-
jz @Done2
991+
jz @Done2 // slot used by another thread in-between
992992
mov r10, [rcx]
993993
test r10, r10 // r10 = new head = the one following rcx
994994
jz @Done
@@ -1509,7 +1509,10 @@ function _GetMem(size: PtrUInt): pointer;
15091509
mov dl, NumTinyBlockArenas + 1 // 8/16 arenas (including Small[])
15101510
@TinyBlockArenaLoop:
15111511
mov eax, SizeOf(TTinyBlockTypes)
1512-
// note: "lock xadd" decreases the loop iterations but is slower
1512+
// "lock xadd" decreases loop iterations but is slower on normal load
1513+
{$ifdef FPCMM_BOOST}
1514+
lock
1515+
{$endif FPCMM_BOOST}
15131516
xadd dword ptr [r8 + TSmallBlockInfo.TinyCurrentArena], eax
15141517
lea rbx, [r8 + rcx]
15151518
and eax, ((NumTinyBlockArenas + 1) * SizeOf(TTinyBlockTypes)) - 1

src/mormot.commit.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.0.4819'
1+
'2.0.4820'

0 commit comments

Comments
 (0)