Skip to content

Conversation

dweiss
Copy link
Contributor

@dweiss dweiss commented Oct 10, 2025

This builds on top of #15325 so it'll be rebased after that is merged.

LuceneTestCase.random() does have an overhead (needs to loop up randomized context, then returns an asserting Random instance to detect if Random is passed between threads, which shouldn't be done for reproducibility).

This adds two build options to allow detecting mis-use of random() in intense loops. These are low-level settings, not meant to be used for devs in general but useful for detecting such abuse cases.

tests.random.maxacquires      = [empty]  # Max number of per-test calls to LuceneTestCase.random() 
tests.random.maxcalls         = [empty]  # Max number of calls to Randoms returned by LuceneTestCase.random() 
t

I've fixed some of the test cases to be more graceful. I don't see a lot of an impact on my machine but it's an improvement nonetheless.

…alls to the asserting Random returned from LuceneTestCase.random(). Added LuceneTestCase.nonAssertingRandom(Random) to acquire a fast, non-asserting random instance for intense local computation. Modified a bunch of tests that exceeded 1 million calls to random() result.
…s. tests.random.maxacquires will terminate if too many random() calls are called from within a single test. Corrected a few tests where this was the case.
@dweiss dweiss marked this pull request as ready for review October 11, 2025 05:19
Copy link
Contributor

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR.

@dweiss dweiss merged commit 10cb3ee into apache:main Oct 11, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants