Skip to content

Conversation

@saschanaz
Copy link
Collaborator

@saschanaz saschanaz commented Jan 28, 2018

Fixes #5817, fixes #6130

Tried implementing what @juj suggested:

I think the solution forward here might be to assign unique/dedicated temp directories to each parallel test runner process in core and other? That is, for each parallel test runner thread, append a unique subdirectory path to EMCC_TEMP_DIR for each of them, so that they all operate in unique directories? Then the leak checker could also be enabled for the core suite.

Edit: other now only takes 16 minutes on CircleCI (while ~40 minutes on Travis)!

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Overall I like the result here, but I'm a little confused on how this changes the status of the temp dirs, what the meaning of the canonical one is, and where that is set.

environment:
- TEST_TARGET=other.test_n* other.test_o* other.test_p* other.test_q* other.test_r* other.test_s* other.test_t* other.test_u* other.test_v* other.test_w* other.test_x* other.test_y* other.test_z* skip:other.test_native_link_error_message
# TODO: remove skips after fastcomp update on travis for 1.37.23
- TEST_TARGET=other skip:other.test_bad_triple skip:other.test_native_link_error_message skip:other.test_emcc_v skip:other.test_failing_alloc
Copy link
Member

Choose a reason for hiding this comment

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

why is emcc_v skipped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It has been skipped since its birth because it tends to fail whenever an SDK version update happens: #5883

os.makedirs(temp_root)
temp_dir = tempfile.mkdtemp(dir=temp_root)
temp_root = shared.TEMP_DIR
if not os.path.exists(temp_root):
Copy link
Member

Choose a reason for hiding this comment

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

creating shared.TEMP_DIR could be done in shared, I think? seems cleaner that way, unless I'm missing something, and we don't want shared to always create it?

Copy link
Collaborator Author

@saschanaz saschanaz Jan 30, 2018

Choose a reason for hiding this comment

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

Some tools including test runners, emar, emconfigure, etc. also imports shared, we probably don't want to create and remove empty directory for those tools.

Copy link
Member

Choose a reason for hiding this comment

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

Good point, yes.


def clean_emcc_files_in_temp_dir(self):
for x in os.listdir(CANONICAL_TEMP_DIR):
for x in os.listdir(self.canonical_temp_dir):
Copy link
Member

Choose a reason for hiding this comment

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

self.canonical_temp_dir is defined as a function in runner.py, but used as a string here?

Copy link
Collaborator Author

@saschanaz saschanaz Jan 30, 2018

Choose a reason for hiding this comment

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

Ah, the class clean_write_access_to_canonical_temp_dir has its own string field canonical_temp_dir.


def test_emcc_debug_files(self):
if os.environ.get('EMCC_DEBUG'): return self.skip('cannot run in debug mode')
canonical_temp_dir = self.canonical_temp_dir()
Copy link
Member

Choose a reason for hiding this comment

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

this seems confusing. do we need a function there, can't it always be a string?

but a larger question, why is the test runner in charge of declaring the canonical temp dir? shouldn't shared.py do that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, it can be a string. I'll fix it.

This PR dynamically assigns temporary directory path for each test runner thread so that each thread won't get any conflict when writing files in its canonical temp directory. This is not needed for normal emcc use, and shared.py is not related to parallel tests, so this is done in test runners.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I'm not sure, but I think we can get that benefit (each test is independent) by cleaning up the shared.py temp dir code, and using EMCC_TEMP_DIR or one of those. That seems better as the cleanup would be good by itself, and we wouldn't need any new code in the test harness for it.

As I said I'm not sure it can work, and it's a different approach than this PR, so I'd understand if you're not interested to investigate it, I could do that.

tests/runner.py Outdated
return ('-O2' in self.emcc_args or '-O3' in self.emcc_args or '-Oz' in self.emcc_args) and not (Settings.SIDE_MODULE or Settings.BINARYEN)

def canonical_temp_dir(self):
return os.path.join(self.temp_dir, 'emscripten_temp')
Copy link
Member

Choose a reason for hiding this comment

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

we still have logic in shared.py that uses that string "emscripten_temp", can we share that code so it's not duplicated?

@kripken
Copy link
Member

kripken commented Jan 30, 2018

Ok, this looks good to me. I think we could probably simplify the test code some more (but I'm not sure - I might look into it if I have time), but my bigger concerns before were with the non-test code, and all that looks great.

@kripken kripken merged commit 4594b09 into emscripten-core:incoming Jan 30, 2018
@saschanaz saschanaz deleted the other-parallel2 branch January 30, 2018 23:44
@kripken
Copy link
Member

kripken commented Feb 16, 2018

@saschanaz Very strange, when I run other.test_os_oz now on incoming, I get

======================================================================
ERROR: test_os_oz (test_other.other)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/alon/Dev/emscripten/tests/test_other.py", line 3288, in test_os_oz
    with clean_write_access_to_canonical_temp_dir(self.canonical_temp_dir):
AttributeError: 'other' object has no attribute 'canonical_temp_dir'

----------------------------------------------------------------------
Ran 1 test in 0.022s

FAILED (errors=1)

Bisection lead me to here, but it's odd we didn't notice this breakage before. Any ideas?

sbc100 added a commit to sbc100/emscripten that referenced this pull request Oct 21, 2025
It should be fine for all parallel tests to using the same TEMP_DIR.

The only limitation is on tests that use the canonical test directory
(e.g. EMCC_DEBUG).

It looks like we used to use a unique temp directory per process (See emscripten-core#6150).
However that we changes to one-directory-per-test in emscripten-core#18214, although
I don't remember why.

With this change we don't create a new temp directory except for tests
that are marked as `uses_canonical_tmp`
sbc100 added a commit to sbc100/emscripten that referenced this pull request Oct 21, 2025
It should be fine for all parallel tests to using the same TEMP_DIR.

The only limitation is on tests that use the canonical test directory
(e.g. EMCC_DEBUG).

It looks like we used to use a unique temp directory per process (See emscripten-core#6150).
However that we changes to one-directory-per-test in emscripten-core#18214, although
I don't remember why.

With this change we don't create a new temp directory except for tests
that are marked as `uses_canonical_tmp`
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.

more tests should run in parallel Parallel other tests

2 participants