Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /FWCore/MessageService/doc/single-thread.txt is written in an unsupported language. File is not indexed.

0001                 Single-threaded MessageLogger design plan
0002                 -----------------------------------------
0003 
0004                 
0005 The key points of change are on either side of the queue:
0006 
0007 On the left:
0008 ------------
0009 
0010 MessageLoggerQ needs to change every time it does b.commit() to a call
0011 to something in the scribe.  Clearly, it needs to know whetehter this is single
0012 or multiple threaded to make this choice.
0013 
0014 The change is to substitute runCommand(opcode, operand) for the sequence
0015 of creating, filling and committing the buffer for the SingleConsuerQ.
0016 
0017 There will be some commands with other slight changes as well.
0018 
0019 On the right:
0020 -------------
0021 
0022 MessageLoggerScribe::run()  
0023 
0024 do  {
0025     MessageLoggerQ::consume(opcode, operand);  // grab next work item from Q
0026 
0027 has to become something that gets invoked directly,
0028 and when the break happens, the code needs to return to the 
0029 calling routine.  The way to do this is to break off the meat
0030 of that internal do loop, into a call to runCommand(opcode, operand).
0031 
0032 The remainder of changes on the "right" of the fence are in particulars
0033 of the specific commands.
0034 
0035 B) Notify_all() is now not going to be needed in the case of single-threaded.
0036    That implies that the scribe ought to know whether it is single-treaded or 
0037    not.
0038 
0039 
0040 On the fence:
0041 -------------
0042 
0043 The issue is that one must not create a separate message logger thread if
0044 single-thread is desired.
0045 
0046 We first have to find out which option is wanted:  Here, we "parse" the command
0047 line directly, because the setup of the boost parser allows for an exception,
0048 which we want handled by the logger.
0049 
0050 We create a SingleThreadMSPresence to substitute for the MessageServicePresence.
0051 
0052 That has been tested with the plug-in mechanism, by making it identical to the
0053 service it replaces, and using it against the unit tests.  Note that I had to 
0054 include the new one in FWCore/MessageService/plugins/Module.cc also.
0055 
0056 
0057 
0058 At this point I have started changing SingleThreadMSPresence but am at a snag:
0059 MessageLoggerQ wants to call MessageLoggerScribe::runCommand, but that would
0060 introduce a dependency of MessageLogger on MessageService.
0061 
0062 
0063 Resolution of the snag:
0064 
0065 When SingleThreadMSPresence is created, it was going to have to instantiate a
0066 MessageLoggerScribe.  However, now MessageLoggerScribe puhlicly inherits from
0067 AbstractMessageLoggerScribe, which is defined in the MessageLogger pacakge.
0068 A pointer to that AbstractMessageLoggerScribe, which has a virtual method
0069 runCommand(opcode, operand) is provided to MessageLoggerQ.  So now, we
0070 can do scribePointer->runCommand(opcode, operand) an in the implementation
0071 level, it is actually pointing to a true MessageLoggerScribe!
0072 
0073 
0074 TODO:
0075 
0076 SingleThreadMSPresence ctor
0077   OK    create the (concrete) MessageLoggerScribe(true)
0078   OK    supply the pointer as an AbstractMLscribe to MessageLoggerQ
0079   OK    Determine if we need to instantiate MessageLoggerQ early in the 
0080             initializer list -- I don't think so, but...
0081 
0082 MessageLoggerQ
0083   OK    Have place for the mlscribe_ptr
0084   OK    Obtain mlscribe_ptr
0085         change commit sequence to mlscribe-ptr->runCommand
0086         change each of the specialized handshake commands (in tandem with MLS)
0087         
0088 MessageLoggerScribe
0089         Deal with wind-down issues - may not need code changes, but...
0090         change each of the specialized handshake commands (in tandem with MLQ)
0091 
0092 MessageDrop
0093         Inform MessageDrop about singleThread status
0094         When single thread, don't use thread-specific singletons.
0095         
0096 Testing
0097 
0098 
0099 Do we need to pre-instantiate MessageLoggerQ early in the SingleThreadMSPresence
0100 initializer list?  No, because before it is ever used, it will be instantiated
0101 by the code trying to use it.  There is no worry about interthread coherence
0102 in the single-thread mode. 
0103 
0104 MessageDrop is also going to have to change, since it is a thread-specific
0105 static.  This in turn means it needsto be invformed and so forth.