GithubHelp home page GithubHelp logo

rzbdz / min-cgc Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16 KB

A simple and slow conservative garbage collector using mark and sweep with explicit linked list malloc implementation for C programing language. (for leaning garbage collection purpose). Could be modified to adapt xv6.

License: Apache License 2.0

Makefile 1.29% C 98.71%
c garbage-collection

min-cgc's Introduction

min-cgc

A simple and NOT-fast conservative garbage collector (merely a toy for learning basic garbage collection concepts) using mark-and-sweep for C programing language. Provide interface of malloc/free and garbage collection without side effect.

The cgc_malloc, cgc_free, cgc_realloc package is tested using CSAPP3e malloclab mdriver to test. The gc package is tested using some novice codes in the cgc.c source file.

algorithm:

  • cgc_malloc() basically use ordinary segregated explicit free lists to manage heap memory allocated by calling sbrk() (might be switched to mmap() in the future).

  • the gc algorithm is simple mark-and-sweep (STW), if possible, could be implemented in incremental way.

interfaces:

  • int cgc_init() explicitly delegate memory management to min-cgc.

  • int cgc(void) stop the world and do gc.

  • void* cgc_malloc(size_t size) similar to malloc() in unix.

  • void cgc_free(void *ptr) similar to free() in unix.

  • void *realloc(void *ptr, size_t size)

performance

  • The cgc_malloc, cgc_free, cgc_realloc test results using CSAPP3e mdriver in malloclab:
    trace valid util ops secs Kops
    0 yes 98% 5694 0.000721 7902
    1 yes 94% 5848 0.000940 6221
    2 yes 96% 6648 0.001482 4486
    3 yes 95% 5380 0.001758 3060
    4 yes 94% 14400 0.000429 33535
    5 yes 94% 4800 0.000927 5180
    6 yes 93% 4800 0.000799 6008
    7 yes 94% 12000 0.001891 6348
    8 yes 81% 24000 0.002075 11567
    9 yes 99% 14401 0.000365 39433
    10 yes 99% 14401 0.000211 68348
    Total pass 94% 112372 0.011597 9690
  • The garbage collection performance:. (none, it's very slow)
  • test cgc calls with gc most the time and free in test_many_objects(@see src code):
    throughput util
    1106 Kops 88.3%
  • test frequent cgc calls with test_many_objects(@see src code) keep 20,000 objects alive:
    throughput util
    5 Kops 68.3%

naming style:

  • functions are named in snake case e.g. cgc_init.
  • structures are named in pascal case e.g. Header.
  • malloc are using snake upper case e.g. SIZE.

git commit log prefix:

  • feat
  • fix
  • docs
  • style
  • refactor
  • test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.