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

reduce node lookups in event processing #173

Merged
merged 1 commit into from Nov 27, 2013

Conversation

barmintor
Copy link
Contributor

https://www.pivotaltracker.com/story/show/61411396

Reduce node lookups and stop using long-running sessions for look-ups in event processing

@@ -101,30 +110,42 @@ public void buildListener() throws RepositoryException {
@Override
public void onEvent(final javax.jcr.observation.EventIterator events) {
// keep track of nodes that trigger events to prevent duplicates
final Set<Node> posted = new HashSet<Node>();
// size to minimize resizing.
final Set<String> posted = new HashSet<String>((int)events.getSize() * 2 / 3);
Copy link

Choose a reason for hiding this comment

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

What is the rationale for sizing the Set to: (events.size * 2 / 3)? versus some other value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at an initial capacity of 2/3 max, and a load factor of 0.75, this should mean at most one resize of the set. We could size it accurately and set the load to 1, but my understanding is that performance is worse, and if we ignore some nodes we'l have slack anyway. Still, maybe not worth doing anything but setting the size to Math.min(16, (int)events.size())

Copy link

Choose a reason for hiding this comment

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

I trust your research and judgement in deciding between 2/3 or min(16). Thanks for providing the explanation.

@awoods
Copy link

awoods commented Nov 26, 2013

Some minor comments, but otherwise looks good.

awoods pushed a commit that referenced this pull request Nov 27, 2013
@awoods awoods merged commit b6c6c35 into fcrepo:master Nov 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants