CSC/ECE 517 Spring 2015/oss E1510 FLP: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 53: Line 53:
</pre>
</pre>
we can see in this view, <code>parent_node</code> is a <code>AssignmentNode</code> object, it execute:
we can see in this view, <code>parent_node</code> is a <code>AssignmentNode</code> object, it execute:
* <code>.get_name</code>
* <code>parent_node.get_name</code> method
*
* <code>parent_node.get_directory</code> method
* <code>parent_node.get_creation_date</code> method
* <code>parent_node.get_modified_date</code> method


==Modifications==
==Modifications==

Revision as of 02:05, 23 March 2015

Expertiza - Fix Instructor Login Performance Issue

Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.<ref>Expertiza on GitHub</ref>

Project Description

Currently when an Instructor logs into Expertiza,there a lot of select* from assignments queries being fired on database which would have an adverse effect on performance. We analyzed the source of this issue and made some changes, which reduced the number of select queries executed. The performance is high improved. The mission involved is tracing the source of the issue and modify the code to fix the issue.

Performance issue before modification

  Assignment Load (0.1ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1
  CACHE (0.0ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  CACHE (0.0ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  CACHE (0.0ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  CACHE (0.2ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  CACHE (0.1ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  CACHE (0.1ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  Rendered tree_display/_row_header.html.erb (17.4ms)

  CACHE (0.0ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  Assignment Load (0.2ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1
  CACHE (0.0ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  Rendered tree_display/actions/_shared_actions.html.erb (2.6ms)

  CACHE (0.0ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  SignUpTopic Load (0.1ms)  SELECT  `sign_up_topics`.* FROM `sign_up_topics`  WHERE (assignment_id = 1)  ORDER BY `sign_up_topics`.`id` ASC LIMIT 1
  CACHE (0.0ms)  SELECT  `assignments`.* FROM `assignments`  WHERE `assignments`.`id` = 1 LIMIT 1  [["id", 1]]
  Rendered tree_display/actions/_assignments_actions.html.erb (8.8ms)

we can see that there are 7 assignment queries after load _row_header.html.erb, 3 assignment queries after load _shared_actions.html.erb, 3 assignment queries after load _assignments_actions. All these have an adverse effect on the performance.

Locate bug

Install query_reviewer

Analyze code

_row_header.html.erb and assignment_node.rb

In _row_header.html.erb:

  <% if parent_node.get_name == 'Courses'&& session[:user].role_id == 6 %>
  <%else%>
    <%= parent_node.get_name %>
    <% if parent_node.get_directory != nil%>
      <BR/><I>Directory:</I> <%= parent_node.get_directory %>
    <% end %>
    <% if parent_node.get_creation_date != nil %>
      <BR/><I>Creation Date:</I> <%= parent_node.get_creation_date %>
    <% end %>
    <% if parent_node.get_modified_date != nil %>
      <BR/><I>Updated Date:</I> <%= parent_node.get_modified_date %>
    <% end %>
  <%end%>

we can see in this view, parent_node is a AssignmentNode object, it execute:

  • parent_node.get_name method
  • parent_node.get_directory method
  • parent_node.get_creation_date method
  • parent_node.get_modified_date method

Modifications

_assignment_actions.html.erb

assignment_node.rb


Before Modification


After Modification

 

Performance Improvment

References

<references/>