Skip to content

Performance improvement in UAParser #462

@stujo-eg

Description

@stujo-eg

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

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions