Diff of /src/runtime/gencgc.c [1100ef] .. [f71d9c] Maximize Restore

  Switch to unified view

a/src/runtime/gencgc.c b/src/runtime/gencgc.c
...
...
431
    return
431
    return
432
        ((double)generations[gen].cum_sum_bytes_allocated)
432
        ((double)generations[gen].cum_sum_bytes_allocated)
433
        / ((double)generations[gen].bytes_allocated);
433
        / ((double)generations[gen].bytes_allocated);
434
}
434
}
435
435
436
/* The verbose argument controls how much to print: 0 for normal
437
 * level of detail; 1 for debugging. */
438
extern void
436
extern void
439
print_generation_stats() /* FIXME: should take FILE argument, or construct a string */
437
write_generation_stats(FILE *file)
440
{
438
{
441
    generation_index_t i;
439
    generation_index_t i;
442
440
443
#if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
441
#if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
444
#define FPU_STATE_SIZE 27
442
#define FPU_STATE_SIZE 27
...
...
451
    /* This code uses the FP instructions which may be set up for Lisp
449
    /* This code uses the FP instructions which may be set up for Lisp
452
     * so they need to be saved and reset for C. */
450
     * so they need to be saved and reset for C. */
453
    fpu_save(fpu_state);
451
    fpu_save(fpu_state);
454
452
455
    /* Print the heap stats. */
453
    /* Print the heap stats. */
456
    fprintf(stderr,
454
    fprintf(file,
457
            " Gen StaPg UbSta LaSta LUbSt Boxed Unboxed LB   LUB  !move  Alloc  Waste   Trig    WP  GCs Mem-age\n");
455
            " Gen StaPg UbSta LaSta LUbSt Boxed Unboxed LB   LUB  !move  Alloc  Waste   Trig    WP  GCs Mem-age\n");
458
456
459
    for (i = 0; i < SCRATCH_GENERATION; i++) {
457
    for (i = 0; i < SCRATCH_GENERATION; i++) {
460
        page_index_t j;
458
        page_index_t j;
461
        long boxed_cnt = 0;
459
        long boxed_cnt = 0;
...
...
486
                }
484
                }
487
            }
485
            }
488
486
489
        gc_assert(generations[i].bytes_allocated
487
        gc_assert(generations[i].bytes_allocated
490
                  == count_generation_bytes_allocated(i));
488
                  == count_generation_bytes_allocated(i));
491
        fprintf(stderr,
489
        fprintf(file,
492
                "   %1d: %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %8ld %5ld %8ld %4ld %3d %7.4f\n",
490
                "   %1d: %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %5ld %8ld %5ld %8ld %4ld %3d %7.4f\n",
493
                i,
491
                i,
494
                generations[i].alloc_start_page,
492
                generations[i].alloc_start_page,
495
                generations[i].alloc_unboxed_start_page,
493
                generations[i].alloc_unboxed_start_page,
496
                generations[i].alloc_large_start_page,
494
                generations[i].alloc_large_start_page,
...
...
506
                generations[i].gc_trigger,
504
                generations[i].gc_trigger,
507
                count_write_protect_generation_pages(i),
505
                count_write_protect_generation_pages(i),
508
                generations[i].num_gc,
506
                generations[i].num_gc,
509
                generation_average_age(i));
507
                generation_average_age(i));
510
    }
508
    }
511
    fprintf(stderr,"   Total bytes allocated    = %lu\n", bytes_allocated);
509
    fprintf(file,"   Total bytes allocated    = %lu\n", bytes_allocated);
512
    fprintf(stderr,"   Dynamic-space-size bytes = %u\n", dynamic_space_size);
510
    fprintf(file,"   Dynamic-space-size bytes = %lu\n", (unsigned long)dynamic_space_size);
513
511
514
    fpu_restore(fpu_state);
512
    fpu_restore(fpu_state);
513
}
514
515
extern void
516
print_generation_stats()
517
{
518
    write_generation_stats(stderr);
519
}
520
521
extern char* gc_logfile;
522
char * gc_logfile = NULL;
523
524
extern void
525
log_generation_stats(char *logfile, char *header)
526
{
527
    if (logfile) {
528
        FILE * log = fopen(logfile, "a");
529
        if (log) {
530
            fprintf(log, "%s\n", header);
531
            write_generation_stats(log);
532
            fclose(log);
533
        } else {
534
            fprintf(stderr, "Could not open gc logile: %s\n", gc_logfile);
535
            fflush(stderr);
536
        }
537
    }
515
}
538
}
516

539

517
540
518
#if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
541
#if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
519
void fast_bzero(void*, size_t); /* in <arch>-assem.S */
542
void fast_bzero(void*, size_t); /* in <arch>-assem.S */
...
...
1163
     */
1186
     */
1164
    fprintf(stderr, "Heap exhausted during %s: %ld bytes available, %ld requested.\n",
1187
    fprintf(stderr, "Heap exhausted during %s: %ld bytes available, %ld requested.\n",
1165
            gc_active_p ? "garbage collection" : "allocation",
1188
            gc_active_p ? "garbage collection" : "allocation",
1166
            available, requested);
1189
            available, requested);
1167
    print_generation_stats();
1190
    print_generation_stats();
1168
        fprintf(stderr, "GC control variables:\n");
1191
    fprintf(stderr, "GC control variables:\n");
1169
        fprintf(stderr, "   *GC-INHIBIT* = %s\n   *GC-PENDING* = %s\n",
1192
    fprintf(stderr, "   *GC-INHIBIT* = %s\n   *GC-PENDING* = %s\n",
1170
                SymbolValue(GC_INHIBIT,thread)==NIL ? "false" : "true",
1193
            SymbolValue(GC_INHIBIT,thread)==NIL ? "false" : "true",
1171
                (SymbolValue(GC_PENDING, thread) == T) ?
1194
            (SymbolValue(GC_PENDING, thread) == T) ?
1172
                "true" : ((SymbolValue(GC_PENDING, thread) == NIL) ?
1195
            "true" : ((SymbolValue(GC_PENDING, thread) == NIL) ?
1173
                  "false" : "in progress"));
1196
                      "false" : "in progress"));
1174
#ifdef LISP_FEATURE_SB_THREAD
1197
#ifdef LISP_FEATURE_SB_THREAD
1175
        fprintf(stderr, "   *STOP-FOR-GC-PENDING* = %s\n",
1198
    fprintf(stderr, "   *STOP-FOR-GC-PENDING* = %s\n",
1176
                SymbolValue(STOP_FOR_GC_PENDING,thread)==NIL ? "false" : "true");
1199
            SymbolValue(STOP_FOR_GC_PENDING,thread)==NIL ? "false" : "true");
1177
#endif
1200
#endif
1178
    if (gc_active_p || (available == 0)) {
1201
    if (gc_active_p || (available == 0)) {
1179
        /* If we are in GC, or totally out of memory there is no way
1202
        /* If we are in GC, or totally out of memory there is no way
1180
         * to sanely transfer control to the lisp-side of things.
1203
         * to sanely transfer control to the lisp-side of things.
1181
         */
1204
         */
...
...
4257
    /* The largest value of last_free_page seen since the time
4280
    /* The largest value of last_free_page seen since the time
4258
     * remap_free_pages was called. */
4281
     * remap_free_pages was called. */
4259
    static page_index_t high_water_mark = 0;
4282
    static page_index_t high_water_mark = 0;
4260
4283
4261
    FSHOW((stderr, "/entering collect_garbage(%d)\n", last_gen));
4284
    FSHOW((stderr, "/entering collect_garbage(%d)\n", last_gen));
4285
    log_generation_stats(gc_logfile, "=== GC Start ===");
4262
4286
4263
    gc_active_p = 1;
4287
    gc_active_p = 1;
4264
4288
4265
    if (last_gen > HIGHEST_NORMAL_GENERATION+1) {
4289
    if (last_gen > HIGHEST_NORMAL_GENERATION+1) {
4266
        FSHOW((stderr,
4290
        FSHOW((stderr,
...
...
4381
        high_water_mark = 0;
4405
        high_water_mark = 0;
4382
    }
4406
    }
4383
4407
4384
    gc_active_p = 0;
4408
    gc_active_p = 0;
4385
4409
4410
    log_generation_stats(gc_logfile, "=== GC End ===");
4386
    SHOW("returning from collect_garbage");
4411
    SHOW("returning from collect_garbage");
4387
}
4412
}
4388
4413
4389
/* This is called by Lisp PURIFY when it is finished. All live objects
4414
/* This is called by Lisp PURIFY when it is finished. All live objects
4390
 * will have been moved to the RO and Static heaps. The dynamic space
4415
 * will have been moved to the RO and Static heaps. The dynamic space