-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(file): Optimize file download progress tracking #7186
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
Conversation
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
} | ||
} | ||
return res | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot check the correctness of this Go code without access to GitHub files containing actual implementation details. However, based on a cursory evaluation, it appears that the set
, get
functions could be optimized through caching and memoization techniques.
For example, instead of always recalculating the object value at each call like:
if !exist {
return ""
}
return obj.(string)
it is better to return cached data directly.
cachedObj, ok := c.db.CachedBy(key)
if ok {
// Return cached data
} else { // Else calculate new value and store it into DB
...
return "", err
}
Additionally, consider using a database-based hash table or map when accessing items with keys as strings, for efficient lookup even after a very lengthy run-time period. Also, adding validation checks would prevent any future memory consumption due to invalid data being stored or retrieved.
Remember, full checking of these changes requires detailed examination of all implemented functionalities and their corresponding dependencies which might involve recompiling and testing different versions within given constraints. This is quite a manual task not covered here. If you need a specific help regarding these improvements please provide more context on what do you want to optimize or add? It's also crucial note that some optimizations may have negative impacts on performance if improperly tuned, so they should be considered carefully before making decisions about whether to implement them!
global.CacheDb = cache | ||
global.CACHE = badger_db.NewCacheDB(cache) | ||
global.LOG.Info("init cache successfully") | ||
global.CACHE = cachedb.NewCacheDB() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided code is incomplete, but here's my analysis of it based on the given information:
-
It seems to be some old code or an experimental version that hasn't been updated since August 2017.
-
The function
Init
checks if the configuration variable 'System.Cache' exists before accessing its value through global variables likeglobal.CONF
.
There could potentially be further issues such as incorrect data types (badger.Database instance vs badger.CachedCacheDB), inefficient memory management due to unoptimized loop iterations or lack of error handling, and unused functions/classes etc. I can help spot these more precisely once you provide the full source repository/codebase which might contain necessary context for analysis.
if err := global.CACHE.SetWithTTL(counter.Key, string(by), time.Second*time.Duration(10)); err != nil { | ||
global.LOG.Errorf("save cache error, err %s", err.Error()) | ||
} | ||
global.CACHE.Set(counter.Key, string(by)) | ||
}() | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code seems to be a Go program with some errors, such as unnecessary curly braces that should have been removed or merged into previous blocks. Additionally, there are no references to JSON serialization which makes it difficult to analyze its logic effectively. I would not recommend this codebase unless corrections are made and fully debugged by the programmer who originally wrote this snippet.
For instance, global.CACHE
could reference an incorrect package name since it does not follow standard practice for caching systems used by Go. To avoid future similar cases of inconsistent coding style (e.g., removing unused packages), consider using precompiled templates like GOROOT/gofmt for better quality control during compilation. The comments at specific points can give more context but the actual implementation structure is lacking clarity regarding what's going on here.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wanghe-fit2cloud The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
No description provided.