Skip to content

Refactor Git Attribute & performance optimization #34154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Apr 11, 2025

Conversation

lunny
Copy link
Member

@lunny lunny commented Apr 8, 2025

This PR moved git attributes related code to modules/git/attribute sub package and moved language stats related code to modules/git/languagestats sub package to make it easier to maintain.

And it also introduced a performance improvement which use the git check-attr --source which can be run in a bare git repository so that we don't need to create a git index file. The new parameter need a git version >= 2.40 . If git version less than 2.40, it will fall back to previous implementation.

Before:

git-run duration=1.2684s func.caller=git.(*Repository).readTreeToIndex git.command="/opt/homebrew/bin/git ...global... read-tree 70187f7727d4ddd8282b576ece93ca233e88b19e"
git-run duration=0.1633s func.caller=git.(*CheckAttributeReader).Run git.command="/opt/homebrew/bin/git ...global... check-attr --stdin -z --cached linguist-vendored linguist-generated linguist-documentation linguist-detectable linguist-language gitlab-language"

After:

git-run duration=0.1271s func.caller=attribute.(*BatchChecker).run git.command="/opt/homebrew/bin/git ...global... check-attr -z --source 70187f7727d4ddd8282b576ece93ca233e88b19e linguist-vendored linguist-generated linguist-language gitlab-language --stdin"

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 8, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Apr 8, 2025
@lunny lunny force-pushed the lunny/attribute branch 2 times, most recently from 63a9836 to e949f75 Compare April 10, 2025 00:21
@lunny lunny force-pushed the lunny/attribute branch from 960b082 to 2d8c956 Compare April 11, 2025 02:18
@lunny lunny added type/refactoring Existing code has been cleaned up. There should be no new functionality. performance/speed performance issues with slow downs labels Apr 11, 2025
@lunny lunny added this to the 1.24.0 milestone Apr 11, 2025
@lunny lunny changed the title Refactor Git Attribute Refactor Git Attribute & performance optimization Apr 11, 2025
@lunny lunny marked this pull request as ready for review April 11, 2025 02:51
@lunny lunny requested review from wxiaoguang and yp05327 April 11, 2025 02:51
@wxiaoguang wxiaoguang removed their request for review April 11, 2025 03:26
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 11, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 11, 2025
@wxiaoguang wxiaoguang merged commit ae0af8e into go-gitea:main Apr 11, 2025
26 checks passed
@wxiaoguang wxiaoguang deleted the lunny/attribute branch April 11, 2025 13:41
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 14, 2025
* giteaofficial/main: (27 commits)
  fix github migration error when using multiple tokens (go-gitea#34144)
  Add package version api endpoints (go-gitea#34173)
  Fix incorrect file links (go-gitea#34189)
  Add cache for common package queries (go-gitea#22491)
  Allow admins and org owners to change org member public status (go-gitea#28294)
  Fix span svg layout (go-gitea#34185)
  fix webhook url (go-gitea#34186)
  Optimize overflow-menu (go-gitea#34183)
  Move and rename UpdateRepository (go-gitea#34136)
  Update milestones.tmpl (go-gitea#34184)
  [skip ci] Updated translations via Crowdin
  Refactor Git Attribute & performance optimization (go-gitea#34154)
  [skip ci] Updated translations via Crowdin
  fix(go-gitea#33711): cross-publish docker images to ghcr.io (go-gitea#34148)
  refactor organization menu (go-gitea#33928)
  feat: Add sorting by exclusive labels (issue priority) (go-gitea#33206)
  Fix vertical centering of file tree icons and use entryIcon for submodules/symlinks (go-gitea#34137)
  bugfix check for alternate ssh host certificate location (go-gitea#34146)
  Cache GPG keys, emails and users when list commits (go-gitea#34086)
  Set MERMAID_MAX_SOURCE_CHARACTERS to 50000 (go-gitea#34152)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code performance/speed performance issues with slow downs type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants