question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Helper.LoadPolicyLine causes poor performance

See original GitHub issue

I’m loading nearly 10000 policies in my project . the Casbin core module and Adapter is injected as Scoped service. I found this method checking policy uniqueness every time when data line loaded. I wrote a method

private void PolicyUniquenization(Model model)
        {
            var m = model.Model;
            foreach(var key in m.Keys)
            {
                foreach (var ast in m[key].Values)
                {
                    ast.Policy = ast.Policy.Distinct().ToList();
                }
            }
        }

then alter Helper.LoadPolicyLine method without checking data uniqueness. and invoke at the end of LoadPolicy method in Adapter

public void LoadPolicy(Model.Model model)
        {
            // some codes of polices loading...

            PolicyUniquenization(model);
        }

seems to make things better? want to know if this modification causes any problem…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sagiliocommented, Jun 12, 2020

They are Inherited from Object, So the Equals is equivalent to calling the ReferenceEquals method, I think we need to ensure the content is equal. And I think we can create a benchmark project which uses BenchmarkDotNet.

0reactions
xcaptaincommented, Jun 12, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Download Diff File
Parameters can be of any type, but will not cause errors unless actually used ... -For a very rough idea of performance, here...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found