Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4845#discussion_r25717369
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/history/HistoryPage.scala ---
    @@ -34,18 +37,31 @@ private[spark] class HistoryPage(parent: HistoryServer) 
extends WebUIPage("") {
         val requestedIncomplete =
           
Option(request.getParameter("showIncomplete")).getOrElse("false").toBoolean
     
    -    val allApps = parent.getApplicationList().filter(_.completed != 
requestedIncomplete)
    -    val actualFirst = if (requestedFirst < allApps.size) requestedFirst 
else 0
    -    val apps = allApps.slice(actualFirst, Math.min(actualFirst + pageSize, 
allApps.size))
    -
    +    val allCompletedAppsNAttempts = 
    +        parent.getApplicationList().filter(_.completed != 
requestedIncomplete)
    +    val (hasAttemptInfo, appToAttemptMap)  = 
getApplicationLevelList(allCompletedAppsNAttempts)
    --- End diff --
    
    We should slice on the applications, and then build the table with all the 
applications' attempts. So every page shows "x" applications, not attempts. 
After you apply the pagination logic, iterating is cheap ("x" is a small 
number), so calculating `hasAttemptInfo` separately is easy.
    
    Perhaps a more efficient way of doing this would be to make 
`ApplicationHistoryProvider.getListing` return that map, then this code would 
be much simpler. It would just need to slice the map instead of transform a 
flat list into something different.
    
    I just think the code you currently have is a little confusing, and a 
little inefficient. If you have a really long list of applications, it would 
waste a lot of cycles reading through it and copying things that would just be 
thrown away.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to