Skip to content
Tcl Source Code History Of Ticket 219228ffffffffff
Login

History Of Ticket 219228ffffffffff

Artifacts Associated With Ticket 219228ffffffffff

  1. Ticket change [11e8d22266] (rid 95222) by nobody on 2000-10-26 05:03:51:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 4206 RFE
      Version: 8.2.3
      SubmitDate: '2000-02-22'
      LastModified: '2000-03-30'
      Severity: LOW
      Status: Assigned
      Submitter: techsupp
      ChangedBy: hobbs
      OS: Solaris
      OSVersion: SunOS 5.7
      Machine: Ultra Sparc, 128MB of RAM, Single Processor.
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-25'
      
      
      Name:
      David Whittle
      
      Extensions:
      Sybtcl-2.5 (although it was not loaded for the test).
      
      CustomShell:
      None.
      
      ReproducibleScript:
      # The file represented by "test.file" should be a binary file
      # with 2+ million records, where a record is defined as 42 bytes.
      set fp [open test.file r]
      set i 0
      set time [clock seconds]
      while {[read $fp 42] != 0} {
          if ![expr 50000 % $i] {
              set now [clock seconds]
              puts "[expr $now - $time] secs, $i recs, [expr 50000 / ($now - $time)] recs per sec"
              set time $now
          }
      }
      close $fp
      
      ObservedBehavior:
      The issue that I have found is that running the above script (which is essentially only doing a read) takes ~8 seconds to process 50000 "records". When we compared this against a similar Perl script, Perl out did Tcl by a few orders of magnitude (Perl ran through 200000 in ~1 second).
      I looked at the code for the read command and it appears to me that the issue lies in the entended work with the channel code as well as how it appears to attempt to process each byte, even if no conversion is required.
      I also tried testing this in 8.1.1 (The above script wouldn't work in 8.0 and below (i'm guessing due to the binary data in the file)) which ran a bit faster (5 seconds for 50,000 records) and 8.3 which ran about the same speed as 8.2.3.
      
      DesiredBehavior:
      I would expect unless something has been specified differently in the fconfigure command that it would bubble down to a simple fread command for increased performance on the reads.
      
      
      
      I would expect a noticeable speedup if the standard programming
      paradigms were followed.  This should be:
      
      proc process {file} {
        set fp [open $file r]
        set i 0
        set time [clock seconds]
        while {[read $fp 42] != 0} {
          if {!(50000 % $i)} {
              set now [clock seconds]
              puts "[expr {$now - $time}] secs, $i recs, [expr {50000 / ($now - $time)}] recs per sec"
              set time $now
          }
        }
        close $fp
      }
      process test.file
      
      That needs to be tested first, before we evaluate the I/O (which
      could likely be improved).  Of course, bulk reads with range
      fetches would then be much better. 
      -- 02/22/2000 hobbs
      
      
      
    4. foundin initialized to: "final: 8.2.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "37. File System"
    10. title initialized to: "improve speed of read command"
    11. type initialized to: "RFE"
  2. Ticket change [28168e7911] (rid 88639) by dkf on 2000-11-10 21:22:49:

    1. icomment:
      Do you get improved performance by specifying that you are reading binary data as opposed to data which needs converting to UTF-8/UNICODE?  If that "fixes" the problem, then the problem is due to Tcl's encoding support, which can have quite a large performance penalty.  In that case, there's not a lot that can be done about it.  You would expect Perl to suffer similarly if it was trying to do encoding stuff though!
      
      A short test later, I find when reading binary data that I get much better performance with...
      
       proc process {file} { 
          set fp [open $file r]
          fconfigure $fp -translation binary
          set i 0 
          set time [clock seconds] 
          while {[string length [read $fp 42]] != 0} { 
             if {!([incr i] % 50000)} {
                set now [clock seconds] 
                puts "[expr {$now - $time}] secs, $i recs" 
                set time $now 
             } 
          } 
          close $fp 
       }
      
      Unfortunately, the actual figures aren't too good since my computer started swapping...  :^(
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [618208c4f0] (rid 92251) by hobbs on 2001-08-02 08:44:57:

    1. foundin changed to: "None"
    2. subsystem changed to: "None"
  4. Ticket change [3535c0e10c] (rid 106881) by andreas_kupries on 2001-09-18 01:24:55:

    1. assignee changed to: "andreas_kupries"
    2. subsystem changed to: "24. Channel Commands"
  5. Ticket change [66f0ca13fe] (rid 102816) by andreas_kupries on 2001-09-18 01:37:49:

    1. closedate changed to: "2001-09-17T18:37:49"
    2. closer changed to: "andreas_kupries"
    3. icomment:
      Logged In: YES 
      user_id=75003
      
      David Whittle = <[email protected]>.
      Sent mail asking for feedback ... 
      
      
      
    4. login: "andreas_kupries"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "andreas_kupries"