Add normalize_test_id/test_id_normalizer= to configuration#402
Open
bitwise-aiden wants to merge 1 commit intomainfrom
Open
Add normalize_test_id/test_id_normalizer= to configuration#402bitwise-aiden wants to merge 1 commit intomainfrom
bitwise-aiden wants to merge 1 commit intomainfrom
Conversation
e546336 to
eb2d004
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
test_id_normalizer=setter toCI::Queue::Configurationthat allows callers to provide a custom normalization function for test IDs. This ensuresflaky?lookups work correctly even when test ID formats differ between the flaky tests list and runtime test IDs.Accepts both
UnboundMethodandMethodobjects — the setter convertsMethodto aProcautomatically so singleton methods from other modules work without binding issues.Performance
Since
flaky?is called for every test in CI (potentially hundreds of thousands of times), we benchmarked the dispatch overhead of different implementation strategies.Setup
Setid -> id) to isolate pure dispatch overhead from any real normalization workResults
define_singleton_method(no normalizer)define_singleton_method(UnboundMethod)define_singleton_method(Method.to_proc)bind_callAnalysis
We chose
define_singleton_methodbecause:UnboundMethodnormalizer, performance is identical to not having one set at all (both ~1.30x vs baseline) -- the only cost is the extranormalize_test_idmethod call itself.Methodnormalizer (converted viato_proc), there's a small additional overhead (1.84x vs baseline) due to the proc indirection -- but this is still 2-3x faster than the ivar-based alternatives.bind_call, proc) are 4-5x slower because they pay dynamic dispatch costs on every single invocation.For best performance, callers should prefer passing an
UnboundMethod. Passing aMethodis supported for ergonomics with a modest overhead.Usage
Without a normalizer,
flaky?uses exact string matching (identity function):The normalizer is applied to both the stored flaky test IDs and the incoming test ID at lookup time, so mismatches in formatting are resolved regardless of which side has the canonical form:
Changes
ruby/lib/ci/queue/configuration.rb-- Addedtest_id_normalizer=,normalize_test_id, andlazy_normalized_flaky_tests; updatedflaky?to normalize both sidesruby/test/ci/queue/configuration_test.rb-- Added tests forflaky?with and without a normalizer, includingMethodinput