frostyx / copr / copr

Forked from copr/copr 7 years ago
Clone

fdbbb8a frontend: speedup for listing builds via APIv3

Authored and Committed by frostyx 2 years ago
    frontend: speedup for listing builds via APIv3
    
    See PR#1914
    
    I found two bottlenecks
    
    1) `to_dict` function isn't extremely slow but it can be made faster
       by pre-loading the `models.Build` relationships. This adds up and
       brings a significant speedup for large projects
    
    2) Querying the first pages is blazing fast but it gets 10 times
       slower when approaching large offsets. We can mitigate the slowdown
       at least a little by offseting and limiting within a subquery. It
       is also very helpful to query more results per page because the
       time for convering database results to JSON remains the same but we
       simply don't have to calculate the offset so often.
    
    With this changes, I was able to reduce the time for completing
    
        time copr-cli list-builds @rubygems/rubygems --output-format=json
    
    from 42min to 13min.
    
        
file modified
+1 -1