Skip to content

vgc: improve, big step forward#27855

Open
tankf33der wants to merge 1 commit into
vlang:masterfrom
tankf33der:vgc_huge
Open

vgc: improve, big step forward#27855
tankf33der wants to merge 1 commit into
vlang:masterfrom
tankf33der:vgc_huge

Conversation

@tankf33der

Copy link
Copy Markdown
Contributor

Fixes #27830

Despite the fact that this patch contains many changes, it has to be done as a single chunk; this courageous decision has to be made :(.

In addition to fixing the bug that the user found, vgc will now start passing the tests from vlib/ (i am so happy), and in the future it will be easier to make commits when you know that you haven't broken anything.

The patch contains previous findings and knowledge that were made as soon as vgc appeared in April of this year.

Highlights:

  • Fixes 27830
  • start passing all tests for the first time - v -gc vgc test vlib/[a-c,m]*
  • v run bench/bench_gc.v uses less memory than boehm

@medvednikov

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6279ff0ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +390 to +394
if npages >= 32 {
// Large span: keep on the dedicated list, matched by exact page count.
unsafe {
span.next = vgc_heap.free_large
vgc_heap.free_large = span

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recommit decommitted large spans before reuse

On Windows, vgc_os_decommit() is implemented with VirtualFree(..., MEM_DECOMMIT), so adding large spans to free_large after this call makes vgc_get_free_span() later return an uncommitted address for the next exact-sized large allocation. That path immediately writes to the span (for example via memset in vgc_alloc_large()), which will fault on Windows for large objects that survive to a sweep and are then reused; POSIX MADV_DONTNEED does not have the same requirement.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a short break for now to check the patch and the new fix for Windows on Windows 11.

I got curious to try out how it would crash :)

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.

segmentation fault with the compiler flags -gc vgc

2 participants