Forum Discussion

alexfreu's avatar
alexfreu
Copper Contributor
Oct 31, 2019

BrowserMetrics

There is a folder %localappdata%\Microsoft\Edge Dev\User Data\BrowserMetrics with thousands of 4 MB files like BrowserMetrics-5D3A8F5A-1AF0.pma that fill up my precious SSD disk space.

Can I remove these or prevent or limit the creation? What is the purpose of these files?

 

I'm currently at Version 79.0.309.5 (Offizielles Build) dev (64-Bit)

 

I think it would be a good idea to make them sparse files on NTFS volumes or compress the folder by default. In my case compressing the folder reduced the size from 8.55 GB to 462 MB.

 

Solution:

I disabled the creation of the files by setting the following registry entry:

 

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Edge]
"MetricsReportingEnabled"=dword:00000000

 

I checked the policy with edge://policy

 

All existing files were deleted after a restart of Edge.

See https://docs.microsoft.com/en-us/DeployEdge/microsoft-edge-policies#metricsreportingenabled

 

38 Replies

  • Hey folks, 

     

    Quick update here from the team - they're still investigating but have requested some additional information.  Even if you've submitted already, if you don't mind submitting again with the new info we'd really appreciate it! 

    1. On edge://support, do you see a Client Id? What is it?
    2. The list of PMA files, with time stamps. Mainly the count of files and oldest date would be interesting.
    3. Run these from a cmd prompt and share the results:
      1. reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber
      2. reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection
      3. reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\ClientState /s
      4. reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\ClientStateMedium /s
    4. edge://local-state/
    5. edge://version/?show-variations-cmd

    If you could head to edge://policy/ and submit feedback (Alt + Shift + I), check to include the screenshot as well as diagnostic data, attach the information requested above, and add the string "TC0317AR-1010LUO-TMEP908" so we can link it to this issue. If you'd like the team to be able to reach out directly, please check to include your email as well.

    • JimGrisham's avatar
      JimGrisham
      Steel Contributor

      Alexandra-R (and Edge team devs):

       

      Other things of note that I've recently noticed (or heard from others):

       

      Spoiler
      1. Edge seems to clean up these files upon launch. It knows how to do that.
      2. Edge behaves differently depending on version
        1. For me, it occurs in:
          1. Edge Stable: Version 89.0.774.63 (Official build) (64-bit)
          2. Edge Canary: Version 91.0.837.0 (Official build) (64-bit)
        2. It does not occur in:
          1. Edge Beta: Version 90.0.818.22 (Official build) beta (64-bit)
        3. Therefore, it seems there is either
          1. a regression between 90.0.918 and 91.0.837, or
          2. a difference in 'feature flag' or other configuration
        4. I did notice that the Beta version ran with the following command line argument that was absent from the Stable version
          1. "--monitor-self"
      3. At first I thought Edge might be losing a 'race condition' with Windows Defender Real Time Protection (RTP); that is, Defender locks the file and Edge can't delete it  (see detail [1] below)
      4. That seems unlikely, though, since the Beta ring works fine with Defender
      5. Instead, it appears that the Stable version (and possibly the Canary one as well) aren't even _trying_ to delete the old files until after the next time Edge is completely closed and re-opened (... which for some people can be hours to weeks!) (see detail [2] below)
      6. Perhaps unrelated, there was a mention of this in one of the file access traces - perhaps it is another lead for the devs:
        1. msedge.dll - RelaunchChromeBrowserWithNewCommandLineIfNeeded

       

       

      To recap this entire discussion, it seems there are two (separate but related) issues that need to be fixed:

       

      1. Edge is keeping more than one BrowserMetrics file around, and for far too long
        1. As I understand it, having more than one file in the BrowserMetrics directory is designed to only ever be a short-term (i.e. 30-60 minutes max) occurrence
      2. For some combination of builds/users/conditions, Edge is creating these new files at a very high rate (6-300 files / hour).
        1. Even if the previous issue is corrected, this one is arguably more important and will have more impact on the overall UX of Edge.
        2. Whether or not they are full of data, that can result in a ton of small disk accesses.
          1. Pity those unfortunate students using low-end laptops* with spinning HDDs!
            1. Memory-mapped files like this sometimes get written to very often, since the data is saved in very tiny chunks.
            2. Based on some of the reports from above, one can imagine the poor little hard drive heads bouncing back-and-forth nearly constantly, impacting system responsiveness and the user's overall opinion of Edge
              1. An average laptop HDD may only get 60 operations, likely fewer, each second, for the entire operating system and all applications
              2. The fastest server HDDs still only allow a maximum of about 200 operations / second
            3. As I have previously mentioned (ok, mildly ranted), each new file can drive activity from filesystem, antivirus/Defender, Windows Auditing, disk indexing, and potentially other processes. To the extent that most of these are reads, their biggest negative impact relates to HDDs.
            4. * some customers may even have Windows Virtual Desktop instances backed by HDDs, driven by inertia or Azure budgets
          2. This causes unnecessary wear on consumer SSDs as well.
            1. The primary concern here is with the frequent small disk writes; read cost / wear is fairly insignificant
            2. (I believe Chromium on Android turns this feature off altogether, choosing instead to just keep the data in RAM until it needs to be uploaded.)

       

      Thank you for all the attention you and your team are giving to this! :happyface:

       

      Happy hunting,

       

        - Jim

       


      Detail [1] from item (3) in above list:

      Spoiler
      1. Edge creates the 4.0 MiB PMA (Persistent Memory Access) file named "BrowserMetrics-spare.pma" in the "%LocalAppData%\Microsoft\Edge\User Data" directory.
      2. Edge moves that file to the "%LocalAppData%\Microsoft\Edge\User Data\BrowserMetrics" directory and renames it.
      3. Edge loads that re-named file as a memory-mapped file
        1. After some time, the 'spare' file from step 1 is re-created
      4. If Windows Defender is running,
        1. writes to this file are sometimes / always accessed filtered through the Defender (MsMpEng.exe) process (Synchronous Paging I/O)
      5. If Windows Defender ATP (Advanced Threat Protection) is running,
        1. that process (MsSense.exe) requests an 'opportunistic lock (oplock)' [FSCTL_REQUEST_OPLOCK IOCTL (winioctl.h)] while it is scanning
        2. Before that scan is complete (and therefore the oplock is released), Edge (msedge.exe) closes the file

       

      Detail [2] from item (5) in above list:

      Spoiler
      Beta - Version 90.0.818.22 (Official build) beta (64-bit)
      
        --> Normal (working) process, that prevents build-up of "BrowserMetrics-hhhhhhhh-hhhhh.pma" files:
      
        CreateFile                                              Desired Access: Generic Read/Write, Disposition: OpenIf, 
                                                                  Options: Synchronous IO Non-Alert, Non-Directory File, 
                                                                  Attributes: n/a, ShareMode: Read, Write, Delete, 
                                                                  AllocationSize: 0, OpenResult: Created
        CreateFileMapping                                       SyncType: SyncTypeCreateSection, 
                                                                  PageProtection: PAGE_EXECUTE_READWRITE
                          Result: FILE LOCKED WITH WRITERS
        QueryStandardInformationFile                            AllocationSize: 0, EndOfFile: 0, NumberOfLinks: 1, 
                                                                  DeletePending: False, Directory: False
        SetEndOfFileInformationFile                             EndOfFile: 4,194,304
        CreateFileMapping                                       SyncType: SyncTypeOther
        ReadFile                                                Offset: 0, Length: 32,768, I/O Flags: Non-cached, Paging I/O, 
                                                                  Synchronous Paging I/O, Priority: Normal
      	...
        CreateFile                    IRP_MJ_CREATE
        QueryAttributeTagFile         IRP_MJ_QUERY_INFORMATION  Type: QueryAttributeTagFile, Attributes: AC, ReparseTag: 0x0
        SetDispositionInformationEx   IRP_MJ_SET_INFORMATION    FILE_DISPOSITION_DELETE, FILE_DISPOSITION_POSIX_SEMANTICS, 
                                                                  FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK
                                      IRP_MJ_CLEANUP
        CloseFile                     IRP_MJ_CLOSE
      When running the Stable ring version of Edge, "SetDispositionInformationEx" never appears and the files persist.

       

      • dave260's avatar
        dave260
        Copper Contributor
        Thanks Jim for all the updates and spoiler alerts! Good information.
        I will quickly add at this point, I am using Edge Beta now. It seems to work well, but I haven't tested every possible issue. Interesting that this is the third day I have used Beta, and there is only ONE file in Browser Metrics. This is the third day I have been using it. On the other hand, Stable Edge has 854 BrowserMetric entries for 3/31-4/1 minimal use.
        -- Dave
    • lexcyn's avatar
      lexcyn
      Steel Contributor
      Thanks - done as requested.

      I just cleared out the files a couple of days ago and already up to over 12k new files, all spaced 1 day apart. Added all the details into a txt file in the upload!
      • JimGrisham's avatar
        JimGrisham
        Steel Contributor

        lexcynHow far apart are the dates/times on your files? [Unless my quick math is wrong, 12,000 files over 2 days (48 hours) would be 250/hour, or a new file every 15 seconds or less. Even if over 4 days (96 hours), that is 125 files/hour, still over 2 new files _per minute_.]

        dave260 Here's probably why the NTFS file compression isn't working for you:

        • When NTFS compression is enabled on a file:
          • The file is broken up into small sections
          • Every time one of those sections is written to,
            • The data for that section (including any changes being saved) are compressed in RAM.
              • If the compressed size is smaller than the size of the uncompressed data, the compressed section is written to disk.
              • If the compressed size is about the same or larger than the uncompressed data, that section is written uncompressed
        • What I think Edge is doing:
          • Creates a new empty 4MB file
          • 'Memory-maps' that file to an area of memory so that Edge can write to it directly
          • Each time it has a drop of 'metrics' data, it stores it in RAM
            • Since the file is 'memory-mapped', the system (Windows' virtual memory subsystem and/or the CPU's internal Memory Management Unit) automatically writes the changed data to disk, some small number of bytes at a time
          • Since only a tiny bit of data is changing at any one moment, NTFS compression doesn't bother with it (guesses: because it's either too small, because by itself it doesn't compress well, or because it never really works for memory-mapped files)

        If you were to turn off compression for your entire BrowserMetrics folder and its contents, and them immediately turned it back on, I think you'd find that all existing files would be greatly compressed, but new files would not. So much for that idea!

         

  • lexcyn's avatar
    lexcyn
    Steel Contributor

    Happened again last night while leaving the browser open overnight, over 76GB of these files :sad:

    • JimGrisham's avatar
      JimGrisham
      Steel Contributor

       

      lexcyn (and dave260) Have you tried turning on automatic compression for the BrowserMetrics folder, as I detailed above? (If so, do you have anything notable to report?)

       

      Anyone else?

       

      (I haven’t personally seen any ill effects yet from enabling automatic compression.)

       

      PSA: if you can fulfill the data request from Alexandra-R, please do that first! The sooner the team gets data the sooner they can figure this out.

       

       - Jim

       

      ----

      Aside: With the explosion (in both usage and number) of plain-text configuration, log, and analytics files in recent years, I wonder if NTFS compression should be used by default in many more places...

       

      [Even with medium-speed SSDs, accessing a compressed file might be faster (fewer IOPS as well), let alone for those poor souls still using HDDs for their boot disk.

       

      I’m not well-versed to know for sure, but memory-mapping files that a program needs extensive access to may contribute to the current disk performance challenges across various ‘modern’ operating systems (in theory and benchmarking, maybe this shouldn’t be a problem due to something like ‘intelligent caching’ in disk and VM systems, but in real-world multi-threaded multi-tasking usage, might not even the most ‘intelligent’ cache prediction system fail to determine user intent in order to optimize performance?).

       

      It shouldn’t be that surprising that browsers such as Chromium-based Edge, in some ways nearly mini-OSs themselves, might end up being a canary for this sort of systemic issue. They are very complex and usage can vary widely by user and time - this isn’t just ‘winword.exe accessing hugereport.doc’ anymore!]

      ... and all that is aside from the performance impacts of having thousands or more files per process - each one places load on systems and filesystems upon reading (e.g. for each and every file opened, even read-only: verifying access rights, recording ‘atime’ access time, and performing other security/audit logging), writing (most of those same activites, plus updating modification times and file system journals, and perhaps SSD ‘write amplification’), and for purposes of indexing, backup, and security (Windows Defender Real-Time Protection). Many are likely to be left behind when new builds are installed. Sure, some of those things can be disabled on a per-file, directory, or process basis, but... without giving admin rights to the application?

       

      Even if developers of most programs know how to do this, even if allowed to by system security and domain group policy, why would they remember to do this on every release? If using a cross-platform framework, they may not even _be aware_ of these issues, or have an API to address them.

      • dave260's avatar
        dave260
        Copper Contributor
        Jim, yes I did try setting the BrowserMetrics folder to auto compress. That seemed to help initially, but today it is up to 2400 files, 9.6 GB (4K/file). Date-range is 3/28-3/31. Interesting to note that uncompressed files were same size in properties - Size of File and Size on disk (4.00 MB). As compressed, there is a slight difference in Size of File (4.00 MB) vs Size on Disk (3.94 MB). So compression is doing very little it seems. Initially, compression was very good, but I'm wondering if upgrading to latest version of Edge changed compression effectiveness?
        Latest Edge version updated after the first compression trial. Now 89.0.774.63 (Official build) (64-bit). Previous version was 89.0.731.xx as I recall..
        Alexandra-R My apologies for not submitting the info for your request. I will hopefully get that to you today!
        - Dave
    • dave260's avatar
      dave260
      Copper Contributor

      Yes, I'm up to 14 GB since 3/20/21; almost 3 GB/day. Some of you seem to be having much higher usage by Browser Metrics. I'm hoping for progress by the Microsoft Edge team soon!

    • JimGrisham's avatar
      JimGrisham
      Steel Contributor

      EDIT:

      This does NOT work.

          (It shouldn't hurt anything, but my post below for the explanation of why it won't help for any files created after you turn on compression.)

       

      This still might: (Potential alternate kludgy fix in post further below)

       

      (original post follows):

      -----

       

      Okay, so this may end horribly, but I just turned on NTFS compression for the BrowserMetrics folder.

       

       

       

      Actual disk usage is now 0.62% of what it was.

      (New files are created about every 10 minutes, and so far it appears they are being properly compressed.)

       

      Even if this works, it's still a kludge. This is not tested; buyer beware.

       

    • JimGrisham's avatar
      JimGrisham
      Steel Contributor

      Vovan / Edge team:

      The site (pomotodo) that you mention uses something called 'web workers' (the Chromium 'Blink' rendering engine apparently calls them 'Blink Workers').

       

      In my (very limited) understanding, this causes a piece of JavaScript to run on a different thread than the one controlling the display of the page to which it belongs, allowing it to run on a different actual (or virtual) CPU.

       

      If each of these new threads (as many as one or more every time you switch pages?) causes Edge to create a new file in BrowserMetrics (whether intentionally or not), maybe they are crashing or quitting before it can clean up the excess files.

       

      Metrics files from different files are supposed to be automatically collected into a single file, but perhaps that part of the code (e.g. subprocess_metrics_provider.cc, or something that calls / is called by a function or method there or elsewhere) is malfunctioning.

       

      Many (most?) sites these days use 'web workers', but the inconsistent (across the Edge user base) nature of this problem suggests that if they are indeed part of what causes this, something in the JavaScript on certain sites is triggering this (the browser should behave even in the presence of horrible / buggy JavaScript, of course).

       

      - Jim

  • taasdaamde's avatar
    taasdaamde
    Copper Contributor

    alexfreu 

    Edge crashes my PC for the third time today.  It indeed fills the directory C:\Users\%username%\AppData\Local\Microsoft\Edge\User Data\BrowserMetrics with thousands  of files.   The registry key setting doesn't prevent Edge for doings so. 

     

    This is the policy: 

     

     

     

    But this is the result :   

     

    Is there a solution, other than removing Edge from the PC ?  

     

     

    • Andrew Grantham's avatar
      Andrew Grantham
      Copper Contributor

      This has become an issue again, which seemed initially to be solved, Yesterday admittedly after having an Edge session with multiple tabs probably open for most of the week the Browser Metrics folder had ballooned to 179GB, currently with 2 tabs open it's generating 20 4MB files a minute so 4.8GB an hour so I now have 32Hrs 30 minutes of disk space until Edge fills my OS SSD again.

       

      I've already added the reg key described and set to 0 and confirmed that this has applied in edge://policy. I can't find a root cause for this but unless I'm able to pretty soon I'll just have to go back to chrome.

      • HotCakeX's avatar
        HotCakeX
        MVP
        Have you sent feedback using feedback button on Edge?
        sending machine logs using feedback button is the only useful way to let developers know you are having this issue.
  • alexfreu Thanks for explanation for community. Will be nice, if Edge will provide automatic cleanup of these files in Disk Cleaner utility or something like that. Liked to send crash telemetry data, but need to clean such if they take so much disk space.

Resources