Using CardFilter.All causes huge hit in performance
techfooninja opened this issue · 4 comments
I'm primarily using the Board.Cards property, since I'm interested in all cards on the board, regardless of which list they're in. When I run the following code, it executes relatively quickly (5-10 seconds for the 15-20 boards I care about):
this.trello = new TrelloFactory().Me().Result;
foreach (var board in this.trello.Boards)
{
// board.Cards.Filter(CardFilter.All); // <-- This causes huge perf hit
await board.Cards.Refresh();
}
But if I uncomment the filter line, I hit a massive performance hit, possibly even more than 100x (waiting several minutes and it just finished the first board).
Details:
- Used in a .NET Framework 4.6.2 Console Application on a Windows 10 machine (Version 1809, OS Build 17763.379). I see the same behavior on a Windows Server 2016 machine (Version 1607, OS Build 14393.2906)
- The first board I'm trying this on has 8 lists, about 40 visible cards, and 15 archived cards
- Looking at the Fiddler trace, it looks like the API is returning all of the cards relatively quickly (within a second or two of the default query), but it appears that the parsing/processing of the response is what is getting hung up.
- I'm using a paid Manatee.Trello license
- I downloaded the git repo and referenced it in my project instead of using the nuget package. I'm not really familiar with the library code, so I haven't been able to debug fully myself. But it looks like there is a lot of time being spent on line 42 of ReadOnlyActionCollection.cs, which is:
internal ReadOnlyActionCollection(Type type, Func<string> getOwnerId, TrelloAuthorization auth)
: base(getOwnerId, auth)
{
_updateRequestType = RequestTypes[type];
EventAggregator.Subscribe(this);
}
Maybe there is a concurrency performance issue with the lock used in EventAggregator.cs on line 58?:
public static void Subscribe(IHandle subscriber)
{
if (subscriber == null) throw new ArgumentNullException(nameof(subscriber));
lock (Handlers)
{
if (Handlers.Any(x => x.Matches(subscriber))) return;
Handlers.Add(new Handler(subscriber));
}
}
Thanks for the report. I'll check it out.
The event aggregator is actually pulled out of Caliburn.Micro and unchanged (to my recollection). I might be able to remove that lock, but I need to contemplate it first.
Do you need the actions on the cards? Turning off the actions download (via Card.DownloadedFields
) might be a workaround for now.
Also, I think you meant to put this in Manatee.Trello, not Manatee.Json. I'm going to close this and open one over there (I'll tag you).
Ha, whoops...yes, I meant Manatee.Trello...sorry about that.