From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 27 Aug 2018 12:26:57 +0300 From: Alexander Turenko Subject: Re: [PATCH 1/3] socket: evaluate buffer size in recv / recvfrom Message-ID: <20180827092657.vcefaeac4xcg6zo4@tkn_work_nb> References: <36b23f07009f3cd467c1eb7e54e982b1f907908d.1535076888.git.alexander.turenko@tarantool.org> <20180824152542.54jf6fs5rm372bh6@esperanza> <20180827000848.cmtlbxrrbub5svn6@tkn_work_nb> <20180827092059.fa2mzesvn4jcvqnu@esperanza> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180827092059.fa2mzesvn4jcvqnu@esperanza> To: Vladimir Davydov Cc: tarantool-patches@freelists.org List-ID: On Mon, Aug 27, 2018 at 12:20:59PM +0300, Vladimir Davydov wrote: > On Mon, Aug 27, 2018 at 03:08:49AM +0300, Alexander Turenko wrote: > > On Fri, Aug 24, 2018 at 06:25:42PM +0300, Vladimir Davydov wrote: > > > On Fri, Aug 24, 2018 at 05:47:37AM +0300, Alexander Turenko wrote: > > > > diff --git a/src/lua/socket.lua b/src/lua/socket.lua > > > > index 06306eae2..946e11e9e 100644 > > > > --- a/src/lua/socket.lua > > > > +++ b/src/lua/socket.lua > > > > @@ -770,6 +770,41 @@ local function socket_send(self, octets, flags) > > > > return tonumber(res) > > > > end > > > > > > > > +local function socket_is_udp(self) > > > > + local fd = check_socket(self) > > > > + if self.itype == nil then > > > > + self.itype = self:getsockopt('SOL_SOCKET', 'SO_TYPE') > > > > > > I think you could instead set itype in socket constructor. > > > > > > > That will increase memory consumption in case when it is not needed to > > know itype: say, for sending sockets (I should add comment about this, > > of course). However I think it is worth to cache it when revc / recvfrom > > is used intensively to avoid extra syscall. > > > > Do you think we can ignore extra memory comsumption in this case? > > How much of memory overhead is it going to be? Several bytes per socket? > IMHO we can ignore it. 8 bytes (numbers in lua are doubles). Ok, I'll proceed. WBR, Alexander Turenko.