ActiveLogin.Authentication icon indicating copy to clipboard operation
ActiveLogin.Authentication copied to clipboard

Performance improvement in UAParser

Open stujo-eg opened this issue 1 year ago • 1 comments

Describe the bug The UAParser implementation seems to consume a lot of unnecessary memory, putting the ua yaml parse definition multiple times into memory.

What area is it related to UAParser

To Reproduce Steps to reproduce the behavior:

  1. Run any instance of activelogin
  2. Make sure you have a large amount of requests
  3. Perform a memory dump in VS with Managed heap Summary
  4. Observe many instances of 390.1 KB strings containing a YAML definition file for UAParser (problem)

Expected behavior Single read of parse definition

Screenshots image

NuGet package version 8.0.0

Runtime version .NET Core 8.0

Desktop (please complete the following information): N/A

Smartphone (please complete the following information): N/A

Additional context Parser uses Parser.GetDefault() for each detect which in turns reads manifest resource. Seems like this could easily be optimized by making the parser a static/singleton.

Activelogin https://github.com/ActiveLogin/ActiveLogin.Authentication/blob/main/src/ActiveLogin.Authentication.BankId.UAParser/UAParserDeviceDetector.cs

UaParser. https://github.com/ua-parser/uap-csharp/blob/master/UAParser/UAParser.cs

stujo-eg avatar Aug 20 '24 11:08 stujo-eg

Thanks for reporting this! Will reproduce and have a look.

rfolkes avatar Oct 21 '24 11:10 rfolkes

This issue was fixed in release in v 10.1.1.

elinohlsson avatar Jan 23 '25 09:01 elinohlsson