From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id B30A36F3E5; Wed, 10 Nov 2021 15:32:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B30A36F3E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1636547526; bh=f+ZPDMVqMTu56umhhBIRwzsqBlLFtWbDEFjlKJrO2t0=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=vmFTJnT1rIKWEH/Y9+YMSeemvg1PAD/uVpeMDV1SO0cL08+2prV9RBPdiNvai5O0X maP0Cl0U2C/mKdL2Pt61SClSWYMPDN0iqVBIBtDMwlXrt8cYXCgH1IRH/SC+XD7M++ 3EjTHKyQh/W+BhDRUCHARvlsAO5/cglbHu+J93QI= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 593516F3E5 for ; Wed, 10 Nov 2021 15:32:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 593516F3E5 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mkmlm-0004qi-Kv; Wed, 10 Nov 2021 15:32:04 +0300 Date: Wed, 10 Nov 2021 15:31:56 +0300 To: Sergey Kaplun Message-ID: <20211110123156.GG8831@tarantool.org> References: <20211022130225.6076-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211022130225.6076-1-skaplun@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9731B3922EC063979BEDFFADD574E98A41354626144B249C400894C459B0CD1B9C3DC5B72D4F2987F0F70D8032FA06724B9390EB30B4F5A4FF70E9905CEA40A81 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7646B74825E00C605EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374E88016F1B7D8D248638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D823049B882BAE2895439C4C4924A0D07D117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B682BBBAF5DF00056E089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5FE036CD0B8405A4930B604AC49FA23DB3B096E23C8C8EA99D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA753753CEE10E4ED4A7410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348E5EF936B2E46EBA8A02418AAEDC9D2ECE9A3F0F22356222A1CBBBEA6051F63F1952BBFECC36F7491D7E09C32AA3244C4B3EF5197DA9D93F9C0FEA90B96E29FD60759606DA2E136A927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojukdrygDmQ+xkW8bU9lNneg== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D7702007BF24A4D20DA7C24CA7D17336BA7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] tuple: make tuple_bless() compilable X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, I've checked the patch into master and 2.8. On 22.10.21, Sergey Kaplun wrote: > tuple_bless() uses a tail call to ffi.gc() with return to the caller. > This tail call replaces the current (tuple_bless) frame with the frame > of the callee (ffi.gc). When JIT tries to compile return from `ffi.gc()` > to the frame below it aborts the trace recording with the error "NYI: > return to lower frame". > > This patch replaces the tail call with using additional local variable > returned to the caller right after. > --- > > Actually, this patch become possible thanks to Michael Filonenko and his > benchmarks of TDG runs with jit.dump() enabled. After analysis of this > dump we realize that tuple_bless is not compiled. This uncompiled chunk > of code leads to the JIT cancer for all possible workflows that use > tuple_bless() (i.e. tuple:update() and tuple:upsert()). This change is > really trivial, but adds almost x2 improvement of performance for > tuple:update()/upsert() scenario. Hope, that this patch will be a > stimulus for including benchmarks of our forward products like TDG to > routine performance running with the corresponding profilers dumps. > > Benchmarks: > > Before patch: > > Update: > | Tarantool 2.10.0-beta1-90-g31594b427 > | type 'help' for interactive help > | tarantool> local t = {} > | for i = 1, 1e6 do > | table.insert(t, box.tuple.new{'abc', 'def', 'ghi', 'abc'}) > | end > | local clock = require"clock" > | local S = clock.proc() > | for i = 1, 1e6 do t[i]:update{{"=", 3, "xxx"}} end > | return clock.proc() - S; > | --- > | - 4.208298872 > > Upsert: 4.158661731 > > After patch: > > Update: > | Tarantool 2.10.0-beta1-90-g31594b427 > | type 'help' for interactive help > | tarantool> local t = {} > | for i = 1, 1e6 do > | table.insert(t, box.tuple.new{'abc', 'def', 'ghi', 'abc'}) > | end > | local clock = require"clock" > | local S = clock.proc() > | for i = 1, 1e6 do t[i]:update{{"=", 3, "xxx"}} end > | return clock.proc() - S; > | --- > | - 2.357670738 > > Upsert: 2.334134195 > > Branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-noticket-tuple-bless-compile > > src/box/lua/tuple.lua | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > -- > 2.31.0 > -- Best regards, IM