Starts in:
2 DAYS
3 HRS
52 MIN
7 SEC
Starts in:
2 D
3 H
52 M
7 S
Open Closed

Performance Issue #2783


User avatar
0
Rrader30 created
  • ABP Framework version: v5.1.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I am attempting to build out some basic reporting features. I created a new end-point.

My application end-point code is as follows

public virtual async Task<PagedResultDto<ReportingContractor>> GetAvailableContractors(Guid? MSA = null, int? trade = null, int? status = null, Guid? vps = null) { List<ContractorDto> _rpt = new List<ContractorDto>();

        IQueryable&lt;Trade&gt; queryableTrade = await _trade.GetQueryableAsync();
        List&lt;Trade&gt; queryTrade = (from _t in queryableTrade
                           orderby _t.Id
                           select _t).ToList();

        IQueryable&lt;Status&gt; queryableStatus = await _status.GetQueryableAsync();
        List&lt;Status&gt; queryStatus = (from _s in queryableStatus
                                    orderby _s.Id
                                  select _s).ToList();

        //Get all the contractors
        IQueryable&lt;Contractor&gt; queryablecnt = await _contractor.GetQueryableAsync();
        var querycnt = (from cnt in queryablecnt
                        orderby cnt.Id
                        select cnt).ToList();

        var _cntrList = querycnt.WhereIf(MSA.HasValue, e => e.msaid.Contains(MSA.ToString()))
                                .WhereIf(trade.HasValue, e => e.tradeid == trade)
                                .WhereIf(status.HasValue, e => e.status == status)
                                .WhereIf(vps.HasValue, e => e.procurementSpecialist == vps.ToString());



        ////Duplicate Contractors for each of the MSA they belong to.
        List&lt;Contractor&gt; _cntrItems = new List&lt;Contractor&gt;();
        foreach (var _itemCtr in _cntrList.ToList())
        {
            Contractor _cnItem = new Contractor();

            if (_itemCtr.msaid != null)
            {
                var tags = _itemCtr.msaid.ToString();
                string[] _tags = tags.Split(',');
                _tags = _tags.Where(x => !string.IsNullOrEmpty(x)).ToArray();

                List&lt;string&gt; msaNames = new List&lt;string&gt;();

                foreach (string _tag in _tags)
                {
                    if (_tag.ToString() != null)
                    {
                        _itemCtr.msaid = _tag.ToString();
                        _cntrItems.Add(_itemCtr);
                    }
                }
            }
        }

        List&lt;ReportingContractor&gt; _rptItems = new List&lt;ReportingContractor&gt;();

        foreach (var _itemCtr in _cntrItems.ToList())
        {
            ReportingContractor _cnItem = new ReportingContractor();
            var rpt = ObjectMapper.Map&lt;Contractor, ReportingContractor&gt;(_itemCtr);

            if (rpt.status != 0 || rpt.status != null)
            {
                foreach (var stat in queryStatus)
                {
                    if (_cnItem.status == stat.Id)
                    {
                        rpt.statusName = stat.Name;
                        break;
                    }
                }
            }

            if (rpt.tradeid != 0)
            {
                foreach (var _trade in queryTrade)
                {
                    if (_trade.Id == rpt.tradeid)
                    {
                        rpt.tradeName = _trade.Name;
                        break;
                    }
                }
            }

            _rptItems.Add(rpt);
        }

        var _return = new PagedResultDto&lt;ReportingContractor&gt;
        {
            TotalCount = _rptItems.Count,
            Items = _rptItems
        };

        return _return;
    }
    

The code itself runs at a decent speed given the number of records (close to 900). What I noticed is the code will return values in debug but it takes 3-4x as long for the values to show up in Swagger. I can't seem to figure out what would be causing the issue.

Here is the other areas of code: IContractorAppService

Task<PagedResultDto<ReportingContractor>> GetAvailableContractors(Guid? MSA = null, int? trade = null, int? status = null, Guid? vps = null);

HttpApi ContractorController

[HttpGet] [Route("gcavail")] public virtual Task<PagedResultDto<ReportingContractor>> GetAvailableContractors(Guid? MSA = null, int? trade = null, int? status = null, Guid? vps = null) { return _contractorsAppService.GetAvailableContractors(MSA, trade, status, vps); }


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    HI

    I don't see obvious problems in the code you shared. You can try to use related tools for profiling,

    https://www.jetbrains.com/help/profiler/Introduction.html

  • User Avatar
    0
    Rrader30 created

    So I downloaded and ran the profiling, but honestly did not see any issues (of course I am not sure what exactly I am looking at). This is very odd issue that I have not run into with other APIs I have added. It takes a good 4 mins or so for the data to return about to the HttpApi project. Not sure what would be between the Application and the HttpApi, but the application project returns the data in less than a min but it takes over 4 mins for it to show up in Swagger. Very weird issue. Could it have anything to do with redis?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Could it have anything to do with redis?

    Yes, 127.0.0.1 is used as the Redis server. If you didn't run the server on 127.0.0.1 there is will be a problem.

  • User Avatar
    0
    Rrader30 created

    I have redis running on 12.0.0.1 and I got the error with the server running. It almost seems like it can not handle large datasets. So my question, is there a way to turn redis off for specific queries? I would like to keep redis running but having issues like this keeps it from running properly.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    So my question, is there a way to turn redis off for specific queries

    We need the Redis.

    https://github.com/abpframework/abp/issues/5023#issuecomment-687854205

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06