<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 31 Oct 2018, at 12:18, Vladislav Shpilevoy <<a href="mailto:v.shpilevoy@tarantool.org" class="">v.shpilevoy@tarantool.org</a>> wrote:</div><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On 31/10/2018 02:08, n.pettik wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">But SQL wants to use some transactional data after commit. It is<br class="">autogenerated identifiers - a list of sequence values generated<br class="">for autoincrement columns and explicit sequence:next() calls.<br class=""><br class="">It is possible to store the list on malloced mem inside Vdbe, but<br class="">it complicates deallocation.<br class=""></blockquote>What is the problem with deallocation? AFAIU it is enough to<br class="">simply iterate over the list and release each element - not big deal.<br class="">If you want to use region, mb it is worth to store separate region<br class="">specially for VDBE? We already have it in parser, so what prevents<br class="">us for adding the same thing to VDBE? I guess we can store many<br class="">things there, not only list of ids. I understand that parser in its turn<br class="">has nothing in common (at least it should, except for analyze machinery)<br class="">with transaction routines, so separate region is likely to be more<br class="">reasonable for parser, but anyway...<br class=""></blockquote><br class="">I've decided to say more details. Parser never yields. This is why we can<br class="">waste here any resources, rack and ruin everything, but at the end of<br class="">parsing it should be returned back.<br class=""><br class="">Vdbe, on the contrary, yields. So it holds some system resources while<br class="">other fibers can not use them. If we added a special region to Vdbe, it<br class="">would steal slabs from the thread's slab cache, while other fibers may<br class="">want to use it. Hence, when we use one region for all transactional data,<br class="">including language specific, allocations are much less fragmented over<br class="">different slabs.<br class=""><br class="">Is this explanation decent?<br class=""></blockquote>Quite. I thought that used slabs are marked somehow so that different<br class="">fibers’ regions can’t rely on the same chunk. Probably, I misunderstood<br class="">how internals of our allocation system work. I would better ask you f2f<br class="">someday (or read again Konstantin’s article). Anyway, thanks.<br class=""><blockquote type="cite" class=""><br class="">Also, I do not agree, that 'deallocation is just iteration and it is<br class="">ok'. It is O(n) iteration and freeing of heap objects. If a one inserted<br class="">10k rows with autogenerated ids, it would waste 10k heap fragments,<br class="">10k calls of malloc/free - in my opinion it is an abysmal overhead, but<br class="">what is more, it can be avoided for free. Instead of 10k free() it boils<br class="">down to deallocation of N slabs, where N = slab_size / (10k * 8); 8 - size<br class="">of autogenerated it; slab size is at least 64Kb, so N = 64*<a href="tel:1024/80000" class="">1024/80000</a><span class="Apple-converted-space"> </span><<a href="tel:1024/80000" class="">tel:1024/80000</a>>< 1.<br class="">It takes 1 deallocation vs 10k deallocations. So I think this refactoring<br class="">is worth.<br class=""></blockquote>Very impressive calculations, however:<br class="">a. I doubt that smb extensively uses queries like<br class="">INSERT INTO t VALUES (NULL, ..), *10k repeats*, (NULL, ..)’<br class="">*Ok, neither I nor you know which queries users execute (or will execute),<br class=""> but anyway your example looks too synthetic.*<br class="">b. Nothing prevents us from counting number of NULLs right in parser<br class="">and allocate memory as single array (one malloc). In this case it would<br class="">be more efficient, I guess, since you don’t need that machinery connected<br class="">with linked list. Btw, why didn’t you consider this variant?<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">INSERT INTO ... SELECT FROM ...;</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Here you can not calculate. Also, it is not possible to calculate</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">autoids from triggers, box Lua functions. So a list is the only</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">variant.</span></div></blockquote><br class=""></div><div>Ok, now I see. Then patch LGTM.</div><br class=""></body></html>