On Wed, Feb 25, 2009 at 11:12 AM, Matthew Toseland
<toad at amphibian.dyndns.org> wrote:
> On Thursday 29 January 2009 17:12:57 nextgens at freenetproject.org wrote:
>> Author: nextgens
>> Date: 2009-01-29 17:12:57 +0000 (Thu, 29 Jan 2009)
>> New Revision: 25364
>>
>> Modified:
>> ? ?trunk/freenet/src/freenet/node/FNPPacketMangler.java
>> ? ?trunk/freenet/src/freenet/node/PacketSender.java
>> ? ?trunk/freenet/src/freenet/node/PeerNode.java
>> ? ?trunk/freenet/src/freenet/node/RequestSender.java
>> ? ?trunk/freenet/src/freenet/support/Logger.java
>> ? ?trunk/freenet/src/freenet/support/LoggerHook.java
>> Log:
>> some untested code trying to address the lock-contention problem in the
> logger
>
> How expensive are the volatile's?
much cheaper then full synchronization.
volatile on boolean just prevent inlining in compiler, no fancy stuff.
>>
>> Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
>> ===================================================================
>> --- trunk/freenet/src/freenet/node/FNPPacketMangler.java ? ? ?2009-01-29
>> 16:36:30
> UTC (rev 25363)
>> +++ trunk/freenet/src/freenet/node/FNPPacketMangler.java ? ? ?2009-01-29
>> 17:12:57
> UTC (rev 25364)
>> @@ -47,6 +47,7 @@
>> ?import freenet.support.HTMLNode;
>> ?import freenet.support.HexUtil;
>> ?import freenet.support.Logger;
>> +import freenet.support.LogThresholdCallback;
>> ?import freenet.support.SimpleFieldSet;
>> ?import freenet.support.TimeUtil;
>> ?import freenet.support.WouldBlockException;
>> @@ -62,8 +63,18 @@
>> ? * changes in IncomingPacketFilter).
>> ? */
>> ?public class FNPPacketMangler implements OutgoingPacketMangler,
> IncomingPacketFilter {
>> - ? ? private static boolean logMINOR;
>> - ? ? private static boolean logDEBUG;
>> + ? ? private static volatile boolean logMINOR;
>> + ? ? private static volatile boolean logDEBUG;
>> +
>> + ? ? static {
>> + ? ? ? ? ? ? Logger.registerLogThresholdCallback(new LogThresholdCallback(){
>> + ? ? ? ? ? ? ? ? ? ? public void shouldUpdate(){
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? logMINOR = Logger.shouldLog(Logger.MINOR,
>> this);
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? logDEBUG = Logger.shouldLog(Logger.DEBUG,
>> this);
>> + ? ? ? ? ? ? ? ? ? ? }
>> + ? ? ? ? ? ? });
>> + ? ? }
>> +
>> ? ? ? private final Node node;
>> ? ? ? private final NodeCrypto crypto;
>> ? ? ? private final MessageCore usm;
>> @@ -168,8 +179,6 @@
>>
>> ? ? ? ? ? ? ? fullHeadersLengthMinimum = HEADERS_LENGTH_MINIMUM +
> sock.getHeadersLength();
>> ? ? ? ? ? ? ? fullHeadersLengthOneMessage = HEADERS_LENGTH_ONE_MESSAGE +
> sock.getHeadersLength();
>> - ? ? ? ? ? ? logMINOR = Logger.shouldLog(Logger.MINOR, this);
>> - ? ? ? ? ? ? logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
>> ? ? ? }
>>
>> ? ? ? /**
>> @@ -208,8 +217,6 @@
>> ? ? ? ?*/
>> ? ? ? public void process(byte[] buf, int offset, int length, Peer peer, long
> now) {
>> ? ? ? ? ? ? ? node.random.acceptTimerEntropy(fnpTimingSource, 0.25);
>> - ? ? ? ? ? ? logMINOR = Logger.shouldLog(Logger.MINOR, this);
>> - ? ? ? ? ? ? logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
>> ? ? ? ? ? ? ? if(logMINOR) Logger.minor(this, "Packet length "+length+" from
>> "+peer);
>>
>> ? ? ? ? ? ? ? /**
>> @@ -1806,7 +1813,7 @@
>> ? ? ? private boolean tryProcess(byte[] buf, int offset, int length,
>> SessionKey
> tracker, long now) {
>> ? ? ? ? ? ? ? // Need to be able to call with tracker == null to simplify
>> code above
>> ? ? ? ? ? ? ? if(tracker == null) {
>> - ? ? ? ? ? ? ? ? ? ? if(Logger.shouldLog(Logger.DEBUG, this))
>> Logger.debug(this, "Tracker ==
> null");
>> + ? ? ? ? ? ? ? ? ? ? if(logDEBUG) Logger.debug(this, "Tracker == null");
>> ? ? ? ? ? ? ? ? ? ? ? return false;
>> ? ? ? ? ? ? ? }
>> ? ? ? ? ? ? ? if(logMINOR) Logger.minor(this,"Entering
> tryProcess: "+Fields.hashCode(buf)+ ',' +offset+ ',' +length+ ',' +tracker);
>>
>
> _______________________________________________
> Devl mailing list
> Devl at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
>