jenkins-bot has submitted this change and it was merged.
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, 8 insertions(+), 7 deletions(-)
Approvals:
DCausse: Looks good to me, approved
jenkins-bot: Verified
Objections:
Cindy-the-browser-test-bot: There's a problem with this change, please improve
diff --git a/includes/Maintenance/OrderedStreamingForkController.php
b/includes/Maintenance/OrderedStreamingForkController.php
index 9aab4b4..bbc0a26 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" );
}
}
}
@@ -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: merged
Gerrit-Change-Id: I7bf0577c34c9e3952e24481a7c2d862f0cbcb756
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: Cindy-the-browser-test-bot <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits