From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id 075A93B29E for ; Wed, 12 Apr 2017 08:48:51 -0400 (EDT) Received: by mail-wm0-x241.google.com with SMTP id x75so6203415wma.1 for ; Wed, 12 Apr 2017 05:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:cc:date:message-id:in-reply-to:references:reply-to :user-agent:mime-version:content-transfer-encoding; bh=oPSOCO9fD/dbV55ZFmZEo5NF4NGtTs72LsJH3qgj9oI=; b=eLJ/JUBBYK6jn52yEyNM2yT+GwRMyx081x1kILN/d1P0xvkDXUY7w3ZuzKmtTNl9W/ aQEhSPD8CXPCwdbJnbgdjG0vaPauWM+vjeJMB9cdm4LoTtsCTdnKb/cDLnzRDOgNFeP0 ABIed59uV0psWG2IQYrOAtdkULtTDA9uKTRHOul1wAnm6t3NaXLNSvBm8CGQN0Ch5IOM t5xdq8t7s+2ME7gnvtGlKpPnxzcWf6q5YDag9vpnpMA2Zw8/nqQUD8MiR+GTpXirAH2o 6BK7tXs232Qdpa7XbuiMZvJ2BSzIsirbVz9ywfoD1zgjTbJtSnBLCipplUH7NwH1ecWC qlLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:cc:date:message-id:in-reply-to :references:reply-to:user-agent:mime-version :content-transfer-encoding; bh=oPSOCO9fD/dbV55ZFmZEo5NF4NGtTs72LsJH3qgj9oI=; b=PWoNVlskY1ND/4RZzWKjmv8wbxpoaU5v5EQDtLdZEEHcsOWOsIVauof4MMIRgiYhmc 6AvRN6g2wZ5vp+/QP57J8C6ne2+PsAvtcoSrbG1f7V8QZ8SAjwWTfF+1qDs29hBudcAf VvFeKr6AyFCgres6PKsH4GdrXA1eQocz1eopZFxoa0gwjEiv5kGKtl3uqPTkhNaht/mj 9t6BzgIgzriMjKftByquM+GqRbK9tOrxzQz9qBVWp5oQkXyfZyRNpzxMKHHhnkCHkbW6 NTq2xnQnMpjc2tkjpCnf9eWvQv4KKgEVqHEuARv65A3lRL6Q+hZonfAH3eDsJlO/BwOI mGdg== X-Gm-Message-State: AN3rC/7jz5OV7DrAWao8hYdoN8MMRB746jQOd/1P+ceRh0eHGn8tjM4S0084iOpb73Pz2A== X-Received: by 10.28.143.135 with SMTP id r129mr2642492wmd.54.1492001331074; Wed, 12 Apr 2017 05:48:51 -0700 (PDT) Received: from [192.168.1.116] (cm149-53.liwest.at. [81.10.149.53]) by smtp.gmail.com with ESMTPSA id x1sm25400157wrd.63.2017.04.12.05.48.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Apr 2017 05:48:50 -0700 (PDT) From: xnor To: "Kevin Darbyshire-Bryant" , "George Amanakis" Cc: cake@lists.bufferbloat.net Date: Wed, 12 Apr 2017 12:48:52 +0000 Message-Id: In-Reply-To: <322beef3-fd84-144c-6718-795eff0e4435@darbyshire-bryant.me.uk> References: <1698783902.612018.1491919195146.ref@mail.yahoo.com> <1698783902.612018.1491919195146@mail.yahoo.com> <322beef3-fd84-144c-6718-795eff0e4435@darbyshire-bryant.me.uk> Reply-To: xnor User-Agent: eM_Client/7.0.27943.0 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Cake] Choosing a tin to work on X-BeenThere: cake@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Cake - FQ_codel the next generation List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2017 12:48:52 -0000 Hey, >> s64 tdiff =3D b->tin_time_next_packet - now; >> if(tdiff <=3D 0 || tdiff <=3D best_time) { >> best_time =3D tdiff; >> best_tin =3D tin; >> } > >I'll try to answer this based on a vague bit of understanding...and=20 >then Jonathan can shoot me down as well :-) > >So the 'best_time' is signed because we can have a packet in a tin that= =20 >is not yet due to be sent (a positive result...ie. we have got here=20 >early) and/or we can have a tin that is due now/overdue (a=20 >zero/negative result, we've got here late) > >The complication is that we can have multiple tins overdue, so we want=20 >the highest priority *and* least overdue (least late) tin - this is the= =20 >reason for searching in tin_order[oi] and as a result tdiff can be <=3D= 0=20 >and bigger than best_time. > >best_time is initialised to the 'most early' time possible. that makes no sense to me. best_time is initialized to some high value (though why is it not 0x7FFF= =20 FFFF FFFF FFFFL, the highest possible positive s64?) such that no matter= =20 how far tdiff is in the future, best_time will always be set to the=20 lower tdiff. (Just like you would initialize a variable keeping track of the max to=20 the lowest possible value, you set a min variable to the highest=20 possible value.) But if you wanted best_time to end up as the lowest value, then you=20 would have to only set it if tdiff < best_time (or <=3D if you actually=20 want to prefer the last tin if they happen to have the same tdiff), and=20 not also if tdiff <=3D 0. For example, if tdiff values were 5000, -5000, 0 then best_time would be= =20 set to 0. The last value less than or equal to zero will always win as=20 best_tin. If all tdiff values are positive then best_time will end up as the=20 lowest value however.