summaryrefslogtreecommitdiff
path: root/frontends/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-11-27 17:10:03 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2016-11-27 17:10:03 +0000
commit0bc32aa654271fd592d36fabf272e3fa0ca0a450 (patch)
tree3fadc9b2700f9dea38c271a440cbbd9e33bda2b7 /frontends/amiga
parent4fb38f574a303d53fb3e4560e76163e4e97687b3 (diff)
downloadnetsurf-0bc32aa654271fd592d36fabf272e3fa0ca0a450.tar.gz
netsurf-0bc32aa654271fd592d36fabf272e3fa0ca0a450.tar.bz2
Add more clib2 stats
JSON formatted data can now be saved with ARexx "SLABSTATS stats.json"
Diffstat (limited to 'frontends/amiga')
-rw-r--r--frontends/amiga/arexx.c11
-rwxr-xr-xfrontends/amiga/memory.c41
-rw-r--r--frontends/amiga/memory.h2
3 files changed, 47 insertions, 7 deletions
diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c
index 18dae24d1..b9702287b 100644
--- a/frontends/amiga/arexx.c
+++ b/frontends/amiga/arexx.c
@@ -118,7 +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 },
+ {"SLABSTATS", RX_SLABSTATS, rx_slabstats, "FILE", 0, NULL, 0, 0, NULL },
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
};
@@ -674,7 +674,14 @@ RXHOOKF(rx_hotlist)
RXHOOKF(rx_slabstats)
{
#ifndef __amigaos4__
- ami_memory_slab_dump();
+ BPTR fh = 0;
+
+ if(cmd->ac_ArgList[0] != NULL) {
+ fh = Open((char *)cmd->ac_ArgList[0], MODE_NEWFILE);
+ }
+ ami_memory_slab_dump(fh);
+
+ if(fh != 0) Close(fh);
#endif
}
diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c
index 8f901a17e..d371d2585 100755
--- a/frontends/amiga/memory.c
+++ b/frontends/amiga/memory.c
@@ -17,6 +17,7 @@
*/
#ifndef __amigaos4__
+#include <proto/dos.h>
#include <proto/exec.h>
#include <exec/interrupts.h>
#include <stdlib.h>
@@ -46,7 +47,7 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value)
}
/* clib2 slab allocator stats */
-static int ami_memory_slab_callback(const struct __slab_usage_information * sui)
+static int ami_memory_slab_usage_cb(const struct __slab_usage_information * sui)
{
if(sui->sui_slab_index <= 1) {
LOG("clib2 slab usage:");
@@ -70,11 +71,43 @@ static int ami_memory_slab_callback(const struct __slab_usage_information * sui)
return 0;
}
-void ami_memory_slab_dump(void)
+static int ami_memory_slab_alloc_cb(const struct __slab_allocation_information *sai)
{
- __get_slab_usage(ami_memory_slab_callback);
+ if(sai->sai_allocation_index <= 1) {
+ LOG("clib2 allocation usage:");
+ LOG(" Number of allocations which are not managed by slabs: %ld",
+ sai->sai_num_single_allocations);
+ LOG(" Total number of bytes allocated for memory not managed by slabs: %ld",
+ sai->sai_total_single_allocation_size);
+ }
+ LOG("Alloc %d", sai->sai_allocation_index);
+ LOG(" Size of this allocation, as requested: %ld", sai->sai_allocation_size);
+ LOG(" Total size of this allocation, including management data: %ld",
+ sai->sai_total_allocation_size);
+
+ return 0;
+}
+
+static int ami_memory_slab_stats_cb(void *user_data, const char *line, size_t line_length)
+{
+ BPTR fh = (BPTR)user_data;
+ long err = FPuts(fh, line);
+
+ if(err != 0) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+void ami_memory_slab_dump(BPTR fh)
+{
+ __get_slab_usage(ami_memory_slab_usage_cb);
+ __get_slab_allocations(ami_memory_slab_alloc_cb);
+ __get_slab_stats(fh, ami_memory_slab_stats_cb);
}
+/* Low memory handler */
static void ami_memory_low_mem_handler(void *p)
{
if(low_mem_status == PURGE_STEP1) {
@@ -115,7 +148,7 @@ struct Interrupt *ami_memory_init(void)
struct Interrupt *memhandler = malloc(sizeof(struct Interrupt));
if(memhandler == NULL) return NULL; // we're screwed
- memhandler->is_Node.ln_Pri = -100; // low down as will be slow
+ memhandler->is_Node.ln_Pri = -127; // low down as will be slow
memhandler->is_Node.ln_Name = "NetSurf low memory handler";
memhandler->is_Data = NULL;
memhandler->is_Code = (APTR)&ami_memory_handler;
diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h
index a87a3ea97..7abf0a387 100644
--- a/frontends/amiga/memory.h
+++ b/frontends/amiga/memory.h
@@ -59,7 +59,7 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value);
/* clib2 slab allocator */
#ifndef __amigaos4__
-void ami_memory_slab_dump(void);
+void ami_memory_slab_dump(BPTR fh);
struct Interrupt *ami_memory_init(void);
void ami_memory_fini(struct Interrupt *memhandler);
#endif