Hi everyone,
huge job logs are currently displayed as a whole, which can lead to an OOM on the server (see XWIKI-16647). Most likely they also cause unresponsiveness and high memory usage in the browser. The reason is that every display path turns the whole log into one big string, often several times: the Velocity output, then the wiki parser, then the HTML cleaner. The extension manager does this again every second while a job is running, because its refresh loop re-renders the whole extension display including the log. I would like to work on this as part of the December roadmap for the stabilization of XWiki 18.10.x. There are several possible options, and I would like your opinion on them.
Option 0: Raw output for script macros
The cheapest improvement is the one I proposed in Raw output for the Velocity and other script macros. It would avoid parsing and copying the log HTML as wiki syntax, which is where the reported OOM seems to happen. It would still render the whole log as one string on every refresh, though, so I don’t think it’s enough on its own, and it might just move the OOM or still lead to slowness due to high memory usage.
Option 1: Live Data
As discussed before, we could move the whole job log to Live Data. This fits relatively well for displaying the logs of finished jobs. With the current file-based storage, a filter by level would be cheap, but text search or sorting would need to read the whole log file. For running jobs, the table layout is paginated, so following new log entries would mean going to the last page and refreshing it regularly. A continuously scrolling log that follows new entries would need a custom Live Data layout that loads and caches its own ranges of entries. That’s possible, but it basically means writing a full log component inside Live Data.
I think this becomes a better fit once job logs move to a shared store as part of XCOMMONS-3249. However, XCOMMONS-3249 is far too big a change for 18.10.x. So even though Live Data is the solution I would favor long-term, I don’t think it’s a good short-term fix.
Option 2: Load only part of the job log
Initially, display only a limited number of the most recent log entries, say, 100. Above the first displayed entry, a notice says that there are more entries, with a button to load 100 more. New entries of a running job are appended by their index instead of re-rendering the log. The server can render any range of entries one by one and stream them to the response, so it never holds the whole log in memory. This would apply to all places that display job logs (extension manager, copy/rename/delete, wiki creation, etc.), not just extensions.
For extensions, we would also need to change the extension refresh loop so that it stops replacing the whole extension display, including the log, every second. If that turns out to be too invasive for a first step, a fallback is to keep refreshing the whole display, but with the log capped to the last 100 entries, and to show the “load more” button only once the job has finished.
Question 1: How can users access the full log?
Users should still be able to display the full log at once, for example to search in it. I see two options, which aren’t exclusive:
- Add a “Load all N entries” button. This won’t cause an OOM on the server, since the entries can be streamed (this is not possible in the initial load where we render a full page, but it seems possible for refreshes/loading of more entries). On really huge logs it would still create a huge page in the browser, but only on an explicit click, with the number of entries shown on the button.
- Add a link to download the full log as plain text, also streamed.
Question 2: Limit new log entries per refresh?
Should we limit the number of new entries added at a time, and add a gap marker (which can be clicked to load the missing entries) if there are, e.g., more than 100 new entries in a single refresh?
Question 3: Limit the total displayed log size?
If a job runs for a long time, the displayed log could still grow quite big, even with the initial limit and a limit per refresh. Should we discard the oldest displayed entries in that case, to keep, say, at most 1000 entries? To make this work with “load all” from question 1, we could discard entries only while following a running job, and stop discarding once the user has explicitly loaded older entries.
Question 4: Load stack traces on demand?
To further reduce the size of the displayed log, we could stop rendering stack traces by default and load them only when the user clicks on the log entry. This matters especially if we decide to log more/all stack traces (see Logging warning stacktraces in debug mode). Each log entry would carry its index, plus a check that it’s still the same entry, since some jobs reuse their identifier and replace their log. Searching the page with Ctrl+F already misses collapsed stack traces today, so this wouldn’t change much. The plain-text download from question 1 would be the way to search them.
Option 3: Client-side rendering without Live Data
For completeness: we could also write a dedicated client-side log component, for example in Vue. The server would provide pages of structured log entries, and the component would display only the visible entries (virtualized list) and keep a limited number of pages in memory. This gives the best control over memory and following a running job. However, it’s a lot of new code next to Live Data, and it needs the same work on the server (paging by level, serializing log arguments) as Live Data would. I don’t think it’s worth it compared to option 1 in the long term and option 2 in the short term.
Summary
My current plan would be option 2 now, to be backported to stable-18.10.x, and option 1 once XCOMMONS-3249 is done. Which of the answers to questions 1–4 would you prefer? Do you have any other ideas or feedback on this topic?
Note that these questions and ideas are based on a preliminary analysis with Claude Opus 5.5. Neither Claude nor I have fully verified that each option can be implemented. With this proposal, I mainly want to gather your opinions on which of these options I should pursue further.
Disclaimer: this proposal was written with the help of Claude Opus 5.5, based on an initial draft written by me.