Browse Source

[mORMot] pipelining: (#7926)

- /queries and /updates for raw test case: Postgres SQL pipelining uses `Bind->Exec->Sync` as required by General Rule 7
 - /plaintext: improved HTTP pipelining on mORMot level - added response buffering to minimize send syscall`s
 - general optimization: use aggressive compiler optimization level (-O4)

Co-authored-by: pavel.mash <[email protected]>
pavelmash 2 years ago
parent
commit
6533bea452

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

@@ -40,7 +40,7 @@ echo "Unpacking to ./libs/mORMot/static ..."
 rm -rf ./mormot2static.7z
 
 # uncomment for fixed commit URL
-URL=https://github.com/synopse/mORMot2/tarball/7cc9e10d6dfbe531ded16aa7f9ccd0fb95f8c6dd
+URL=https://github.com/synopse/mORMot2/tarball/9a186358a3695afc3065853790e90f2868d86e23
 #URL="https://api.github.com/repos/synopse/mORMot2/tarball/$USED_TAG"
 echo "Download and unpacking mORMot sources from $URL ..."
 wget -qO- "$URL" | tar -xz -C ./libs/mORMot  --strip-components=1
@@ -74,7 +74,7 @@ fi
 SUPRESS_WARN=-vm11047,6058,5092,5091,5060,5058,5057,5028,5024,5023,4081,4079,4055,3187,3124,3123,5059,5036,5089,5090
 
 echo "Start compiling..."
-fpc -MDelphi -Sci -Ci -O3 -g -gl -gw2 -Xg -k'-rpath=$ORIGIN' -k-L$BIN \
+fpc -MDelphi -Sci -Ci -O4 -g -gl -gw2 -Xg -k'-rpath=$ORIGIN' -k-L$BIN \
   -T$TARGET -P$ARCH \
   -veiq -v-n-h- $SUPRESS_WARN \
   -Fi"$BIN/fpc-$ARCH_TG/.dcu" -Fi"$MSRC" \

+ 6 - 8
frameworks/Pascal/mormot/src/raw.pas

@@ -181,7 +181,7 @@ begin
      {$endif WITH_LOGS}
      hsoIncludeDateHeader  // required by TPW General Test Requirements #5
     ] + flags);
-  fHttpServer.HttpQueueLength := 100000; // needed e.g. from wrk/ab benchmarks
+  fHttpServer.HttpQueueLength := 10000; // needed e.g. from wrk/ab benchmarks
   fHttpServer.Route.RunMethods([urmGet], self);
   // writeln(fHttpServer.Route.Tree[urmGet].ToText);
   fHttpServer.WaitStarted; // raise exception e.g. on binding issue
@@ -269,21 +269,18 @@ begin
   if not conn.IsConnected then
     conn.Connect;
   // specific code to use PostgresSQL pipelining mode
-  // see test_nosync in
+  // see test_multi_pipelines in
   // https://github.com/postgres/postgres/blob/master/src/test/modules/libpq_pipeline/libpq_pipeline.c
   stmt := conn.NewStatementPrepared(WORLD_READ_SQL, true, true);
-  //w/o transaction pg_stat_statements view returns calls-1 and tfb verify fails
-  conn.StartTransaction;
+  //conn.StartTransaction;
   pConn.EnterPipelineMode;
   pStmt := (stmt as TSqlDBPostgresStatement);
   for i := 0 to cnt - 1 do
   begin
     stmt.Bind(1, RandomWorld);
     pStmt.SendPipelinePrepared;
-    pConn.Flush;
+    pConn.PipelineSync;
   end;
-  pConn.SendFlushRequest;
-  pConn.Flush;
   for i := 0 to cnt - 1 do
   begin
     pStmt.GetPipelineResult;
@@ -292,9 +289,10 @@ begin
     res[i].id := pStmt.ColumnInt(0);
     res[i].randomNumber := pStmt.ColumnInt(1);
     pStmt.ReleaseRows;
+    pConn.CheckPipelineSync;
   end;
   pConn.ExitPipelineMode;
-  conn.commit;
+  //conn.commit;
   result := true;
 end;