EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/276889
Change subject: Encode data transfered between processes in
StreamingForkController
......................................................................
Encode data transfered between processes in StreamingForkController
I can't explain what exactly was happening, all the data we send over
this pipe should already be json encoded, but by encoding the data this
removes the 30s+ pause at the end of every forked runSearch.php test
run.
Change-Id: I7bf0577c34c9e3952e24481a7c2d862f0cbcb756
---
M includes/Maintenance/OrderedStreamingForkController.php
1 file changed, 9 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/89/276889/1
diff --git a/includes/Maintenance/OrderedStreamingForkController.php
b/includes/Maintenance/OrderedStreamingForkController.php
index 9aab4b4..fe675bb 100644
--- a/includes/Maintenance/OrderedStreamingForkController.php
+++ b/includes/Maintenance/OrderedStreamingForkController.php
@@ -109,9 +109,9 @@
while ( !feof( $this->input ) ) {
$line = trim( fgets( $this->input ) );
if ( $line ) {
- list( $id, $data ) = explode( ':', $line, 2 );
+ list( $id, $data ) = json_decode( $line );
$result = call_user_func( $this->workCallback,
$data );
- fwrite( $this->output, "$id:$result\n" );
+ fwrite( $this->output, json_encode( array( $id,
$result ) ) . "\n" );
}
}
}
@@ -139,7 +139,7 @@
$used = array();
$id = 0;
$this->nextOutputId = 0;
-
+
while ( !feof( $this->input ) ) {
$data = fgets( $this->input );
if ( $used ) {
@@ -147,11 +147,12 @@
$this->updateAvailableSockets(
$sockets, $used, $sockets ? 0 : 5 );
} while( !$sockets );
}
- if ( !trim( $data ) ) {
+ $data = trim( $data );
+ if ( !$data ) {
continue;
}
$socket = array_pop( $sockets );
- fputs( $socket, $id++ . ':' . $data );
+ fwrite( $socket, json_encode( array( $id++, $data ) ) .
"\n" );
$used[] = $socket;
}
while ( $used ) {
@@ -174,7 +175,7 @@
stream_select( $read, $write, $except, $timeout );
foreach ( $read as $socket ) {
$line = fgets( $socket );
- list( $id, $data ) = explode( ':', $line, 2 );
+ list( $id, $data ) = json_decode( trim( $line ) );
$this->receive( (int) $id, $data );
$sockets[] = $socket;
$idx = array_search( $socket, $used );
@@ -187,10 +188,10 @@
$this->delayedOutputData[$id] = $data;
return;
}
- fwrite( $this->output, $data );
+ fwrite( $this->output, $data . "\n" );
$this->nextOutputId = $id + 1;
while ( isset( $this->delayedOutputData[$this->nextOutputId] )
) {
- fwrite( $this->output,
$this->delayedOutputData[$this->nextOutputId] );
+ fwrite( $this->output,
$this->delayedOutputData[$this->nextOutputId] . "\n" );
unset( $this->delayedOutputData[$this->nextOutputId] );
$this->nextOutputId++;
}
--
To view, visit https://gerrit.wikimedia.org/r/276889
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7bf0577c34c9e3952e24481a7c2d862f0cbcb756
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits