-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix: removing duplicated nuget packages folder #746
fix: removing duplicated nuget packages folder #746
Conversation
Please add how this was tested. |
packagesFolderName | ||
) | ||
if (!fs.existsSync(packagesFolder)) { | ||
this.logging.log('Cannot find nuget packages folder in source code') |
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.
Why do we need to log this?
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.
+1. If we invert the if
logic, we can simplify this method. Then reducing the logging becomes natural.
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.
agreed, it is causing unnecessary logs, will remove this.
will add just return here instead of logging
) | ||
if (fs.existsSync(packagesFolder)) { | ||
fs.rmSync(packagesFolder, { recursive: true, force: true }) | ||
this.logging.log(`Removed nuget packages folder: ${packagesFolder}`) |
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.
One more thing: In the log message, we should say why it is removed (e.g. "Removed packages folder {packagesFolder} from directory containing artifacts to be uploaded because it is a duplicate of {nugetFolder}"
).
Going forward, we should be mindful of the messages we log. They should provide enough context so the reader understands the intended behavior without having any knowledge of the code itself.
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.
thanks for suggestion, updated logging message accordingly
… to be copied before zipping
@@ -41,6 +43,21 @@ export class ArtifactManager { | |||
} | |||
} | |||
|
|||
async removeDuplicateNugetPackagesFolder(request: StartTransformRequest) { |
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.
as a potential optimization, is it possible to skip adding these files to the zip in the first place. If I understand correctly right now we spend extra time copying these files in the step before only to end up going through the folder again and deleting them. If we could create the artifacts in a single go that would also make the process more efficient. Is this possible?
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.
yes Ege, thanks for suggestion.
After this hotfix, we will take a stab in detail on optimizing entire zipping with ticket P194692593.
Small reminder to remove the |
Problem
V1642391964
Currently when we are packaging artifacts.zip on the IDE, the nuget packages are part of
This is causing increased artifacts size.
Solution
we are not using packages folder from sourceCode for transformations in Qnet CLI, we are only using nuget packages from references folder.
So we can safely delete packages folder before zipping to save on space.
Simple example on saving space is
Sample applications - Bobs Bookstore
Size of packages folder - 241MB
size of Artifacts zip BEFORE below changes of deduping - 179 MB
size of Artifacts zip AFTER below changes of deduping - 89 MB
![image](https://private-user-images.githubusercontent.com/21162984/406350717-04f2c3cc-e625-4446-87c8-37d952793254.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMDM3OTQsIm5iZiI6MTczOTEwMzQ5NCwicGF0aCI6Ii8yMTE2Mjk4NC80MDYzNTA3MTctMDRmMmMzY2MtZTYyNS00NDQ2LTg3YzgtMzdkOTUyNzkzMjU0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDEyMTgxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQzMjE0ZGI3MjBmYzJjY2VmMDA4Njk3MjBjMTU5YTk0MTVlMjcwMzhiZDNiM2MxYmMzMjM5ZmQ0OGU1OTRmODgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.IL3CGBo1eVECj15sAa9mwbnWMdLMOaf2TQftEFfEr1M)
we are saving almost 45% space in artifacts zipping and thereby for uploads. This will also benefit for customer issues with large codebase
UPDATE :
Also found that copyFile is async and we are zipping / deleting package folder even before all copying is complete. so changed copyFile to Sync operation
Testing
Case : Updated a BobsBookstore application to bloat to 2.3 GB of artifacts.zip.
with deduping, for same project artifacts size is - 1.2 GB
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.