Skip to content

Commit 258d751

Browse files
pavelmashpavel.mash
andauthored
[mORMot] uses binary array binding (updates); changed async pool size (-s CPUs -t 4) (#8232)
Co-authored-by: pavel.mash <[email protected]>
1 parent a4029fc commit 258d751

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

frameworks/Pascal/mormot/setup_and_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ echo "Download statics from $URL ..."
3535
wget -qO- "$URL" | tar -xz -C ./libs/mORMot/static
3636

3737
# uncomment for fixed commit URL
38-
URL=https://github.com/synopse/mORMot2/tarball/c66f01232083104d7b84757ae14b4af8351ae6ae
38+
URL=https://github.com/synopse/mORMot2/tarball/139b61c77065d0b7c784eeeec8217c7e4dbb9618
3939
#URL="https://api.github.com/repos/synopse/mORMot2/tarball/$USED_TAG"
4040
echo "Download and unpacking mORMot sources from $URL ..."
4141
wget -qO- "$URL" | tar -xz -C ./libs/mORMot --strip-components=1

frameworks/Pascal/mormot/src/raw.pas

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ TRawAsyncServer = class(TSynPersistent)
125125
WORLD_COUNT = 10000;
126126
WORLD_READ_SQL = 'select id,randomNumber from World where id=?';
127127
WORLD_UPDATE_SQLN = 'update World as t set randomNumber = v.r from ' +
128-
'(SELECT unnest(?::bigint[]), unnest(?::bigint[]) order by 1) as v(id, r)' +
128+
'(SELECT unnest(?::integer[]), unnest(?::integer[]) order by 1) as v(id, r)' +
129129
' where t.id = v.id';
130130
FORTUNES_SQL = 'select id,message from Fortune';
131131

@@ -168,6 +168,7 @@ constructor TRawAsyncServer.Create(
168168
inherited Create;
169169
fDbPool := TSqlDBPostgresConnectionProperties.Create(
170170
'tfb-database:5432', 'hello_world', 'benchmarkdbuser', 'benchmarkdbpass');
171+
fDbPool.ArrayParamsAsBinary := true;
171172
// customize JSON serialization for TFB expectations
172173
TOrmWorld.OrmProps.Fields.JsonRenameProperties([
173174
'ID', 'id',
@@ -658,19 +659,17 @@ procedure TAsyncWorld.OnQueries(Statement: TSqlDBPostgresAsyncStatement;
658659
procedure TAsyncWorld.DoUpdates;
659660
var
660661
i: PtrInt;
661-
ids, nums: TInt64DynArray;
662+
params: TIntegerDynArray;
662663
begin
663-
setLength(ids{%H-}, count);
664-
setLength(nums{%H-}, count);
665664
for i := 0 to count - 1 do
666-
with res[i] do
667-
begin
668-
randomNumber := ComputeRandomWorld;
669-
ids[i] := id;
670-
nums[i] := randomNumber;
671-
end;
672-
update.BindArray(1, ids);
673-
update.BindArray(2, nums);
665+
res[i].randomNumber := ComputeRandomWorld;
666+
SetLength(params, count);
667+
for i := 0 to count - 1 do
668+
params[i] := res[i].id;
669+
update.BindArrayInt32(1, params);
670+
for i := 0 to count - 1 do
671+
params[i] := res[i].randomNumber;
672+
update.BindArrayInt32(2, params);
674673
update.ExecuteAsync(request, OnRes);
675674
end;
676675

@@ -718,8 +717,8 @@ procedure TAsyncWorld.OnRes(Statement: TSqlDBPostgresAsyncStatement;
718717
if GetEnvironmentVariable('TFB_TEST_NAME') = 'mormot-postgres-async' then
719718
begin
720719
// asynchronus test
721-
servers := cpuCount * 2;
722-
threads := 1;
720+
servers := cpuCount;
721+
threads := 4;
723722
end
724723
else
725724
if GetEnvironmentVariable('TFB_TEST_NAME') = 'mormot-postgres-async2' then

0 commit comments

Comments
 (0)