Skip to content

Rework registry to seach with O(1) #188

@DifferentialOrange

Description

@DifferentialOrange

Registry collector search сomputational complexity is O(N) where N is quantity of collectors

for _, c in ipairs(self.collectors) do

But Lua has hash tables, and with them we can search with O(1) at most times (and it's not like hash collision will happen often with standard number of collectors). All we need is to use kind+name key instead of plain array, i.e.

{ [ kind1 .. name1] = collector1, ... }

instead of

{ [1] = collector1 }

since kind+name must be unique. Moreover, it is more common to search for user collectors, but in registry array they always will be placed after default collectors, so it will be .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions