Optional yieldIfContendedSafely() on bulkInsert #54
Conversation
Add the useage to the demo module |
I more imagined you would create a new page in the demo that does a yield. Then you can write why you are using yield in that scenario. Not just change the other demo's :-( |
@@ -23,10 +24,14 @@ public void bulkSaveDataToFireworksTable(ContentValues[] values) { | |||
} | |||
|
|||
private void bulkSaveDataToTable(String table, ContentValues[] values) { | |||
Uri uri = createUri(table); | |||
Uri uri = createUriWithoutYieldFor(table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wohoo 👍
All right, I'll provide an example with both yield and without it in order to compare the multithreaded bulkInsert in terms of duration 👍 |
👍 when I said "write what it means" I meant in a textview in the demo, so the peeps using it can read it there n then |
@blundell added an example in the sample module where the difference between yield and not yield can be clearly seen. |
nice i assume the edittexts have hints to know which is which |
Optional yieldIfContendedSafely() on bulkInsert
@blundell yep |
Firework firework = data.get(0); | ||
return TextUtils.replace( | ||
DatabaseConstants.RawSql.BULK_INSERT_FIREWORKS, | ||
new String[]{"Times", "Na", "Co", "No", "Ft", "Pr", "Sh"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your input data offends me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really input data, there are just placeholders to be replaced with the computed sql for the users of the demo to see what sql has been executed. Just following the other screens examples 👅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other demo's are amazing soooo 👍
Allowing to specify an optional query parameter for allowing or not
yieldIfContendedSafely()
during bulk inserts.The reasoning behind not wanting the yield is that in case of parallel multithreaded bulkInserts the yield will case ending and starting new transactions and thread context switching in turn causing performance issues.
In order to keep backwards compatibility and for a more flexible API, we didn't removed the yield completely, but rather let the user choose. By default, the bulkInsert will yield.
Notice the major increase of performance when not using yield: