[JAVA-3328] Excessive memory allocation due to unwrapping of updates in bulk ops Created: 18/Jun/19 Updated: 28/Oct/23 Resolved: 24/Jul/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Write Operations |
| Affects Version/s: | 3.6.0, 3.7.0, 3.8.0, 3.9.0, 3.10.0 |
| Fix Version/s: | 3.11.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Oleg Rekutin | Assignee: | Jeffrey Yemin |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Backwards Compatibility: | Fully Compatible |
| Description |
|
It looks like the changes inĀ 332ffc78538b36db880c94836d82276f5e5d9296 introduced a call to isEmpty() on the update document, to throw an illegal arg exception if the update document is empty. However, when used with BsonDocumentWrapper, the call to isEmpty() causes the wrapped document to be unwrapped, just to check for emptiness. This causes many unnecessary allocations when unwrapping update documents of any size. Removing this call saves about approx ~80% GC'd allocations for a comparable volume of writes, as illustrated in the attached screenshot comparing two JProfiler snapshots. On the left is the version w/o the check, on the right is the current code w/ the check. |
| Comments |
| Comment by Githook User [ 01/Aug/19 ] |
|
Author: {'name': 'Jeff Yemin', 'email': 'jeff.yemin@10gen.com', 'username': 'jyemin'}Message: Optimize check for an empty update document The CRUD specification requires that an update contains at least one The current method of checking for an empty document is to call This also fixes a bug in which that check was done for both update and Thanks to @astral303 for finding this issue and for opening an initial
|
| Comment by Githook User [ 01/Aug/19 ] |
|
Author: {'name': 'Jeff Yemin', 'email': 'jeff.yemin@10gen.com', 'username': 'jyemin'}Message: Introduce BsonWriterDecorator superclass
|
| Comment by Githook User [ 24/Jul/19 ] |
|
Author: {'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}Message: Optimize check for an empty update document The CRUD specification requires that an update contains at least one The current method of checking for an empty document is to call This also fixes a bug in which that check was done for both update and Thanks to @astral303 for finding this issue and for opening an initial
|
| Comment by Githook User [ 24/Jul/19 ] |
|
Author: {'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}Message: Introduce BsonWriterDecorator superclass
|
| Comment by Oleg Rekutin [ 18/Jun/19 ] |
|
Added pull request and a benchmark you can run yourself w/ memory allocation profiling. |