diff options
| author | David Reyna <david.reyna@windriver.com> | 2014-05-21 15:15:09 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-06-20 14:58:08 +0100 |
| commit | 26db62e35951013515fba6b4ab92ac0ed6a80852 (patch) | |
| tree | 49ec934a3ac06d9a768c6f09597bf43157235dc4 | |
| parent | 18224a4a461754d660ed3e69a0545ac7e0a2d028 (diff) | |
| download | poky-26db62e35951013515fba6b4ab92ac0ed6a80852.tar.gz | |
bitbake: toaster: reduce redundant foreign key lookups
Replace redundant foreign key lookups with "with" to improve all
recipes page load time. Do depends pre-lookup in the view class,
and use python itertation instead of filter() all to achieve x16
processing speedup.
[YOCTO #6137]
(Bitbake rev: e068727de686cd6c43cebacdac5b898c134705ef)
Signed-off-by: David Reyna <David.Reyna@windriver.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Conflicts:
bitbake/lib/toaster/toastergui/views.py
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rwxr-xr-x | bitbake/lib/toaster/toastergui/templates/recipes.html | 20 | ||||
| -rwxr-xr-x[-rw-r--r--] | bitbake/lib/toaster/toastergui/views.py | 15 |
2 files changed, 29 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/recipes.html b/bitbake/lib/toaster/toastergui/templates/recipes.html index 907b83d269..791a487a81 100755 --- a/bitbake/lib/toaster/toastergui/templates/recipes.html +++ b/bitbake/lib/toaster/toastergui/templates/recipes.html | |||
| @@ -45,31 +45,39 @@ | |||
| 45 | <td><a href="{% url "recipe" build.pk recipe.pk %}">{{recipe.version}}</a></td> | 45 | <td><a href="{% url "recipe" build.pk recipe.pk %}">{{recipe.version}}</a></td> |
| 46 | <!-- Depends --> | 46 | <!-- Depends --> |
| 47 | <td class="depends_on"> | 47 | <td class="depends_on"> |
| 48 | {% if recipe.r_dependencies_recipe.all.count %} | 48 | {% with deps=recipe_deps|get_dict_value:recipe.pk %} |
| 49 | {% with count=deps|length %} | ||
| 50 | {% if count %} | ||
| 49 | <a class="btn" | 51 | <a class="btn" |
| 50 | title="<a href='{% url "recipe" build.pk recipe.pk %}#dependencies'>{{recipe.name}}</a> dependencies" | 52 | title="<a href='{% url "recipe" build.pk recipe.pk %}#dependencies'>{{recipe.name}}</a> dependencies" |
| 51 | data-content="<ul class='unstyled'> | 53 | data-content="<ul class='unstyled'> |
| 52 | {% for i in recipe.r_dependencies_recipe.all|dictsort:"depends_on.name"%} | 54 | {% for i in deps|dictsort:"depends_on.name"%} |
| 53 | <li><a href='{% url "recipe" build.pk i.depends_on.pk %}'>{{i.depends_on.name}}</a></li> | 55 | <li><a href='{% url "recipe" build.pk i.depends_on.pk %}'>{{i.depends_on.name}}</a></li> |
| 54 | {% endfor %} | 56 | {% endfor %} |
| 55 | </ul>"> | 57 | </ul>"> |
| 56 | {{recipe.r_dependencies_recipe.all.count}} | 58 | {{count}} |
| 57 | </a> | 59 | </a> |
| 58 | {% endif %} | 60 | {% endif %} |
| 61 | {% endwith %} | ||
| 62 | {% endwith %} | ||
| 59 | </td> | 63 | </td> |
| 60 | <!-- Brought in by --> | 64 | <!-- Brought in by --> |
| 61 | <td class="depends_by"> | 65 | <td class="depends_by"> |
| 62 | {% if recipe.r_dependencies_depends.all.count %} | 66 | {% with revs=recipe_revs|get_dict_value:recipe.pk %} |
| 67 | {% with count=revs|length %} | ||
| 68 | {% if count %} | ||
| 63 | <a class="btn" | 69 | <a class="btn" |
| 64 | title="<a href='{% url "recipe" build.pk recipe.pk %}#brought-in-by'>{{recipe.name}}</a> reverse dependencies" | 70 | title="<a href='{% url "recipe" build.pk recipe.pk %}#brought-in-by'>{{recipe.name}}</a> reverse dependencies" |
| 65 | data-content="<ul class='unstyled'> | 71 | data-content="<ul class='unstyled'> |
| 66 | {% for i in recipe.r_dependencies_depends.all|dictsort:"recipe.name"%} | 72 | {% for i in revs|dictsort:"recipe.name" %} |
| 67 | <li><a href='{% url "recipe" build.pk i.recipe.pk %}'>{{i.recipe.name}}</a></li> | 73 | <li><a href='{% url "recipe" build.pk i.recipe.pk %}'>{{i.recipe.name}}</a></li> |
| 68 | {% endfor %} | 74 | {% endfor %} |
| 69 | </ul>"> | 75 | </ul>"> |
| 70 | {{recipe.r_dependencies_depends.all.count}} | 76 | {{count}} |
| 71 | </a> | 77 | </a> |
| 72 | {% endif %} | 78 | {% endif %} |
| 79 | {% endwith %} | ||
| 80 | {% endwith %} | ||
| 73 | </td> | 81 | </td> |
| 74 | <!-- Recipe file --> | 82 | <!-- Recipe file --> |
| 75 | <td class="recipe_file">{{recipe.file_path}}</td> | 83 | <td class="recipe_file">{{recipe.file_path}}</td> |
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 4622810cf9..686cd5c8ce 100644..100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
| @@ -1074,11 +1074,26 @@ def recipes(request, build_id): | |||
| 1074 | 1074 | ||
| 1075 | recipes = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) | 1075 | recipes = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) |
| 1076 | 1076 | ||
| 1077 | # prefetch the forward and reverse recipe dependencies | ||
| 1078 | deps = { }; revs = { } | ||
| 1079 | queryset_dependency=Recipe_Dependency.objects.filter(recipe__layer_version__build_id = build_id) | ||
| 1080 | for recipe in recipes: | ||
| 1081 | deplist = [ ] | ||
| 1082 | for recipe_dep in [x for x in queryset_dependency if x.recipe_id == recipe.id]: | ||
| 1083 | deplist.append(recipe_dep) | ||
| 1084 | deps[recipe.id] = deplist | ||
| 1085 | revlist = [ ] | ||
| 1086 | for recipe_dep in [x for x in queryset_dependency if x.depends_on_id == recipe.id]: | ||
| 1087 | revlist.append(recipe_dep) | ||
| 1088 | revs[recipe.id] = revlist | ||
| 1089 | |||
| 1077 | context = { | 1090 | context = { |
| 1078 | 'objectname': 'recipes', | 1091 | 'objectname': 'recipes', |
| 1079 | 'build': Build.objects.filter(pk=build_id)[0], | 1092 | 'build': Build.objects.filter(pk=build_id)[0], |
| 1080 | 'objects': recipes, | 1093 | 'objects': recipes, |
| 1081 | 'default_orderby' : 'name:+', | 1094 | 'default_orderby' : 'name:+', |
| 1095 | 'recipe_deps' : deps, | ||
| 1096 | 'recipe_revs' : revs, | ||
| 1082 | 'tablecols':[ | 1097 | 'tablecols':[ |
| 1083 | { | 1098 | { |
| 1084 | 'name':'Recipe', | 1099 | 'name':'Recipe', |
