azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Set-AzureStorageBlobContent Command uses constant 13-14% CPU After Executing CMDLET

Open MCrank opened this issue 9 years ago • 20 comments

Cmdlet(s)

Set-AzureStorageBlobContent

PowerShell Version

5.1.16296.0

Module Version

3.3.1 Azure.Storage

OS Version

10.0.16296.0

Description

Script that pulls down Azure EA Billing Usage and manipulates the data before saving it back to a .csv file and uploading to an Azure Storage Account. Upon execution of the Set-AzureStorageBlobContent cmdet my CPU hovers around 13-14% CPU even after the script exits. It seems as though this happens whether you use valid values for your parameters. Just merely running the cmdlet causes this to occur.

Debug Output

VERBOSE: Selected Month: 09 VERBOSE: Selected Year: 2017 VERBOSE: 2017-09-25T16:42:49: Azure Enrollment ####### VERBOSE: 2017-09-25T16:42:49: https://ea.azure.com/rest/#########/usage-report?month=2017-09&type=detail) VERBOSE: Rows = 42027 Total Rows = 42027 VERBOSE: 2017-09-25T16:43:25: Fixing datatypes... DEBUG: Resource Group is Empty ... ... 2017-09-25T16:43:27: Saving to file .\UsageDetail_2017-09.csv Backup Done: Location: .\UsageDetail_2017-09.csv DEBUG: 4:43:28 PM - NewAzureStorageContext begin processing with ParameterSet 'AccountNameAndKey'. DEBUG: 4:43:29 PM - NewAzureStorageContext end processing. DEBUG: 4:43:29 PM - Init Operation Context for 'SetAzureBlobContentCommand' with client request id Azure-Storage-PowerShell-8a4600d3-009d-4696-bff4-62dcbd3b18e5. If you want to get more details, please add "-Debug" to your command. DEBUG: 4:43:29 PM - SetAzureBlobContentCommand begin processing with ParameterSet 'SendManual'. DEBUG: 4:43:29 PM - Use storage account 'storage_account_name' from storage context.

ICloudBlob : Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob BlobType : BlockBlob Length : 28305577 ContentType : application/octet-stream LastModified : 9/25/2017 9:43:31 PM +00:00 SnapshotTime : ContinuationToken : Context : Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext Name : ./UsageDetail_2017-09.csv

DEBUG: 4:43:32 PM - SetAzureBlobContentCommand end processing, Start 1 remote calls. Finish 1 remote calls. Elapsed time 3101.64 ms. Client operation id: Azure-Storage-PowerShell-8a4600d3-009d-4696-bff4-62dcbd3b18e5. DEBUG: 4:43:32 PM - SetAzureBlobContentCommand end processing. VERBOSE: Transfer Summary -------------------------------- Total: 1. Successful: 1. Failed: 0.

Script/Steps for Reproduction

At this point basically just use the Set-AzureStorageBlobContent cmdlet to try and upload a file to azure storage. Run the following commands to reproduce. You can of course use valid fields and get the same results.

$ctx = New-AzureStorageContext -StorageAccountName "darthvader" -StorageAccountKey "mySuperSecretKey"
Set-AzureStorageBlobContent -File "notafile.txt" -Container "BogusContainer" -Blob "GreatMovie" -Context $ctx

I just started a new PowerShell window and ran this and was able to reproduce.

Set-AzureStorageBlobContent -File notafile.txt -Container "BogusContainer" -Blob "GreatMovie" -Context $ctx

MCrank avatar Sep 25 '17 22:09 MCrank

@MCrank Is this something that is new in the most recent version fo the cmdlets, or have you notice this in earlier versions?

markcowl avatar Sep 25 '17 23:09 markcowl

@markcowl It is relatively new for me as this is a fairly new script. I only noticed it because my machine was running a bit sluggish compared to normal and I saw that powershell.exe was running at a constant 13-14%. I started to dig in using process explorer but could not see too far into the process. So today I just put a breakpoint and stepped through the code watching the CPU as I did. No sooner than the storage cmdlet fired it did this exact symptom. I thought I might need to dispose a connection or something somewhere in my code but found out it was coming from this cmdlet.

I was able to reproduce on a colleague's machine, who is also running Windows 10 but not the Fast Ring build I have. Just before I left work I had another colleague run it on one of our jump boxes running in Azure (Windows Server 2012 R2) and did not see the issue. I'll log in and test some more in a bit and get the PoSh version etc for that server.

MCrank avatar Sep 26 '17 00:09 MCrank

@markcowl I just tested on my home machine, also Windows 10 with the latest Azure.Storage module pulled form the Gallery with the same results.

PS C:\WINDOWS\system32> Get-Module -Name Azure.Storage

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     3.4.0      Azure.Storage                       {Get-AzureStorageBlob


PS C:\WINDOWS\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.608
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.608
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

MCrank avatar Sep 26 '17 01:09 MCrank

@blueww Can you please take a look?

markcowl avatar Feb 06 '18 23:02 markcowl

Just to add that this issue is still occurring with the latest version of Azure.Storage. I also just ran the Reproduction tests mentioned above and am seeing the same results.

azurestorage_version

azurestorage_cpu

MCrank avatar Feb 07 '18 13:02 MCrank

@MCrank, Set-AzureStorageBlobContent cmdlet is implemented based on DMlib, and caused by DMlib issue for the CPU usage after finish all jobs: https://github.com/Azure/azure-storage-net-data-movement/issues/66.

I will update PowerShell when DMlib fix this issue.

blueww avatar Feb 13 '18 05:02 blueww

@blueww Has this issue been fixed?

maddieclayton avatar Jul 17 '18 22:07 maddieclayton

@maddieclayton This has not been fixed, and DMlib has not fixed this.

blueww avatar Jul 18 '18 02:07 blueww

@blueww Just wanted to reach out to see if there is any movement on this? This is still an ongoing problem that still does not seem to be fixed.

Just to follow up I looked at the issue Azure/azure-storage-net-data-movement#66 and it looks like there may have been a community PR that went into 0.8.0 / 0.8.1 that might have helped. Another poster in that thread said this did not help though.

MCrank avatar Feb 15 '19 18:02 MCrank

@MCrank The PR in https://github.com/Azure/azure-storage-net-data-movement/issues/66 is still not merged.

I have just tried to repro it on the lastest Az.Storage Module.

After upload a 2MB file, the CPU keeps 2-3% on my machine (my machine is 4 core). So it's seems not so high as the issue. Could you give more detail for your recent repro of the problem:

  1. which version of storage module (run get-module)
  2. The size/Count of file(s) that you upload/download? (better with your repro script, hide credential)
  3. You machine configure (CPU, memory)
  4. What's the CPU usage after upload/download finish?

blueww avatar Feb 18 '19 07:02 blueww

Close the issue due to idle time. Please reopen if there is still question.

zhusijia26 avatar Jun 06 '19 20:06 zhusijia26

The issue is still happening... 😢 I'll upload the repo steps when I get a chance to look at it.

MCrank avatar Jun 06 '19 20:06 MCrank

@MCrank Just reopened the issue. Please provide details when you get a chance :)

zhusijia26 avatar Jun 06 '19 20:06 zhusijia26

Will do. Just wrapping up a bit here and I will try with the latest Az.Storage module as @blueww mentioned above

MCrank avatar Jun 06 '19 21:06 MCrank

@zhusijia26 @blueww I just ran the repro steps I initially tested in the initial post with the latest Az.Storage module and I am still seeing a higher than normal CPU usage. It is not at 15% but still hovering around 6%-8% for PowerShell.

  1. Az.Storage 1.3.0
  2. Upload 1 FIle ~145MB (.Net Core SDK)
  3. Intel Core i7-6700HQ Quad Core with Hyper-Thread/16GB RAM
  4. CPU for the powershell process after upload is around 6%-9%

image

MCrank avatar Jun 06 '19 23:06 MCrank

@MCrank Thanks for the information! We will continue investigate the issue.

blueww avatar Jun 10 '19 02:06 blueww

I can repro the issue on my machine with 8 cores. After transfer a 600MB file, the CPU usage will keep 3-5% for Powershell.exe. I have discussed with DMlib team, and get some clue on it. We will see how to fix this in DMlib, then Powershell will also be fixed by upgrade to new DMlib.

blueww avatar Jul 04 '19 02:07 blueww

@MCrank We have already merge the fixed DMlib to PSH code base, the issue will be fixed in the next PSH release. (Az.Storage 1.7.0) In my testing, cpu will keep 0% after 1-2 seconds of finish running Set-AzStorageBlobContent. I will close the issue now. Feel free to contact us if need any further assistance.

blueww avatar Sep 18 '19 09:09 blueww

Az.Storage 4.2.0, issue still present: >40% CPU usage on 24-core machine.

DmitryMashkov-DM avatar Feb 09 '22 06:02 DmitryMashkov-DM

@DmitryMashkov-DM

Please give more details for your repro, or better open a new issue, since the original one is fixed and you issue might have different root cause, and following the issue template normally can get most information needed for investigation.

Please give :

  1. The size/Count of file(s) that you upload/download?
  2. Your repro script, hide credential
  3. Please confirm the CPU usage > 40% happens after all transfer finished, or when the upload/download happen?

blueww avatar Feb 09 '22 06:02 blueww