Today we use a sliced lock strategy for acquiring locks to prevent
concurrent updates to the same document. The number of sliced locks is
computed as a linear function of the number of logical
processors. Unfortunately, the probability of a collision against a
sliced lock is prone to the birthday problem and grows faster than
expected. In fact, the mathematics works out such that for a fixed
target probability of collision, the number of lock slices should grow
like the square of the number of logical processors. This is
less-than-ideal, and we can do better anyway. This commit introduces a
strategy for avoiding lock contention within the internal
engine. Ideally, we would only have lock contention if there were
concurrent updates to the same document. We can get close to this ideal
world by associating a lock with the ID of each document. This
association can be held in a concurrent hash map. Now, the JDK
ConcurrentHashMap also uses a sliced lock internally, but it has several
strategies for avoiding taking the locks and these locks are only held
for a very short period of time. This implementation associates a
reference count with the lock that is associated with a document ID and
automatically removes the document ID from the concurrent hash map when
the reference count reaches zero.
Relates elastic#18060
ProTip!
Use n and p to navigate between commits in a pull request.
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.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more
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
Sync loggly fork with current master #2
Sync loggly fork with current master #2
Changes from 1 commit
99aad3d22dc06f1a321febe239b834b583910f9df3946c7e4cb29e04a0ba3c96302fb672fb93e0cf1d166c3beaac25f8ad04bd55d2636703713c0df6c7a44cbaceabd2232a7c8c7739937382ecf349c4f07c2fbf7aca138a31b94ee322903b2ce2f5262a814c82e5640b41580cf1d0d59162fd27c8397d4cf53859fee8c728409e4372eceb8e178c48bdda49226679c15f33e616c4c250c6d6a5693c1f6fff82db0eed5cf0a6f40c98dba261385e25d01526b85d2fc03ca02d6564825321e94e68397328ca21aa0929187cd63362c8bdd31980dbe3151a53c5a8bf759ad8bf536b9ac469a90bdc6f15f35ffcb1323bc926b283a6d2247b5c82dea4499fe5ce9052191f78d615f52eb6f3c4554fe8d3427b223d67dfad07055a0cfdd34d90b04c6cf7e7656d7e124e8e567c0734230697ce49d21b07d8b3e784c9e58fc513821d716f928e2b959c135b66e8529e11b96c2cae5754b1c1163912761c4090a18ff699ee3ce6c9f3b2ab82d2b2320f778c9f1fb6a3443976d1199cd8e16af607d87087c55df19de8354db91df364ddf9167d14728e88ac1193567a2d3c5f867b69e4eb12a423b6698c3e839dade90d00fcb40b98d52537d473be01f270ed2ddebbb9901c25b0ff56521d5b9f10eaa8315be79ed3d1be072c3d3d99988105d0d2d2bc1afcb5c740feb10e3b37a78cdcd4ae5c0db352a90000dd623a468120f36c7425289343f59408ef2e3a88c52e883f3fa59b7d02fb7d1fd1752cdac46094704aef78ce214ce31ded91d5ddc531e0970c595b6f9abe54c24dfdae97aeed5b0b5a7edf9ba2fe155d8f68468e7ac4f481492b6556e27bf8e6717225d93aeb66802cf4298972f392e613f4b6a149193d1b38243c9e7667a091557fc8b319ca821c54033a45e1cc0660386546aed87a47d33ad5ce59eb1b2cf81c0b7b1c2d3b106a4f647753420a0ffe6ee8ddf5def6a7631dfbe8b531dcbfddc2c1f1d80542a63285a2bf585e5f0cc795644f49abb015b389ef46632bb4c2e4f87dd8b373c30b5b4f9d12f7b7689a1afe05ee86d288deae01a4f97a41eed0edd13e4edee5866a545d790c7680bb46b2764b47ce4af4b5189eb420af482fced8da189341d6b4e47bc5532d38adfd603b66d4025dd642d3142e3930a2158871fdd113e2399fbbd7328164cc9d5537d9ce96f55ee5cc294317b10830bd42e258379b2b474ec4825ddf4323010381de8155e1ef9667dbFile filter...
Jump to…
Avoid sliced locked contention in internal engine