KSP-CKAN / CKAN

The Comprehensive Kerbal Archive Network

Home Page:https://forum.kerbalspaceprogram.com/index.php?/topic/197082-*

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance hitch when typing in the search box while versions tab is open

JonnyOThan opened this issue · comments

I'm pretty sure the search box isn't the only way to trigger this but I found a consistent repro:

  1. open the versions tab
  2. in the search box, start typing "ksp community fixes"
  3. When you hit the second 'm', CKAN will hang for a few seconds

The first time I did this the hang was probably ~20 seconds. Doing it again resulted in a shorter hang, but it's still several seconds long.

I'm running this on the latest dev version so I don't have symbols (huh apparently there are some symbols in here; just not jitted code maybe) but maybe this will help:
image

The thread that eventually unblocked the main thread is here:
image

Kinda hard to tell, but maybe calling ToList on a parallel enumerator is doing some bad stuff?

I think we have over-parallelization here. RelationshipResolver.ModList is parallel (for speeding up very large changesets), and Versions.checkInstallable calls it in parallel (via ModuleInstaller.CanInstall; that's what feeds the ToList call highlighted above). This nesting can do wacky things to threads; I hit this a couple of times while parallelizing other stuff. This probably also explains why the Versions tab doesn't start filling in right away.

That link recommends only parallelizing the outer loop.

... confirmed (more or less). Commenting this line makes the inner loop non-parallel, which makes the response to color the list instantaneous and fixes the hang-up issue in the OP:

... but I think we'll want to be able to make that conditional somehow in case there are other places that would still benefit from it being parallel...