Skip to content
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

refactor: Preallocate pieceDigests slice in genMetadata for improved #3325

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

yantingqiu
Copy link
Contributor

@yantingqiu yantingqiu commented Jun 14, 2024

Description

Optimized the pieceDigests slice initialization in the genMetadata function by preallocating space based on t.TotalPieces. This change avoids dynamic slice resizing during runtime, which enhances the performance especially when handling large data sets.

Related Issue

Motivation and Context

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

…performance.

Signed-off-by: yantingqiu <1173578083@qq.com>
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.70%. Comparing base (1c9484a) to head (afb3c7d).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3325      +/-   ##
==========================================
+ Coverage   52.66%   52.70%   +0.03%     
==========================================
  Files         192      192              
  Lines       20427    20427              
==========================================
+ Hits        10758    10766       +8     
+ Misses       8863     8859       -4     
+ Partials      806      802       -4     
Flag Coverage Δ
unittests 52.70% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
client/daemon/storage/local_storage.go 32.37% <100.00%> (ø)

... and 6 files with indirect coverage changes

Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@jim3ma jim3ma left a comment

Choose a reason for hiding this comment

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

LGTM

@jim3ma jim3ma merged commit fae3613 into dragonflyoss:main Jul 3, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants