Skip to content
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

Use concurrent sets or queues #3570

Merged
merged 1 commit into from Sep 12, 2020

Conversation

jelovirt
Copy link
Member

@jelovirt jelovirt commented Sep 3, 2020

Description

Use concurrent sets and queues where applicable.

Motivation and Context

Contains operations are faster on a dedicated set implementation.

How Has This Been Tested?

Tests pass.

Type of Changes

  • New feature (non-breaking change which adds functionality)

Documentation and Compatibility

None needed

@jelovirt jelovirt added the enhancement Changes to an existing feature label Sep 3, 2020
@jelovirt jelovirt self-assigned this Sep 3, 2020
@jelovirt jelovirt added this to In progress in Next via automation Sep 3, 2020
@jelovirt jelovirt moved this from In progress to Review in progress in Next Sep 3, 2020
Copy link
Member

@raducoravu raducoravu left a comment

Choose a reason for hiding this comment

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

There is still probably a performance problem with waitList.contains() as it’s still a queue, can’t we use some kind of linkedhashset instead and always remove first item from it?

@jelovirt
Copy link
Member Author

jelovirt commented Sep 3, 2020

Using waitList = new ConcurrentLinkedQueue<>(); may not be a good idea after all.

The waitList doesn't have to be a queue, but we need some way of removing and getting some value out of the set. We could just use LinkedHashSet, but it's just a Set, so there's no remove() or pop() method.

@raducoravu
Copy link
Member

On my side after replacing Queue with LinkedHashSet I used something like:

	while(! waitList.isEmpty()) {
		Reference ref = waitList.iterator().next();
		waitList.remove(ref);
		processFile(ref);
	}

I could not iterate over the waitList and remove at the same time because "processFile" influenced the set while I was iterating through it.

@jelovirt
Copy link
Member Author

jelovirt commented Sep 4, 2020

Maybe we could use ConcurrentSkipListMap 🤔

@raducoravu
Copy link
Member

raducoravu commented Sep 4, 2020

@jelovirt I'm not sure how many automatic tests for performance has the DITA OT, in this case such a test could be created to populate the sets in GenMapAndTopicListModule with lots of data and then to use the access methods and see how fast they return.. then you could switch implementations inside the class and see if you notice any improvement.

Signed-off-by: Jarno Elovirta <jarno@elovirta.com>
@jelovirt jelovirt force-pushed the feature/processing-queue-implementation branch from 66d1733 to cc115ba Compare September 5, 2020 07:52
Copy link
Member

@raducoravu raducoravu left a comment

Choose a reason for hiding this comment

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

Looks ok, I will try next week the changes with the large project.

Next automation moved this from Review in progress to Reviewer approved Sep 5, 2020
@jelovirt
Copy link
Member Author

jelovirt commented Sep 5, 2020

@raducoravu What do you think about this? Are you able to run the same benchmark again?

@raducoravu
Copy link
Member

@jelovirt I will run the processing on Monday and report back.

@raducoravu
Copy link
Member

@jelovirt I can confirm the latest fix no longer produces the CPU usage problems I noticed with the original code in GenMapAndTopicListModule. I profiled both with the fix (and the problem was no longer noticed) and without the fix (and the problem with the queue.contains() was noticed in the profiler)

@jelovirt jelovirt merged commit f7f7e3e into develop Sep 12, 2020
Next automation moved this from Reviewer approved to Done Sep 12, 2020
@jelovirt jelovirt deleted the feature/processing-queue-implementation branch September 12, 2020 04:51
@jelovirt jelovirt added this to the Next milestone Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes to an existing feature
Projects
No open projects
Next
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants