mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
move bitmap cache initialisation up a level
improve stats reporting svn path=/trunk/netsurf/; revision=12770
This commit is contained in:
parent
6814a07243
commit
69bee6fb71
@ -39,6 +39,7 @@
|
||||
#include "content/urldb.h"
|
||||
#include "css/css.h"
|
||||
#include "image/image.h"
|
||||
#include "image/image_cache.h"
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/401login.h"
|
||||
#include "desktop/browser.h"
|
||||
@ -53,6 +54,22 @@
|
||||
#include "utils/utils.h"
|
||||
#include "utils/messages.h"
|
||||
|
||||
/** speculative pre-conversion small image size
|
||||
*
|
||||
* Experimenting by visiting every page from default page in order and
|
||||
* then netsurf homepage
|
||||
*
|
||||
* 0 : Cache hit/miss/speculative miss/fail 604/147/ 0/0 (80%/19%/ 0%/ 0%)
|
||||
* 2048 : Cache hit/miss/speculative miss/fail 622/119/ 17/0 (82%/15%/ 2%/ 0%)
|
||||
* 4096 : Cache hit/miss/speculative miss/fail 656/109/ 25/0 (83%/13%/ 3%/ 0%)
|
||||
* 8192 : Cache hit/miss/speculative miss/fail 648/104/ 40/0 (81%/13%/ 5%/ 0%)
|
||||
* ALL : Cache hit/miss/speculative miss/fail 775/ 0/161/0 (82%/ 0%/17%/ 0%)
|
||||
*/
|
||||
#define SPECULATE_SMALL 4096
|
||||
|
||||
/* the time between cache clean runs in ms */
|
||||
#define IMAGE_CACHE_CLEAN_TIME (10 * 1000)
|
||||
|
||||
bool netsurf_quit = false;
|
||||
bool verbose_log = false;
|
||||
|
||||
@ -102,6 +119,12 @@ nserror netsurf_init(int *pargc,
|
||||
nserror error;
|
||||
struct utsname utsname;
|
||||
nserror ret = NSERROR_OK;
|
||||
struct image_cache_parameters image_cache_parameters = {
|
||||
.bg_clean_time = IMAGE_CACHE_CLEAN_TIME,
|
||||
.limit = (8 * 1024 * 1024),
|
||||
.hysteresis = (2 * 1024 * 1024),
|
||||
.speculative_small = SPECULATE_SMALL
|
||||
};
|
||||
|
||||
#ifdef HAVE_SIGPIPE
|
||||
/* Ignore SIGPIPE - this is necessary as OpenSSL can generate these
|
||||
@ -140,6 +163,12 @@ nserror netsurf_init(int *pargc,
|
||||
|
||||
messages_load(messages);
|
||||
|
||||
/* image handler bitmap cache */
|
||||
error = image_cache_init(&image_cache_parameters);
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
|
||||
/* content handler initialisation */
|
||||
error = css_init();
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
@ -156,6 +185,7 @@ nserror netsurf_init(int *pargc,
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
|
||||
|
||||
error = mimesniff_init();
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
@ -222,6 +252,9 @@ void netsurf_exit(void)
|
||||
html_fini();
|
||||
css_fini();
|
||||
|
||||
/* dump any remaining cache entries */
|
||||
image_cache_fini();
|
||||
|
||||
content_factory_fini();
|
||||
|
||||
LOG(("Closing utf8"));
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "utils/errors.h"
|
||||
|
||||
#include "image/image.h"
|
||||
#include "image/image_cache.h"
|
||||
#include "image/bmp.h"
|
||||
#include "image/gif.h"
|
||||
#include "image/ico.h"
|
||||
@ -38,22 +37,6 @@
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
/** low water mark for speculative pre-conversion */
|
||||
|
||||
/* Experimenting by visiting every page from default page in order and
|
||||
* then netsurf homepage
|
||||
*
|
||||
* 0 : Cache hit/miss/speculative miss/fail 604/147/ 0/0 (80%/19%/ 0%/ 0%)
|
||||
* 2048 : Cache hit/miss/speculative miss/fail 622/119/ 17/0 (82%/15%/ 2%/ 0%)
|
||||
* 4096 : Cache hit/miss/speculative miss/fail 656/109/ 25/0 (83%/13%/ 3%/ 0%)
|
||||
* 8192 : Cache hit/miss/speculative miss/fail 648/104/ 40/0 (81%/13%/ 5%/ 0%)
|
||||
* ALL : Cache hit/miss/speculative miss/fail 775/ 0/161/0 (82%/ 0%/17%/ 0%)
|
||||
*/
|
||||
#define SPECULATE_SMALL 4096
|
||||
|
||||
/* the time between cache clean runs in ms */
|
||||
#define CACHE_CLEAN_TIME (10 * 1000)
|
||||
|
||||
/**
|
||||
* Initialise image content handlers
|
||||
*
|
||||
@ -62,16 +45,6 @@
|
||||
nserror image_init(void)
|
||||
{
|
||||
nserror error;
|
||||
struct image_cache_parameters image_cache_parameters = {
|
||||
.bg_clean_time = CACHE_CLEAN_TIME,
|
||||
.limit = (8 * 1024 * 1024),
|
||||
.hysteresis = (2 * 1024 * 1024),
|
||||
.speculative_small = SPECULATE_SMALL
|
||||
};
|
||||
|
||||
error = image_cache_init(&image_cache_parameters);
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
|
||||
#ifdef WITH_BMP
|
||||
error = nsbmp_init();
|
||||
@ -187,7 +160,5 @@ void image_fini(void)
|
||||
webp_fini();
|
||||
#endif
|
||||
|
||||
/* dump any remaining cache entries */
|
||||
image_cache_fini();
|
||||
}
|
||||
|
||||
|
@ -94,12 +94,15 @@ struct image_cache_s {
|
||||
|
||||
/** Bitmap was not available at plot time required conversion */
|
||||
int miss_count;
|
||||
size_t miss_size;
|
||||
/** Bitmap was available at plot time required no conversion */
|
||||
int hit_count;
|
||||
size_t hit_size;
|
||||
/** Bitmap was not available at plot time and required
|
||||
* conversion which failed.
|
||||
*/
|
||||
int fail_count;
|
||||
size_t fail_size;
|
||||
|
||||
/* Cache entry freed without ever being redrawn */
|
||||
int total_unrendered;
|
||||
@ -291,11 +294,14 @@ struct bitmap *image_cache_get_bitmap(struct content *c)
|
||||
if (centry->bitmap != NULL) {
|
||||
image_cache_stats_bitmap_add(centry);
|
||||
image_cache->miss_count++;
|
||||
image_cache->miss_size += centry->bitmap_size;
|
||||
} else {
|
||||
image_cache->fail_count++;
|
||||
image_cache->fail_size += centry->bitmap_size;
|
||||
}
|
||||
} else {
|
||||
image_cache->hit_count++;
|
||||
image_cache->hit_size += centry->bitmap_size;
|
||||
}
|
||||
|
||||
return centry->bitmap;
|
||||
@ -358,32 +364,43 @@ image_cache_init(const struct image_cache_parameters *image_cache_parameters)
|
||||
nserror image_cache_fini(void)
|
||||
{
|
||||
int op_count;
|
||||
size_t op_size;
|
||||
|
||||
schedule_remove(image_cache__background_update, image_cache);
|
||||
|
||||
op_count = image_cache->hit_count +
|
||||
image_cache->miss_count +
|
||||
image_cache->specultive_miss_count +
|
||||
image_cache->fail_count;
|
||||
|
||||
LOG(("Destroying Remaining Image cache entries"));
|
||||
LOG(("Size at finish %d (in %d)", image_cache->total_bitmap_size, image_cache->bitmap_count));
|
||||
|
||||
while (image_cache->entries != NULL) {
|
||||
image_cache__free_entry(image_cache->entries);
|
||||
}
|
||||
|
||||
LOG(("Image cache size at finish %d (in %d)", image_cache->total_bitmap_size, image_cache->bitmap_count));
|
||||
op_count = image_cache->hit_count +
|
||||
image_cache->miss_count +
|
||||
image_cache->fail_count;
|
||||
|
||||
op_size = image_cache->hit_size +
|
||||
image_cache->miss_size +
|
||||
image_cache->fail_size;
|
||||
|
||||
LOG(("Age %ds", image_cache->current_age / 1000));
|
||||
LOG(("Peak size %d (in %d)", image_cache->max_bitmap_size, image_cache->max_bitmap_size_count ));
|
||||
LOG(("Peak image count %d (size %d)", image_cache->max_bitmap_count, image_cache->max_bitmap_count_size));
|
||||
LOG(("Cache hit/miss/speculative miss/fail %d/%d/%d/%d (%d%%/%d%%/%d%%/%d%%)",
|
||||
LOG(("Cache total/hit/miss/fail (counts) %d/%d/%d/%d (100%%/%d%%/%d%%/%d%%)",
|
||||
op_count,
|
||||
image_cache->hit_count,
|
||||
image_cache->miss_count,
|
||||
image_cache->specultive_miss_count,
|
||||
image_cache->fail_count,
|
||||
(image_cache->hit_count * 100) / op_count,
|
||||
(image_cache->miss_count * 100) / op_count,
|
||||
(image_cache->specultive_miss_count * 100) / op_count,
|
||||
(image_cache->fail_count * 100) / op_count));
|
||||
LOG(("Cache total/hit/miss/fail (size) %d/%d/%d/%d (100%%/%d%%/%d%%/%d%%)",
|
||||
op_size,
|
||||
image_cache->hit_size,
|
||||
image_cache->miss_size,
|
||||
image_cache->fail_size,
|
||||
(image_cache->hit_size * 100) / op_size,
|
||||
(image_cache->miss_size * 100) / op_size,
|
||||
(image_cache->fail_size * 100) / op_size));
|
||||
LOG(("Total images never rendered: %d (includes %d that were converted)",
|
||||
image_cache->total_unrendered,
|
||||
image_cache->specultive_miss_count));
|
||||
@ -495,12 +512,15 @@ bool image_cache_redraw(struct content *c,
|
||||
if (centry->bitmap != NULL) {
|
||||
image_cache_stats_bitmap_add(centry);
|
||||
image_cache->miss_count++;
|
||||
image_cache->miss_size += centry->bitmap_size;
|
||||
} else {
|
||||
image_cache->fail_count++;
|
||||
image_cache->fail_size += centry->bitmap_size;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
image_cache->hit_count++;
|
||||
image_cache->hit_size += centry->bitmap_size;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user