This is an archive of the discontinued LLVM Phabricator instance.

[llvm-exegesis] Make SubprocessMemoryTest use PIDs
AbandonedPublic

Authored by aidengrossman on Jul 6 2023, 9:09 PM.

Details

Summary

This patch makes SubprocessMemoryTest use process PIDs during creation of the SubprocessMemory objects within the tests so that there isn't interference between multiple instances of the test running at the same time which could potentially occur in multi-user environments.

Diff Detail

Event Timeline

aidengrossman created this revision.Jul 6 2023, 9:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 9:09 PM
Herald added a subscriber: mstojanovic. · View Herald Transcript
aidengrossman requested review of this revision.Jul 6 2023, 9:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 9:09 PM

Remove unnecessary headers and debug statements.

This patch is ready when reviewers have a chance. Thanks!

bjope added inline comments.Jul 31 2023, 1:46 PM
llvm/unittests/tools/llvm-exegesis/X86/SubprocessMemoryTest.cpp
42

Multiplying a pid with a number seems a bit weird to me. It is not really guaranteed to result in a number unique to the process (pid=1 and TestNumber=2 gives the same value as pid=2 and TestNumber=1). And I don't know if this multiplication potentially could overflow as well.

bjope added inline comments.Sep 1 2023, 7:43 AM
llvm/unittests/tools/llvm-exegesis/X86/SubprocessMemoryTest.cpp
42

Any news about this? Do you agree that the multiplication is weird?

aidengrossman added inline comments.Sep 1 2023, 12:49 PM
llvm/unittests/tools/llvm-exegesis/X86/SubprocessMemoryTest.cpp
42

Sorry for the delay. Planning on working on this over the weekend. I do agree that multiplication is weird the way I have it implemented here. However, I do think it's the most elegant solution available without changing the library code just to expose more testing hooks. I think doing 2D array indexing should work. We can do getpid() * NumberOfTests + TestNumber which should make everything unique and also won't overflow on 32 bit arithmetic as PIDs are limited to 2^22.