Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add GC #88

Merged
merged 8 commits into from
Aug 20, 2023
Merged

feat: add GC #88

merged 8 commits into from
Aug 20, 2023

Conversation

myuon
Copy link
Owner

@myuon myuon commented Aug 19, 2023

No description provided.

@myuon myuon changed the title refactor: code for 1.9.0 feat: enable GC Aug 20, 2023
@myuon myuon changed the title feat: enable GC feat: add GC Aug 20, 2023
@myuon
Copy link
Owner Author

myuon commented Aug 20, 2023

nogc

	Command being timed: "just check_if_stable --validate-address"
	User time (seconds): 15.07
	System time (seconds): 1.22
	Percent of CPU this job got: 117%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:13.85
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 871072
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 50
	Minor (reclaiming a frame) page faults: 737871
	Voluntary context switches: 30
	Involuntary context switches: 7047
	Swaps: 0
	File system inputs: 0
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0

gc

	Command being timed: "just check_if_stable --validate-address"
	User time (seconds): 18.49
	System time (seconds): 1.30
	Percent of CPU this job got: 113%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:17.42
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 935300
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 50
	Minor (reclaiming a frame) page faults: 790342
	Voluntary context switches: 45
	Involuntary context switches: 7559
	Swaps: 0
	File system inputs: 0
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0

gc performed 2 times (1.75sec/gc), gc/500,000allocs

@myuon
Copy link
Owner Author

myuon commented Aug 20, 2023

Example

fun write_to(fd_n: i32, content: string) {
    let ciovec = make[ptr[byte]](8);
    set_ciovec(ciovec, content.data, content.length);

    let ptr_size = make[ptr[i32]](1);
    let err = _fd_write(fd_n, ciovec, ptr_size);
    if err != 0 {
        panic("[file_write] fd_write {}", err.to_string());
    }
}

fun repeat(n: i32, content: string): string {
    let builder = stringbuilder::new();
    for i in 0..n {
        builder.append(content);
    }

    return builder.to_string();
}

fun main() {
    let fd_n = file_open("new.out", 9, 1 << 6);

    for i in 0..1000000 {
        write_to(fd_n, repeat(100, i.to_string()));
        write_to(fd_n, "\n");
    }

    file_close(fd_n);
}

@myuon myuon merged commit 4b4a076 into main Aug 20, 2023
1 check passed
@myuon myuon deleted the gc branch August 20, 2023 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant