<commit_before>use ctxt::SemContext;
use driver::cmd::Args;
use gc::arena;
use gc::Address;
use gc::Collector;
use gc::swiper::card::CardTable;
use gc::swiper::young::YoungGen;
use gc::swiper::old::OldGen;
use mem;

pub mod young;
pub mod old;
pub mod card;

const YOUNG_RATIO: u32 = 5;

// size of card is 128 bytes
// although stored in constant
// it is not really expected to change
const CARD_SIZE: usize = 128;
const CARD_SIZE_BITS: usize = 7;

pub struct Swiper {
    heap: Region,

    young: YoungGen,
    old: OldGen,
    card_table: CardTable,
}

impl Swiper {
    pub fn new(args: &Args) -> Swiper {
        let heap_size = args.flag_heap_size.map(|s| *s).unwrap_or(32 * 1024 * 1024);

        // set heap size to multiple of page
        let heap_size = mem::page_align(heap_size);

        // determine size for card table
        let card_size = mem::page_align(heap_size >> CARD_SIZE_BITS);

        let alloc_size = heap_size + card_size;

        let ptr = arena::reserve(alloc_size).expect("could not reserve memory");
        let ptr = Address::from_ptr(ptr);
<commit_msg>set card table size to 512 bytes<commit_after>use ctxt::SemContext;
use driver::cmd::Args;
use gc::arena;
use gc::Address;
use gc::Collector;
use gc::swiper::card::CardTable;
use gc::swiper::young::YoungGen;
use gc::swiper::old::OldGen;
use mem;

pub mod young;
pub mod old;
pub mod card;

const YOUNG_RATIO: u32 = 5;

// size of card is 128 bytes
// although stored in constant
// it is not really expected to change
const CARD_SIZE: usize = 512;
const CARD_SIZE_BITS: usize = 9;

pub struct Swiper {
    heap: Region,

    young: YoungGen,
    old: OldGen,
    card_table: CardTable,
}

impl Swiper {
    pub fn new(args: &Args) -> Swiper {
        let heap_size = args.flag_heap_size.map(|s| *s).unwrap_or(32 * 1024 * 1024);

        // set heap size to multiple of page
        let heap_size = mem::page_align(heap_size);

        // determine size for card table
        let card_size = mem::page_align(heap_size >> CARD_SIZE_BITS);

        let alloc_size = heap_size + card_size;

        let ptr = arena::reserve(alloc_size).expect("could not reserve memory");
        let ptr = Address::from_ptr(ptr);

{'fraction_non_alphanumeric': 0.11802088061734, 'fraction_numerical': 0.019518837948252384, 'mean_word_length': 3.4525252525252523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5483904', 'n_tokens_mistral': 798, 'n_tokens_neox': 748, 'n_words': 230}