mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-02 01:04:33 +03:00
Get clib2 slab usage
Calling ARexx function "SLABSTATS" will dump the current stats to the ns log
This commit is contained in:
parent
17128fd0ad
commit
5ce3b93457
@ -45,6 +45,10 @@
|
||||
#include "amiga/misc.h"
|
||||
#include "amiga/theme.h"
|
||||
|
||||
#ifndef __amigaos4__
|
||||
#include "amiga/memory.h"
|
||||
#endif
|
||||
|
||||
extern const char * const verarexx;
|
||||
extern const char * const wt_revid;
|
||||
|
||||
@ -65,7 +69,8 @@ enum
|
||||
RX_WINDOWS,
|
||||
RX_ACTIVE,
|
||||
RX_CLOSE,
|
||||
RX_HOTLIST
|
||||
RX_HOTLIST,
|
||||
RX_SLABSTATS
|
||||
};
|
||||
|
||||
static Object *arexx_obj = NULL;
|
||||
@ -93,6 +98,7 @@ RXHOOKF(rx_windows);
|
||||
RXHOOKF(rx_active);
|
||||
RXHOOKF(rx_close);
|
||||
RXHOOKF(rx_hotlist);
|
||||
RXHOOKF(rx_slabstats);
|
||||
|
||||
STATIC struct ARexxCmd Commands[] =
|
||||
{
|
||||
@ -112,6 +118,7 @@ STATIC struct ARexxCmd Commands[] =
|
||||
{"ACTIVE", RX_ACTIVE, rx_active, "T=TAB/S", 0, NULL, 0, 0, NULL },
|
||||
{"CLOSE", RX_CLOSE, rx_close, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
||||
{"HOTLIST", RX_HOTLIST, rx_hotlist, "A=ACTION/A", 0, NULL, 0, 0, NULL },
|
||||
{"SLABSTATS", RX_SLABSTATS, rx_slabstats, NULL, 0, NULL, 0, 0, NULL },
|
||||
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
|
||||
};
|
||||
|
||||
@ -664,3 +671,10 @@ RXHOOKF(rx_hotlist)
|
||||
}
|
||||
}
|
||||
|
||||
RXHOOKF(rx_slabstats)
|
||||
{
|
||||
#ifndef __amigaos4__
|
||||
ami_memory_slab_dump();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,9 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
|
||||
{
|
||||
struct bitmap *bitmap;
|
||||
|
||||
if(pool_bitmap == NULL) pool_bitmap = ami_misc_itempool_create(sizeof(struct bitmap));
|
||||
if(pool_bitmap == NULL) pool_bitmap = ami_memory_itempool_create(sizeof(struct bitmap));
|
||||
|
||||
bitmap = ami_misc_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
|
||||
bitmap = ami_memory_itempool_alloc(pool_bitmap, sizeof(struct bitmap));
|
||||
if(bitmap == NULL) return NULL;
|
||||
|
||||
bitmap->pixdata = ami_memory_clear_alloc(width*height*4, 0xff);
|
||||
@ -182,7 +182,7 @@ void amiga_bitmap_destroy(void *bitmap)
|
||||
bm->url = NULL;
|
||||
bm->title = NULL;
|
||||
|
||||
ami_misc_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
|
||||
ami_memory_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
|
||||
bm = NULL;
|
||||
}
|
||||
}
|
||||
@ -655,7 +655,7 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
|
||||
|
||||
void ami_bitmap_fini(void)
|
||||
{
|
||||
if(pool_bitmap) ami_misc_itempool_delete(pool_bitmap);
|
||||
if(pool_bitmap) ami_memory_itempool_delete(pool_bitmap);
|
||||
pool_bitmap = NULL;
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <proto/exec.h>
|
||||
|
||||
#include "amiga/memory.h"
|
||||
|
||||
#ifndef __amigaos4__
|
||||
#include <stdlib.h>
|
||||
#include "amiga/memory.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
ULONG __slab_max_size = 8192; /* Enable clib2's slab allocator */
|
||||
|
||||
/* Special clear (ie. non-zero) */
|
||||
@ -31,5 +30,35 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value)
|
||||
if (mem) memset(mem, value, size);
|
||||
return mem;
|
||||
}
|
||||
|
||||
/* clib2 slab allocator stats */
|
||||
static int ami_memory_slab_callback(const struct __slab_usage_information * sui)
|
||||
{
|
||||
if(sui->sui_slab_index <= 1) {
|
||||
LOG("clib2 slab usage:");
|
||||
LOG(" The size of all slabs, in bytes: %ld", sui->sui_slab_size);
|
||||
LOG(" Number of allocations which are not managed by slabs: %ld",
|
||||
sui->sui_num_single_allocations);
|
||||
LOG(" Total number of bytes allocated for memory not managed by slabs: %ld",
|
||||
sui->sui_total_single_allocation_size);
|
||||
LOG(" Number of slabs currently in play: %ld", sui->sui_num_slabs);
|
||||
LOG(" Number of currently unused slabs: %ld", sui->sui_num_empty_slabs);
|
||||
LOG(" Number of slabs in use which are completely filled with data: %ld",
|
||||
sui->sui_num_full_slabs);
|
||||
LOG(" Total number of bytes allocated for all slabs: %ld",
|
||||
sui->sui_total_slab_allocation_size);
|
||||
}
|
||||
LOG("Slab %d", sui->sui_slab_index);
|
||||
LOG(" Memory chunk size managed by this slab: %ld", sui->sui_chunk_size);
|
||||
LOG(" Number of memory chunks that fit in this slab: %ld", sui->sui_num_chunks);
|
||||
LOG(" Number of memory chunks used in this slab: %ld", sui->sui_num_chunks_used);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ami_memory_slab_dump(void)
|
||||
{
|
||||
__get_slab_usage(ami_memory_slab_callback);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -57,5 +57,10 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value);
|
||||
#define ami_memory_itempool_free(p,i,s) FreePooled(p,i,s)
|
||||
#endif
|
||||
|
||||
/* clib2 slab allocator stats */
|
||||
#ifndef __amigaos4__
|
||||
void ami_memory_slab_dump(void);
|
||||
#endif
|
||||
|
||||
#endif //AMIGA_MEMORY_H
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user