Skip to content

Fix parallel tests execution, fix potential collisions, cache only regexes #2092

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 2 commits into from
Feb 11, 2020

Conversation

Inok
Copy link
Contributor

@Inok Inok commented Feb 11, 2020

Let me explain all these changes:

  1. I replaced the static Dictionary with ConcurrentDictionary since its content could be updated by multiple threads. Looks like it is not happening in real scenarios, but the Dictionary breaks almost every time I run unit tests because of [assembly: Parallelizable(ParallelScope.Fixtures)]. The more CPU cores you have, the more chances to break the Dictionary.

  2. Previous approach to cache something by the GetHashCode() value is wrong because of possible collisions. The more commits you have - the more chances to face a collision (for example, "fix foo +semver:major" and "my commit +semver:patch" messages potentially could have the same hash code, and if it so, the result will depend on the order of this commits in history).

  3. Looks like there is no reason to cache increments by commit message text. I believe that it's unusual to have a lot of commits with the same name in real world scenarios. Besides, when the repo has a lot of commits, there will be a huge memory footprint.

  4. Bump messages are likely to stay default, so it's reasonable to turn default patterns to static compiled regexes, and also compile and cache custom regexes.

  5. I also copy reference to intermediateCommitCache to the local variable before use it because of possible issues with multithreading.

@asbjornu
Copy link
Member

The changes look good, but there's a few tests that fail for some reason. I don't quite understand why, but can you please look into it?

@arturcic
Copy link
Member

The changes look good, but there's a few tests that fail for some reason. I don't quite understand why, but can you please look into it?

The tests were failing starting with last week, I have enabled back the testing, and it start failing on linux again.

We can disable for now till I figure out the reason and continue merging the changes. What do you think @asbjornu ?

@asbjornu
Copy link
Member

Sounds good to me, @arturcic.

@arturcic arturcic requested a review from asbjornu February 11, 2020 09:30
@arturcic arturcic added this to the 5.1.4 milestone Feb 11, 2020
@arturcic
Copy link
Member

@asbjornu the build succeeds now, you can continue with the review/merge

@asbjornu asbjornu merged commit 2b15375 into GitTools:master Feb 11, 2020
@asbjornu
Copy link
Member

Thanks for your contributions, @Inok! 🙏

@Inok Inok deleted the fix/parallel-tests-failures branch May 30, 2020 18:23
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.

3 participants