Let the caller say how long a page may be drawn for - #16
Merged
Conversation
Options.MaxPixels bounds what comes out of a page. Nothing bounded the work of making it, so a caller drawing somebody else's file had no way to say how long it was prepared to wait — and some pages take a very long time. Measured over 59 432 corpus pages at half again their own size: 1 131 were still being drawn after twenty seconds, and one figure took two hundred and seventy-three. Two hours of measuring this corpus ended with every worker but one finished and the last grinding on a single page with fifteen gigabytes resident. A page that cannot be given up on is a page that can take a machine away from whoever was using it. Options.MaxDuration is how long it may have. Zero means as long as it takes, which is what this did before there was anywhere to say otherwise, so nothing already written changes. When the time goes, the page stops being drawn and comes back as far as it got, with ErrTimedOut — deliberately not a blank, since half a page is worth more than none to somebody scrolling, and the error says plainly that it is half. The clock is looked at once every 256 operations rather than on every one: asking the machine the time is dear beside drawing a line. A page of a hundred thousand operations therefore asks four hundred times. It costs nothing. Over 3 000 corpus pages, with no budget set: 1:07 against 1:14 without the code at all — the difference is noise, and the wrong way round. Of the 2 991 pages both runs drew, not one hash differs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Options.MaxPixelsbounds what comes out of a page. Nothing bounded the work of making it, so a caller drawing somebody else's file had no way to say how long it was prepared to wait.Measured
Over 59 432 corpus pages at half again their own size: 1 131 were still being drawn after twenty seconds, and one figure took 273. Measuring this corpus once ended with every worker but one finished and the last grinding on a single page with 15.3 GB resident — a page that cannot be given up on is a page that can take a machine away from whoever was using it.
What it does
Options.MaxDuration. Zero means as long as it takes, which is what this did before, so nothing already written changes. When the time goes the page comes back as far as it got, withErrTimedOut— deliberately not a blank: half a page is worth more than none to somebody scrolling, and the error says plainly that it is half.The clock is looked at once every 256 operations, not on every one: asking the machine the time is dear beside drawing a line.
It costs nothing
Over 3 000 corpus pages with no budget set: 1:07 against 1:14 without the code at all — the difference is noise, and the wrong way round. Of the 2 991 pages both runs drew, not one hash differs.
100% statement coverage,
go vetandgofmtclean, nine cross-compile targets.