Explorar o código

[mORMot] uses binary array binding (updates); changed async pool size (-s CPUs -t 4) (#8232)

Co-authored-by: pavel.mash <[email protected]>
pavelmash %!s(int64=2) %!d(string=hai) anos
pai
achega
258d751ab3

+ 1 - 1
frameworks/Pascal/mormot/setup_and_build.sh

@@ -35,7 +35,7 @@ echo "Download statics from $URL ..."
 wget -qO- "$URL" | tar -xz -C ./libs/mORMot/static
 wget -qO- "$URL" | tar -xz -C ./libs/mORMot/static
 
 
 # uncomment for fixed commit URL
 # uncomment for fixed commit URL
-URL=https://github.com/synopse/mORMot2/tarball/c66f01232083104d7b84757ae14b4af8351ae6ae
+URL=https://github.com/synopse/mORMot2/tarball/139b61c77065d0b7c784eeeec8217c7e4dbb9618
 #URL="https://api.github.com/repos/synopse/mORMot2/tarball/$USED_TAG"
 #URL="https://api.github.com/repos/synopse/mORMot2/tarball/$USED_TAG"
 echo "Download and unpacking mORMot sources from $URL ..."
 echo "Download and unpacking mORMot sources from $URL ..."
 wget -qO- "$URL" | tar -xz -C ./libs/mORMot  --strip-components=1
 wget -qO- "$URL" | tar -xz -C ./libs/mORMot  --strip-components=1

+ 13 - 14
frameworks/Pascal/mormot/src/raw.pas

@@ -125,7 +125,7 @@ const
   WORLD_COUNT       = 10000;
   WORLD_COUNT       = 10000;
   WORLD_READ_SQL    = 'select id,randomNumber from World where id=?';
   WORLD_READ_SQL    = 'select id,randomNumber from World where id=?';
   WORLD_UPDATE_SQLN = 'update World as t set randomNumber = v.r from ' +
   WORLD_UPDATE_SQLN = 'update World as t set randomNumber = v.r from ' +
-    '(SELECT unnest(?::bigint[]), unnest(?::bigint[]) order by 1) as v(id, r)' +
+    '(SELECT unnest(?::integer[]), unnest(?::integer[]) order by 1) as v(id, r)' +
     ' where t.id = v.id';
     ' where t.id = v.id';
   FORTUNES_SQL      = 'select id,message from Fortune';
   FORTUNES_SQL      = 'select id,message from Fortune';
 
 
@@ -168,6 +168,7 @@ begin
   inherited Create;
   inherited Create;
   fDbPool := TSqlDBPostgresConnectionProperties.Create(
   fDbPool := TSqlDBPostgresConnectionProperties.Create(
     'tfb-database:5432', 'hello_world', 'benchmarkdbuser', 'benchmarkdbpass');
     'tfb-database:5432', 'hello_world', 'benchmarkdbuser', 'benchmarkdbpass');
+  fDbPool.ArrayParamsAsBinary := true;
   // customize JSON serialization for TFB expectations
   // customize JSON serialization for TFB expectations
   TOrmWorld.OrmProps.Fields.JsonRenameProperties([
   TOrmWorld.OrmProps.Fields.JsonRenameProperties([
     'ID',           'id',
     'ID',           'id',
@@ -658,19 +659,17 @@ end;
 procedure TAsyncWorld.DoUpdates;
 procedure TAsyncWorld.DoUpdates;
 var
 var
   i: PtrInt;
   i: PtrInt;
-  ids, nums: TInt64DynArray;
+  params: TIntegerDynArray;
 begin
 begin
-  setLength(ids{%H-}, count);
-  setLength(nums{%H-}, count);
   for i := 0 to count - 1 do
   for i := 0 to count - 1 do
-    with res[i] do
-    begin
-      randomNumber := ComputeRandomWorld;
-      ids[i] := id;
-      nums[i] := randomNumber;
-    end;
-  update.BindArray(1, ids);
-  update.BindArray(2, nums);
+    res[i].randomNumber := ComputeRandomWorld;
+  SetLength(params, count);
+  for i := 0 to count - 1 do
+    params[i] := res[i].id;
+  update.BindArrayInt32(1, params);
+  for i := 0 to count - 1 do
+    params[i] := res[i].randomNumber;
+  update.BindArrayInt32(2, params);
   update.ExecuteAsync(request, OnRes);
   update.ExecuteAsync(request, OnRes);
 end;
 end;
 
 
@@ -718,8 +717,8 @@ begin
     if GetEnvironmentVariable('TFB_TEST_NAME') = 'mormot-postgres-async' then
     if GetEnvironmentVariable('TFB_TEST_NAME') = 'mormot-postgres-async' then
     begin
     begin
       // asynchronus test
       // asynchronus test
-      servers := cpuCount * 2;
-      threads := 1;
+      servers := cpuCount;
+      threads := 4;
     end
     end
     else
     else
     if GetEnvironmentVariable('TFB_TEST_NAME') = 'mormot-postgres-async2' then
     if GetEnvironmentVariable('TFB_TEST_NAME') = 'mormot-postgres-async2' then