tps TCL "echo" command output

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf tps TCL "echo" command output

  • Creator
    Topic
  • #54516
    Tom Parsons
    Participant

      I have a number of tps TCL scripts that sometimes “echo” a large

      number of lines (100+, for troubleshooting/debugging purposes)

      for each inbound/outbound msg.

      So I may at times turn ON these “BIG echos” in our production VM environment.

      My question is- Does the “echo” command buffer the output lines internally

      or does each “echo” execute it’s own I/O to the log file ?

      If not, I presume that if the tps script itself were to buffer the lines

      then that would be much less I/O intensive.  ???

      Thanks,

      Tom

      []

    Viewing 0 reply threads
    • Author
      Replies
      • #81807

        https://www.tcl.tk/man/tcl8.4/TclCmd/puts.htm

        Tcl buffers output internally, so characters written with puts may not appear immediately on the output file or device; Tcl will normally delay output until the buffer is full or the channel is closed. You can force output to appear immediately with the flush command.

        When the output buffer fills up, the puts command will normally block until all the buffered data has been accepted for output by the operating system. If channelId is in nonblocking mode then the puts command will not block even if the operating system cannot accept the data. Instead, Tcl continues to buffer the data and writes it in the background as fast as the underlying file or device can accept it. The application must use the Tcl event loop for nonblocking output to work; otherwise Tcl never finds out that the file or device is ready for more output data. It is possible for an arbitrarily large amount of data to be buffered for a channel in nonblocking mode, which could consume a large amount of memory. To avoid wasting memory, nonblocking I/O should normally be used in an event-driven fashion with the fileevent command (don’t invoke puts unless you have recently been notified via a file event that the channel is ready for more output data).

        -- Max Drown (Infor)

    Viewing 0 reply threads
    • The forum ‘Cloverleaf’ is closed to new topics and replies.