Skip to content

Add 2GB-4GB heap testing #10811

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

Merged
merged 20 commits into from
Apr 30, 2020
Merged

Add 2GB-4GB heap testing #10811

merged 20 commits into from
Apr 30, 2020

Conversation

kripken
Copy link
Member

@kripken kripken commented Mar 31, 2020

It's not easy to test this because (1) we need super-new V8, and
(2) this will allocate over 2GB during testing, which strains the bots'
memory limits and risks OOMs. But we should try to have some
testing at least.

This adds new tests in browser. I think in the long term we want
to test this there anyhow, to make sure this works in actual
browsers and not just a shell environment. For now, we still need
to wait for the V8 update to reach chrome beta, so this doesn't
actually run in a browser, but I still put the test in
browser as that suite runs sequentially, which means
no other test will compete for memory with it, reducing OOM
risks. As we expect to convert this to a browser test eventually
this seems not that bad for now (however, if we want non-browser
2GB+ testing, we should probably add a sequential test mode).

The main new test, test_4GB, allocates over 3GB and also
verifies that we can read and write to that memory in both C
and JS.

This also found a minor bug: without 2GB+ heaps we did not
properly error on trying to allocate 2GB, the value actually
overflowed and we entered the wrong code path. The new
test_2GB_fail verifies that is fixed (the fix is by always
>>> 0 the memory size, which also removes an ifdef,
nicely).

@kripken kripken requested a review from sbc100 April 1, 2020 16:19
@kripken kripken self-assigned this Apr 9, 2020
for (int i = 0; i < NUM_CHUNKS; i++) {
printf("alloc %d\n", i);
try {
chunks[i].resize(CHUNK_SIZE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just call emscripten_resize_heap directly with the large value?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Of even you wan to go through the c library, is there any need to reproduce the NUM_CHUNKS/CHUNK_SIZE loop here? Why not just call malloc in a loop?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I just wanted to use normal libc stuff, to get testing close to what users do.

Not sure what you mean by "reproduce" in that sentence? This is basically calling malloc in a loop (just with nicer C++ I think)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Its just looks a lot more complicatled to me than a simple malloc loop. With this test you are also implicatly testing all kind of other things such as the C++ standard library. I know we have a lot of tests like this, but I always have a preference for keeping tests as narrow as possible.

You are also using C++ exceptions which makes that whole thing depend on way more emscripten infrastructure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not saying you have to make this change, just explaining my initial reaction to seeing this code in this test case.

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.

2 participants