mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
better defaults and debugging for fixed size chunks
This commit is contained in:
parent
696bf30f5e
commit
9100909ae1
4 changed files with 56 additions and 3 deletions
24
benchmarks/gabriel/difftimes.sh
Executable file
24
benchmarks/gabriel/difftimes.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# set -ex
|
||||||
|
|
||||||
|
BENCHDIR=$(dirname $0)
|
||||||
|
if [ "${BENCHDIR%%/*}" = "." ]; then
|
||||||
|
BENCHDIR="$(pwd)${BENCHDIR#.}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
TS1="${1:--2}"
|
||||||
|
TS2="${2:--1}"
|
||||||
|
DB="${3:-${BENCHDIR}/times.tsv}"
|
||||||
|
|
||||||
|
if [ "$TS1" -lt 1000000000 ]; then
|
||||||
|
TS1=$(cut -f 7 "$DB" | sort -nru | tail -n +$((0 - TS1)) | head -1)
|
||||||
|
fi
|
||||||
|
if [ "$TS2" -lt 1000000000 ]; then
|
||||||
|
TS2=$(cut -f 7 "$DB" | sort -nru | tail -n +$((0 - TS2)) | head -1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
join -t $'\t' \
|
||||||
|
<(grep $'\t'"$TS1"$'\t' "$DB" | cut -f 1-2) \
|
||||||
|
<(grep $'\t'"$TS2"$'\t' "$DB" | cut -f 1-2) \
|
||||||
|
| perl -F'\t' -ane '$g=($F[1]<=0)?0:100*($F[2]-$F[1])/$F[1]; printf STDOUT "%s\t%d\t%d\t%.2f%%\n", @F, $g'
|
18
gc.c
18
gc.c
|
@ -45,6 +45,22 @@ static size_t sexp_heap_total_size (sexp_heap h) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ! SEXP_USE_GLOBAL_HEAP
|
#if ! SEXP_USE_GLOBAL_HEAP
|
||||||
|
#if SEXP_USE_DEBUG_GC
|
||||||
|
void sexp_debug_heap_stats (sexp_heap heap) {
|
||||||
|
sexp_free_list ls;
|
||||||
|
size_t available = 0;
|
||||||
|
for (ls=heap->free_list; ls; ls=ls->next)
|
||||||
|
available += ls->size;
|
||||||
|
#if SEXP_USE_FIXED_CHUNK_SIZE_HEAPS
|
||||||
|
sexp_debug_printf("free heap: %p (chunk size: %lu): %ld / %ld used (%.2f%%)", heap, heap->chunk_size, heap->size - available, heap->size, 100*(heap->size - available) / (float)heap->size);
|
||||||
|
#else
|
||||||
|
sexp_debug_printf("free heap: %p: %ld / %ld used (%.2f%%)", heap, heap->size - available, heap->size, 100*(heap->size - available) / (float)heap->size);
|
||||||
|
#endif
|
||||||
|
if (heap->next)
|
||||||
|
sexp_debug_heap_stats(heap->next);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void sexp_free_heap (sexp_heap heap) {
|
void sexp_free_heap (sexp_heap heap) {
|
||||||
#if SEXP_USE_MMAP_GC
|
#if SEXP_USE_MMAP_GC
|
||||||
munmap(heap, sexp_heap_pad_size(heap->size));
|
munmap(heap, sexp_heap_pad_size(heap->size));
|
||||||
|
@ -618,4 +634,4 @@ void sexp_gc_init (void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* ! SEXP_USE_BOEHM && ! SEXP_USE_MALLOC */
|
||||||
|
|
|
@ -1760,9 +1760,11 @@ SEXP_API sexp sexp_finalize (sexp ctx);
|
||||||
|
|
||||||
#if SEXP_USE_GLOBAL_HEAP
|
#if SEXP_USE_GLOBAL_HEAP
|
||||||
#define sexp_free_heap(heap)
|
#define sexp_free_heap(heap)
|
||||||
|
#define sexp_debug_heap_stats(heap)
|
||||||
#define sexp_destroy_context(ctx) SEXP_TRUE
|
#define sexp_destroy_context(ctx) SEXP_TRUE
|
||||||
#else
|
#else
|
||||||
SEXP_API void sexp_free_heap (sexp_heap heap);
|
SEXP_API void sexp_free_heap (sexp_heap heap);
|
||||||
|
SEXP_API void sexp_debug_heap_stats (sexp_heap heap);
|
||||||
SEXP_API sexp sexp_destroy_context (sexp ctx);
|
SEXP_API sexp sexp_destroy_context (sexp ctx);
|
||||||
SEXP_API sexp sexp_copy_context (sexp ctx, sexp dst, sexp flags);
|
SEXP_API sexp sexp_copy_context (sexp ctx, sexp dst, sexp flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
15
sexp.c
15
sexp.c
|
@ -617,8 +617,16 @@ sexp sexp_bootstrap_context (sexp_uint_t size, sexp_uint_t max_size) {
|
||||||
} else {
|
} else {
|
||||||
sexp_context_heap(ctx) = heap;
|
sexp_context_heap(ctx) = heap;
|
||||||
#if SEXP_USE_FIXED_CHUNK_SIZE_HEAPS
|
#if SEXP_USE_FIXED_CHUNK_SIZE_HEAPS
|
||||||
heap->chunk_size = 1<<(4+SEXP_64_BIT);
|
heap->chunk_size = sexp_heap_align(1);
|
||||||
sexp_grow_heap(ctx, sexp_heap_align(size), 0);
|
heap->next = sexp_make_heap(size, max_size, 0);
|
||||||
|
if (heap->next) {
|
||||||
|
heap->next->chunk_size = sexp_heap_align(1 + sexp_heap_align(1));
|
||||||
|
heap->next->next = sexp_make_heap(size, max_size, 0);
|
||||||
|
if (heap->next->next) {
|
||||||
|
heap->next->next->chunk_size = sexp_heap_align(1 + sexp_heap_align(1 + sexp_heap_align(1)));
|
||||||
|
heap->next->next->next = sexp_make_heap(size, max_size, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
|
@ -677,6 +685,9 @@ sexp sexp_destroy_context (sexp ctx) {
|
||||||
size_t sum_freed;
|
size_t sum_freed;
|
||||||
if (sexp_context_heap(ctx)) {
|
if (sexp_context_heap(ctx)) {
|
||||||
heap = sexp_context_heap(ctx);
|
heap = sexp_context_heap(ctx);
|
||||||
|
#if SEXP_USE_DEBUG_GC
|
||||||
|
sexp_debug_heap_stats(heap);
|
||||||
|
#endif
|
||||||
sexp_markedp(ctx) = 1;
|
sexp_markedp(ctx) = 1;
|
||||||
sexp_markedp(sexp_context_globals(ctx)) = 1;
|
sexp_markedp(sexp_context_globals(ctx)) = 1;
|
||||||
sexp_mark(ctx, sexp_global(ctx, SEXP_G_TYPES));
|
sexp_mark(ctx, sexp_global(ctx, SEXP_G_TYPES));
|
||||||
|
|
Loading…
Add table
Reference in a new issue