---
 mod/silverbox/box.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/mod/silverbox/box.c b/mod/silverbox/box.c
index 8c7243a..665624c 100644
--- a/mod/silverbox/box.c
+++ b/mod/silverbox/box.c
@@ -62,6 +62,8 @@ const struct field ASTERISK = {
 /* hooks */
 typedef int (*box_hook_t) (struct box_txn * txn);
 
+const int BOX_REF_THRESHOLD = 8196;
+
 struct namespace namespace[256];
 
 struct box_snap_row {
@@ -931,12 +933,18 @@ prepare_update_fields(struct box_txn *txn, struct tbuf 
*data, bool old_format)
 static void
 tuple_add_iov(struct box_txn *txn, struct box_tuple *tuple)
 {
-       tuple_txn_ref(txn, tuple);
+       size_t len;
 
-       add_iov(&tuple->bsize,
-               tuple->bsize +
+       len = tuple->bsize +
                field_sizeof(struct box_tuple, bsize) +
-               field_sizeof(struct box_tuple, cardinality));
+               field_sizeof(struct box_tuple, cardinality);
+
+       if (len > BOX_REF_THRESHOLD) {
+               tuple_txn_ref(txn, tuple);
+               add_iov(&tuple->bsize, len);
+       } else {
+               add_iov_dup(&tuple->bsize, len);
+       }
 }
 
 static int __noinline__
-- 
1.7.3.2


_______________________________________________
Mailing list: https://launchpad.net/~tarantool-developers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~tarantool-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to