SessionLog improvement
----------------------
Key: DIRMINA-445
URL: https://issues.apache.org/jira/browse/DIRMINA-445
Project: MINA
Issue Type: Improvement
Components: Core
Affects Versions: 1.1.3, 2.0.0-M1
Environment: Use Object instead of String inSessionLog logging method
to allow for massive perfs improvement on production running instances (when
logs filtering is used).
Reporter: vincent bourdaraud
Priority: Minor
SessionLog.debug(IoSession,String), info(IoSession,String),
warn(IoSession,String) and error(IoSession,String) should be changed to
SessionLog.debug(IoSession,Object), info(IoSession,Object),
warn(IoSession,Object) and error(IoSession,Object), as in log4j.
The reason for this is that if passing Objects instead of String allow to delay
the composition of the logging message (.toString() call) until really needed
and that could greatly improve performance. This kind of feature is needed to
build SW able to be turned in debug while in production using NDC/MDC filters
(using log4j e.g.).
Some code snippet the illustrate this:
public void messageReceived(IoSession session, Object o) throws Exception
{
MyProtocolRequest req = (MyProtocolRequest) o;
NDC.put(req.getUserId());
SessionLog.debug(session, new RequestDumper(req));
NDC.pop();
}
class RequestDumper()
{
public RequestDumper(MyProtocolRequest req)
{
this.req = req;
}
public String toString()
{
return req.toString();
}
private MyProtocolRequest req;
}
In that snippet, the cost of converting MyProtocolRequest to a String is not
paied when SessionLog.debug() is called, but when the underlying logging
framework needs the string for logging. The perf improvement could be massive
if the underlying protocol uses some kind of filtering to filter-out most debug
logs; in that example, the logging framework would be configured to filter-in
only logs with a NDC set to a specific user.
With this feature, we could enable debug in production for some few users only,
without killing the overall performances.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.