Skip to content

Smarter search batching#16333

Merged
roblourens merged 5 commits intomasterfrom
roblou/smarterSearchBatching
Dec 2, 2016
Merged

Smarter search batching#16333
roblourens merged 5 commits intomasterfrom
roblou/smarterSearchBatching

Conversation

@roblourens
Copy link
Member

@roblourens roblourens commented Dec 1, 2016

If the search process batch isn't filled in 2 seconds, it's sent to the frontend anyway. After 50 results are returned, it reverts to the original batching behavior. Also fixed to batch by actual number of results, instead of 'number of files with matches' which it ended up doing before.

Fixes #16284

@roblourens roblourens added the search Search widget and operation issues label Dec 1, 2016
/**
* Collects a batch of items that each have a size. When the cumulative size of the batch reaches 'maxBatchSize', it calls the callback.
* If the batch isn't filled within 'timeout' ms, the callback is also called.
* And after 'batchOnlyAfter' items, the timeout is ignored, and the callback is called only when the batch is full.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

batchOnlyAfter seems misleading, we batch before too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I mean it as "after N, only batch" but it also looks like "only batch after N, not before". Maybe stopTimeoutAfter or timeoutItemsLimit or something...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runTimeoutUntilCount maybe

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you want to follow the suggestion further up to have a short timeout first and after a while switch a long timeout. :)

}

flush(): void {
this.totalNumberCompleted += this.batchSize;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if this.batchSize > 0?

private doSearchWithBatchTimeout(engine: ISearchEngine<ISerializedFileMatch>, batchSize: number): PPromise<ISerializedSearchComplete, IRawProgressItem<ISerializedFileMatch>> {
return new PPromise<ISerializedSearchComplete, IRawProgressItem<ISerializedFileMatch>>((c, e, p) => {
// Use BatchedCollector to get new results to the frontend every 2s at least, until 50 results have been returned
const collector = new BatchedCollector(batchSize, /*timeout=*/2000, /*batchOnlyAfter=*/50, p);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 2s is a long time. What about using 500ms initially and after 5s start using a timeout of 2s? That would ensure that the first results are show quickly and that progress is visible even for very long running searches.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. I picked 2 partly because it's hard to interact with the results when they are changing, since they come in slightly random order. It would be good to get at least some results in faster than 2s though.

@roblourens roblourens merged commit dce380b into master Dec 2, 2016
@roblourens roblourens deleted the roblou/smarterSearchBatching branch July 3, 2017 16:33
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

search Search widget and operation issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve batching between search process and frontend

3 participants