a-plus icon indicating copy to clipboard operation
a-plus copied to clipboard

Load exercises in parallel or in a different order on chapter pages

Open lainets opened this issue 2 years ago • 1 comments

It is quite slow to load all the exercises (if there are several) in a chapter sequentially. If one clicks a link to the last exercises, they will have to wait for multiple seconds for it to load. For example, https://plus.cs.aalto.fi/aplus-manual/master/acos/demo_exercises/#chapter-exercise-13 takes 5+ seconds to load. Even https://plus.cs.aalto.fi/aplus-manual/master/programming_exercises/graderutils/#chapter-exercise-6 takes almost 3 seconds.

To fix this there are three options:

  1. Load all exercises in parallel. This will take less time in total with the caveat of taking longer to load the first exercise (or first few)
  2. Load the linked-to exercise first (i.e. the one in the URL e.g. #chapter-exercise-6), and then the rest. This will give you the exercise you clicked a link to much faster but it is an open question as to what order the rest of the exercises should be loaded in.
  3. Combination of the two above: load the exercises in batches or in multiple parallel sequential loads, with the linked-to exercise in first to be loaded. In batches: two or three at a time in parallel, and start a new batch once all exercises for the previous batch are loaded. Parallel sequential: start parallel loads that start loading the next exercise immediately after the first is loaded (i.e. in this case we do not wait for the whole batch to finish). This should load the linked-to exercise faster than option 1 but slower than option 2, and all exercises slower than option 1 but faster than option 2.

The issue with option 1 is that it will place a much higher load on the server than the current implementation. Option 3 doesn't have quite as high load but the implementatio is much more complicated. Option 1 was originally used on A+ but it was changed 7 years ago to load the exercises sequentially exactly because of the load on the server. Whether either of these would be an issue in practice on the current code and server setup is not known.

lainets avatar Sep 01 '23 12:09 lainets

Could we load only the exercises which are currently in the user's view (with some buffer if possible), and show placeholders for others?

sayravai avatar Aug 18 '25 07:08 sayravai