@@ -106,9 +106,9 @@ public function execute(string $endpoint, string $path, array $options)
106
106
$ initialDataCount = (int )($ options ["-initial-data-count " ] ?? Defaults::GENERATOR_DATA_COUNT );
107
107
$ promPgw = ($ options ["-prom-pgw " ] ?? Defaults::PROMETHEUS_PUSH_GATEWAY );
108
108
$ reportPeriod = (int )($ options ["-report-period " ] ?? Defaults::PROMETHEUS_PUSH_PERIOD );
109
- $ readForks = ((int )($ options ["-read-rps " ] ?? Defaults::READ_RPS )) / Defaults:: RPS_PER_READ_FORK ;
109
+ $ readRps = ((int )($ options ["-read-rps " ] ?? Defaults::READ_RPS ));
110
110
$ readTimeout = (int )($ options ["-read-timeout " ] ?? Defaults::READ_TIMEOUT );
111
- $ writeForks = ((int )($ options ["-write-rps " ] ?? Defaults::WRITE_RPS )) / Defaults:: RPS_PER_WRITE_FORK ;
111
+ $ writeRps = ((int )($ options ["-write-rps " ] ?? Defaults::WRITE_RPS ));
112
112
$ writeTimeout = (int )($ options ["-write-timeout " ] ?? Defaults::WRITE_TIMEOUT );
113
113
$ time = (int )($ options ["-time " ] ?? Defaults::READ_TIME );
114
114
$ shutdownTime = (int )($ options ["-shutdown-time " ] ?? Defaults::SHUTDOWN_TIME );
@@ -125,12 +125,12 @@ public function execute(string $endpoint, string $path, array $options)
125
125
126
126
$ readPIds = $ this ->forkJob (function (int $ i ) use ($ endpoint , $ path , $ tableName , $ initialDataCount , $ time , $ readTimeout , $ shutdownTime , $ startTime ) {
127
127
$ this ->readJob ($ endpoint , $ path , $ tableName , $ initialDataCount , $ time , $ readTimeout , $ i , $ shutdownTime , $ startTime );
128
- }, $ readForks );
128
+ }, Defaults:: READ_FORKS );
129
129
$ pIds = array_merge ($ pIds , $ readPIds );
130
130
131
131
$ writePIds = $ this ->forkJob (function (int $ i ) use ($ endpoint , $ path , $ tableName , $ initialDataCount , $ time , $ writeTimeout , $ shutdownTime , $ startTime ) {
132
132
$ this ->writeJob ($ endpoint , $ path , $ tableName , $ initialDataCount , $ time , $ writeTimeout , $ i , $ shutdownTime , $ startTime );
133
- }, $ writeForks );
133
+ }, Defaults:: WRITE_FORKS );
134
134
$ pIds = array_merge ($ pIds , $ writePIds );
135
135
136
136
foreach ($ pIds as $ pid ) {
@@ -185,7 +185,7 @@ protected function readJob(string $endpoint, string $path, $tableName, int $init
185
185
$ dataGenerator = new DataGenerator ($ initialDataCount );
186
186
$ query = sprintf (Defaults::READ_QUERY , $ tableName );
187
187
$ table = $ ydb ->table ();
188
- $ i = 0 ;
188
+ $ table -> createSession () ;
189
189
190
190
while (microtime (true ) <= $ startTime + $ time ) {
191
191
$ begin = microtime (true );
@@ -213,10 +213,6 @@ protected function readJob(string $endpoint, string $path, $tableName, int $init
213
213
} catch (\Exception $ e ) {
214
214
$ table ->getLogger ()->error ($ e ->getMessage ());
215
215
Utils::metricFail ("read " , $ this ->queueId , $ attemps , get_class ($ e ), $ this ->getLatencyMilliseconds ($ begin ));
216
- } finally {
217
- $ i ++;
218
- $ delay = $ this ->getDelayMicroseconds ($ startTime , Defaults::RPS_PER_READ_FORK , $ i );
219
- usleep ($ delay > 0 ? $ delay : 1 );
220
216
}
221
217
}
222
218
}
@@ -227,7 +223,7 @@ protected function writeJob(string $endpoint, string $path, $tableName, int $ini
227
223
$ dataGenerator = new DataGenerator ($ initialDataCount );
228
224
$ query = sprintf (Defaults::WRITE_QUERY , $ tableName );
229
225
$ table = $ ydb ->table ();
230
- $ i = 0 ;
226
+ $ table -> createSession () ;
231
227
while (microtime (true ) <= $ startTime + $ time ) {
232
228
$ begin = microtime (true );
233
229
Utils::metricsStart ("write " , $ this ->queueId );
@@ -248,10 +244,6 @@ protected function writeJob(string $endpoint, string $path, $tableName, int $ini
248
244
} catch (\Exception $ e ) {
249
245
$ table ->getLogger ()->error ($ e ->getMessage ());
250
246
Utils::metricFail ("write " , $ this ->queueId , $ attemps , get_class ($ e ), $ this ->getLatencyMilliseconds ($ begin ));
251
- } finally {
252
- $ i ++;
253
- $ delay = $ this ->getDelayMicroseconds ($ startTime , Defaults::RPS_PER_WRITE_FORK , $ i );
254
- usleep ($ delay > 0 ? $ delay : 1 );
255
247
}
256
248
}
257
249
}
@@ -333,11 +325,6 @@ protected function getLatencyMilliseconds(float $begin): float
333
325
return (microtime (true ) - $ begin ) * 1000 ;
334
326
}
335
327
336
- protected function getDelayMicroseconds (float $ startTime , int $ rps , int $ i ): float
337
- {
338
- return $ startTime * 1000000 + $ i * 1000000 / $ rps - microtime (true ) * 1000000 ;
339
- }
340
-
341
328
protected $ errors = [
342
329
"GRPC_CANCELLED " ,
343
330
"GRPC_UNKNOWN " ,
0 commit comments