Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 623850f1cd36343782385428b01ce8289fce7e6b8f88d3af6bcf02ca4ec0efc5
Ticket: de232b49f26da1c18e07513d4c7caa203cd27910
write-only nonblocking refchan and Tcl internal buffers
User & Date: apnadkarni on 2024-03-30 15:59:38
Changes

  1. icomment:
    With respect to side effects with my branch setting refchan buffering to none by default, I have not seen any after experimenting for a while. All tests pass on Win and Linux and for the most obvious consequence - performance - there is no discernible difference:
    
    With current trunk:
    
    ```
    % timerate -calibrate {}
    0.08983439299958879 µs/#-overhead 0.090688 µs/# 21524429 # 11026859 #/sec
    % set fd [tcl::chan::memchan]
    rc0
    % timerate {puts -nonewline $fd x}
    7.680620 µs/# 128693 # 130197 #/sec 988.442 net-ms
    % seek $fd 0
    % string length [read $fd]
    128693
    ```
    
    With the -buffering none based solution
    
    ```
    % timerate -calibrate {}
    0.09071036436181426 µs/#-overhead 0.091423 µs/# 21351367 # 10938200 #/sec
    % set fd [tcl::chan::memchan]
    rc0
    % timerate {puts -nonewline $fd x}
    7.687302 µs/# 128568 # 130084 #/sec 988.341 net-ms
    % string length [read $fd]
    0
    % seek $fd 0
    % string length [read $fd]
    128568
    ```
    
    I suppose one might expect this. Buffering is really meant to mitigate the cost of disk i/o and system call transitions. There is none with reflected channels.
    
    An alternative, but similar effect, would be to set buffersize to 1 but the related code is a little more convoluted and I don't think offers any benefit over -buffering none.
    
    I'm inclined to favor the -buffering none solution. It handles not the socket test and Nathan's coro test. Docs will have to note refchans do not get buffering by default. Also, we would have to decided whether the application can change the buffering mode (I would say yes as long as the potential issues are noted in the documentation. If that is not desired, we could simply force the buffering to be -none and ignore / raise error on any requests for change).
    
  2. login: "apnadkarni"
  3. mimetype: "text/plain"