Skip to content

handle diff-too-large scenario with less crashes - #1893

Merged
joshaber merged 22 commits into
masterfrom
encode-locally-not-internally
Jun 7, 2017
Merged

joshaber merged 22 commits into
masterfrom
encode-locally-not-internally

Conversation

@shiftkey

@shiftkey shiftkey commented Jun 5, 2017 •

Copy link
Copy Markdown
Member

🌵 🌵 🌵 Depends on #1897 - go review that first 🌵 🌵 🌵

Fixes #1818
Fixes #1524

This switches diff parsing over to use a spawn based API so we can lazily encode the diff and handle the scenario where a file diff exceeds the kMaxLength limitation Node enforces when creating strings. There's probably some performance improvements we can address in here afterwards, but we need to be mindful of this limitation because it's a hard limit which can lead to tearing down the process.

screen shot 2017-06-05 at 11 34 27 am

  • [ ] identify why multiple invocations are occurring - can we eliminate these? 👢

  • diff tests are impacted by this change, gotta figure out if this can be supported

Uncovered Issues

While fixing this I've identified a couple of performance areas we should look at:

  • there's no indicator going on for when a diff takes more than a moment to render. In this extreme case, the execution of Git can take up to 20 seconds. It would be nice to show some sort of "working" indicator in these situations: show a "working" indicator when Git is computing a large diff #1913
  • git status may take multiple seconds to complete, which is really noticeable on the initial load for this repository as we don't have any repository state to work with. In lieu of speeding that up, perhaps we need some sort of indicator there too: show a "working" indicator when git status is executing #1914
  • AppStore._loadStatus will always try and redraw the diff, and it doesn't get caught by our existing checks for when a diff can be skipped or ignored. It'd be nice to abort a Git invocation (we could do this now), but promises don't support this directly so it'll require some more refactoring to the abstractions: AppStore._loadStatus should not queue up multiple diffs #1915

I'll move these out to other issues before this gets closed out, I just wanted to write them down now while they're in front of me. Let me know your feels on these above things.

@shiftkey
shiftkey force-pushed the encode-locally-not-internally branch from c3a289f to 21c3ef8 Compare June 5, 2017 16:02
@shiftkey shiftkey mentioned this pull request Jun 5, 2017
@shiftkey
shiftkey force-pushed the encode-locally-not-internally branch 5 times, most recently from 90600b8 to a39d8df Compare June 5, 2017 19:16
Comment thread app/src/lib/git/diff.ts Outdated

This comment was marked as spam.

This comment was marked as spam.

@shiftkey
shiftkey force-pushed the encode-locally-not-internally branch from 4de45e2 to 28eed8d Compare June 5, 2017 20:01
@shiftkey
shiftkey force-pushed the encode-locally-not-internally branch from 1c87f89 to 3f59669 Compare June 5, 2017 20:58
@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jun 6, 2017
@shiftkey shiftkey mentioned this pull request Jun 6, 2017
2 tasks done
@joshaber joshaber self-assigned this Jun 6, 2017

@joshaber joshaber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some nits, but this looks like a nice improvement 👍

Comment thread app/src/models/diff.ts Outdated
export interface IDiffTooLarge {
readonly kind: DiffType.TooLarge
/**
* The length of the diff output from Git which exceeds the runtime limits

This comment was marked as spam.

Comment thread app/test/unit/git/rev-parse-test.ts Outdated
let repository: Repository | null = null

beforeEach(() => {
beforeEach(async () => {

This comment was marked as spam.

Comment thread script/test-setup
const { getUserDataPath } = require('./dist-info')

const output = cp.execSync('git config -l --show-origin', { encoding: 'utf-8' })
console.log(`${output}\n\n`)

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/lib/git/diff.ts
const stdout = new Array<Buffer>()

process.stdout.on('data', (chunk) => {
if (chunk instanceof Buffer) {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/lib/git/diff.ts Outdated
}
}

const maximumStringSize = 268435441

This comment was marked as spam.

Comment thread app/src/lib/git/diff.ts

const startTime = (performance && performance.now) ? performance.now() : null

const process = GitProcess.spawn(args, path)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@joshaber

joshaber commented Jun 6, 2017

Copy link
Copy Markdown
Contributor

While fixing this I've identified a couple of performance areas we should look at:

Yeah, breaking this up into separate issues would be ✨

@joshaber

joshaber commented Jun 6, 2017

Copy link
Copy Markdown
Contributor

This looks good but needs a merge now 🙈

@joshaber

joshaber commented Jun 7, 2017

Copy link
Copy Markdown
Contributor

👍

@joshaber
joshaber merged commit fe66f83 into master Jun 7, 2017
@joshaber
joshaber deleted the encode-locally-not-internally branch June 7, 2017 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants