mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-03-04 06:11:33 +03:00
Performance improvements: rather than calling content_clean() every poll, we now call it no more frequently than once every 5 seconds. Additionally, we cache the result of talloc_total_size() in content_clean() rather than calculating it twice. On large documents, this function took 25% of CPU time. This makes the fetching/rendering/scrolling/redrawing of large documents over twice as fast.
svn path=/trunk/netsurf/; revision=4527
This commit is contained in:
parent
192faa2177
commit
e7c5e16b9b
@ -873,14 +873,15 @@ void content_clean(void)
|
||||
next = 0;
|
||||
for (c = content_list; c; c = c->next) {
|
||||
next = c;
|
||||
size += c->size + talloc_total_size(c);
|
||||
c->talloc_size = talloc_total_size(c);
|
||||
size += c->size + c->talloc_size;
|
||||
}
|
||||
for (c = next; c && (unsigned int) option_memory_cache_size < size;
|
||||
c = prev) {
|
||||
prev = c->prev;
|
||||
if (c->user_list->next)
|
||||
continue;
|
||||
size -= c->size + talloc_total_size(c);
|
||||
size -= c->size + c->talloc_size;
|
||||
content_destroy(c);
|
||||
}
|
||||
}
|
||||
|
@ -232,6 +232,7 @@ struct content {
|
||||
unsigned int size; /**< Estimated size of all data
|
||||
associated with this content, except
|
||||
alloced as talloc children of this. */
|
||||
off_t talloc_size; /**< Used by content_clean() */
|
||||
char *title; /**< Title for browser window. */
|
||||
unsigned int active; /**< Number of child fetches or
|
||||
conversions currently in progress. */
|
||||
|
@ -121,7 +121,16 @@ void netsurf_init(int argc, char** argv)
|
||||
|
||||
void netsurf_poll(void)
|
||||
{
|
||||
content_clean();
|
||||
static unsigned int last_clean = 0;
|
||||
unsigned int current_time = wallclock();
|
||||
|
||||
/* avoid calling content_clean() more often than once every 5
|
||||
* seconds.
|
||||
*/
|
||||
if (last_clean + 500 < current_time) {
|
||||
last_clean = current_time;
|
||||
content_clean();
|
||||
}
|
||||
gui_poll(fetch_active);
|
||||
fetch_poll();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user