Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Merge requests
  • !5014

Merged
Created 11 years ago by Administrator@rootOwner

Improved large commit handling.

  • Overview 20
  • Commits 1
  • Changes 11

Created by: bladealslayer

Previously, only number of changed files mattered. Now, the number of lines to render in the diff are also taken into account.

A hard limit is set, above which diffs are not rendered and users are not allowed to override that. This prevents high server resource usage with huge commits.

Related to #1745 (closed), #2259 (closed)

In addition, handle large commits for MergeRequests and Compare controllers.

Also fixes a bug where diffs are loaded twice, if user goes directly to merge_requests/:id/diffs URL.

Loading
Loading

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: coveralls

    Coverage Status

    Coverage decreased (-0.27%) when pulling 01ff084a on bladealslayer:feature/big-commit-improvements into 71d31a38 on gitlabhq:master.

    By Administrator on 2013-09-07T12:33:02 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: bladealslayer

    The main motivation for this improvement is that:

    1. commits with small number of files changed, but huge number of lines are rendered (e.g. 50 files with 500 000 lines changed)
    2. when hiding diffs for large files, the backend still renders the diffs - they are just hidden by default from the page

    Both of these cases can be quite CPU intensive on the server.

    Some more discussion on the feedback entry: http://feedback.gitlab.com/forums/176466-general/suggestions/3787993-hide-files-with-many-changes-in-a-diff-to-improve-

    By Administrator on 2013-09-07T12:49:16 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dosire

    Thanks @bladealslayer for making this code, I've just asked Dmitriy to take a look at it.

    By Administrator on 2013-09-07T17:23:41 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: bladealslayer

    You're welcome! I'm interested to get some feedback.

    By Administrator on 2013-09-07T21:44:18 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dzaporozhets

    @bladealslayer Cool PR. I merge it

    By Administrator on 2013-09-08T08:14:48 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: DenisBY

    How to disable it or force to show the diff? I see that there should be:

    +        If you still want to see the diff
    +        = link_to "click this link", url_for(force_show_diff: true), class: "underlined_link"

    But I don't have this link.

    By Administrator on 2013-09-23T14:49:41 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: bladealslayer

    @DenisBY, the link won't appear if the commit is "really big", which means more than 500 changed files or more than 10 000 lines to render (changed lines + context). This is a hard limit, that can't be overridden by the user (using the front-end), to prevent server load.

    Such diffs can still be downloaded as patch or plain diff.

    The link to force show the diff appears for "moderately sized" diffs, which means more than 100 changed files or more than 5000 lines of diff to render, but not more than the hard limits above.

    So, basically, diffs are split in 3 categories - normal, "moderately big" and "really big".

    The limits are set in https://github.com/gitlabhq/gitlabhq/blob/master/app/models/commit.rb#L13

    By Administrator on 2013-09-23T17:30:59 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: DenisBY

    @bladealslayer this commit is 25 png files.

    By Administrator on 2013-09-23T18:39:26 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: bladealslayer

    @DenisBY Interesting... I think I didn't test this with binary files. Might need to improve their handling.

    By Administrator on 2013-09-23T18:54:46 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: DenisBY

    It would be nice. Thank you!

    By Administrator on 2013-09-23T19:04:07 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: bladealslayer

    @randx what do you think if implementation would ignore image files when calculating total line count in the diff? Image files would still count towards the number of files changed in the diff. That way, large image files won't prevent the diff from rendering.

    So something like:

    def self.diff_line_count(diffs)
      image_types = ['.png', '.jpg', '.jpeg', '.gif']
      diffs.select{|d| not image_types.include?(File.extname(d.new_path || d.old_path))}.reduce(0){|sum, d| sum + d.diff.lines.count}
    end

    By Administrator on 2013-09-23T20:33:37 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dosire

    Png files are binaries that contain many commit lines. That is why you do not see a diff. We are open to merge requests that show a partial diff (which files changed) in this case.

    By Administrator on 2013-09-23T20:34:37 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dosire

    I only now read your comment. Great idea, can you submit a tested pull request?

    By Administrator on 2013-09-23T20:37:52 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dzaporozhets

    @bladealslayer yeap we should ignore image files

    By Administrator on 2013-09-24T06:34:55 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: bladealslayer

    Hmmm. The correct way to do this would be to ignore all but the text files. Looks like that other parts of the code use something like Gitlab::Git::Blob.new(project.repository, @commit.id, @ref, diff.new_path).text? to determine if a file is text. However, inside the Commit model, I can't access neither the project, nor the repository. What would you suggest as the best way to filter out all non-text files, @randx?

    My suggestion in the comments above would work for images, but still won't cover when other binary files are in a commit.

    By Administrator on 2013-09-29T19:03:54 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dosire

    @bladealslayer Your proposal makes sense. Can you maybe link to the existing code?

    By Administrator on 2013-09-30T07:37:42 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: bladealslayer

    @dosire For example here: https://github.com/gitlabhq/gitlabhq/blob/master/app/views/projects/commits/_diffs.html.haml#L40 and later in the same file there is if file.text?.

    By Administrator on 2013-09-30T07:41:09 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dosire

    @bladealslayer Indeed https://github.com/gitlabhq/gitlabhq/blob/master/app/views/projects/commits/_diffs.html.haml#L63 seems to be it. The best thing would be if someone creates a pull request to use .text? instead of the current filter for images.

    By Administrator on 2013-09-30T08:43:49 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: bladealslayer

    @dosire as I wrote above, the problem is that the Commit model, where we have the commit size calculation logic, doesn't have access to project/repository, which seems needed to have a Gitlab::Git::Blob object.

    By Administrator on 2013-09-30T10:29:35 (imported from GitLab project)

  • Administrator
    Administrator @root · 11 years ago
    Owner

    Created by: dosire

    @bladealslayer Thanks, I read over that the first time. Waiting for a suggestion from @randx I guess.

    By Administrator on 2013-09-30T14:16:48 (imported from GitLab project)

  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
0 Assignees
Assign to
0 Reviewers
Request review from
Milestone
No milestone
None
None
Time tracking
0
Labels
None
Assign labels
  • No matching results
  • Manage project labels
Lock merge request
Unlocked
participants
Reference:
Source branch: github/fork/bladealslayer/feature/big-commit-improvements

    0 pending comments