Skip to content
Tcl Source Code History Of Ticket a382a311e098c19a
Login

History Of Ticket a382a311e098c19a

Artifacts Associated With Ticket a382a311e098c19a

  1. Ticket change [a93954d90a] (rid 252368) by juliannoble2 on 2026-03-28 04:55:08:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      related but I suspect different to https://core.tcl-lang.org/tcl/tktview/108904173c
      
      An example on windows c:/windows/system32 folder (which is one of the largest default directories on a windows system)
      
        %llength [glob {[a]*}]
        246
        %llength [glob {[A]*}]
        246
        %llength [glob {[aA]*}]
        246
      
      I have an alternative command fglob that I implemented using twapi that can produce correct results.
      
        %llength [fglob {[a]*}]
        118
        %llength [fglob {[A]*}]
        128
        %llength [fglob {[aA]*}]
        246
      
      I expect on a case-insensitve system that characters outside either character classes or braced-alternative globs should be case-insensitive, but character classes such as [a-z] [A-Z] should be respect the case of the file as stored on the system - which is clearly possible to do, and at least in the cases I tested - pretty performantly.
      
      As a side note - my wrapper is using tcl script and twapi but no other c code - and is understandably slower on many simple queries such as *, it can outperform the builtin glob on some of the more complex glob queries.
        
        %time {glob {[a]*}}
        9444 microseconds per iteration
      
        %time {fglob {[aA]*}}
        3164 microseconds per iteration
        %time {fglob {[a]*}}
        1820 microseconds per iteration
      
      This suggests that there may be justification for re-examining the mechanisms being used here - although I don't claim to know all the tradeoffs that could be required to preferably optimise for simple cases.
      
      I would expect my tcl/twapi alternative to be slower in all cases.
      
      The difference is large enough that I don't think it's related to any side issues such as option parsing or checking for vfs etc (which I also do anyway)
      My fglob also handles braced expressions (even nested) and generates fairly complex regexps to post-process the result from necessarily broader queries that the underlying windows system accepts (only * and ? globs).
      
      Whilst I haven't set up tests to verify my fglob supports all possible valid globs (e.g processing escaped glob characters in all levels of nesting) the time difference is still a bit suspicious to me, and the simple cases above should be faster regardless of glob processing which I wouldn't expect to dominate.
      
      My time tests are on a modern fast nvme ssd - so I can't suggest that my glob vs fglob timings above are indicative for spinning rust systems, although testing on a mapped network drive from a share on a remote system the fglob version was still significantly faster than glob for those basic character-class queries.
      
    5. is_private initialized to: "0"
    6. login: "juliannoble2"
    7. priority initialized to: "5 Medium"
    8. private_contact initialized to: "957fdfcd8744611e3fe1f4896c7538b1d9bf47b2"
    9. resolution initialized to: "None"
    10. severity initialized to: "Important"
    11. status initialized to: "Open"
    12. submitter initialized to: "juliannoble2"
    13. subsystem initialized to: "37. File System"
    14. title initialized to:
      glob on case insentitive sytems not respecting character class case
      
    15. type initialized to: "Bug"
  2. Ticket change [dd5ea83704] (rid 252369) by juliannoble2 on 2026-03-28 05:02:28:

    1. comment changed to:
      related but I suspect different to https://core.tcl-lang.org/tcl/tktview/108904173c
      
      An example on windows c:/windows/system32 folder (which is one of the largest default directories on a windows system)
      
        %llength [glob {[a]*}]
        246
        %llength [glob {[A]*}]
        246
        %llength [glob {[aA]*}]
        246
      
      I have an alternative command fglob that I implemented using twapi that can produce correct results.
      
        %llength [fglob {[a]*}]
        118
        %llength [fglob {[A]*}]
        128
        %llength [fglob {[aA]*}]
        246
      
      I expect on a case-insensitve system that characters outside either character classes or braced-alternative globs should be case-insensitive, but character classes such as [a-z] [A-Z] should be respect the case of the file as stored on the system - which is clearly possible to do, and at least in the cases I tested - pretty performantly.
      
      As a side note - my wrapper is using tcl script and twapi but no other c code - and is understandably slower on many simple queries such as *, it can outperform the builtin glob on some of the more complex glob queries.
        
        %time {glob {[a]*}}
        9444 microseconds per iteration
      
        %time {fglob {[aA]*}}
        3164 microseconds per iteration
        %time {fglob {[a]*}}
        1820 microseconds per iteration
      
      This suggests that there may be justification for re-examining the mechanisms being used here - although I don't claim to know all the tradeoffs that could be required to preferably optimise for simple cases.
      
      I would expect my tcl/twapi alternative to be slower in all cases.
      
      The difference is large enough that I don't think it's related to any side issues such as option parsing or checking for vfs etc (which I also do anyway)
      My fglob also handles braced expressions (even nested) and generates fairly complex regexps to post-process the result from necessarily broader queries that the underlying windows system accepts (only * and ? globs).
      
      Whilst I haven't set up tests to verify my fglob supports all possible valid globs (e.g processing escaped glob characters in all levels of nesting) the time difference is still a bit suspicious to me, and the simple cases above should be faster regardless of glob expression processing or post-retrieval filtering which I wouldn't expect to dominate.
      
      My time tests are on a modern fast nvme ssd - so I can't suggest that my glob vs fglob timings above are indicative for spinning rust systems, although testing on a mapped network drive from a share on a remote system the fglob version was still significantly faster than glob for those basic character-class queries.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  3. Ticket change [633cb4c972] (rid 252370) by juliannoble2 on 2026-03-28 05:25:55:

    1. icomment:
      Just to clarify - the performance thing is really not the point of this.
      
      I believe that once there are more than a handful of character class entries e.g [a-d] my system performs more hits to the the filesystem and use of {choice1,choice2,...} can result in a combinatoric explosion of underlying queries which is slower than just retrieving all and doing only post-filtering.
      An optimised system might count the number of queries generated and switch strategies.
      
      It may not be worth further complicating the core glob code just because some intermediate style queries aren't optimal.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  4. Ticket change [e5687cbbfe] (rid 252371) by apnadkarni on 2026-03-30 11:50:41:

    1. icomment:
      I am not sure I agree that `glob [a-z]` should not match a file called `A` on case-insensitive systems. As I see it, the glob pattern represents a (potentially infinite) set of strings. The command then should return any file name that matches any of those strings using the case-sensitivity behaviour of the file system.
      
      Regarding performance, while debugging the related bugs, it appeared that traversal to build the internal representation is unnecessarily duplicated at times. I've still not fully grok'ed maintenance of the representation. The other possiblity is that Tcl builds up the internal representation of the file path which twapi does not do. While this is an additional cost in globbing (possibly wasted), it may speed up later operations such as normalization. I wonder how relative performance would look if you normalized the returned paths in both cases.
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  5. Ticket change [59216cd1f8] (rid 252372) by juliannoble2 on 2026-03-30 14:58:09:

    1. icomment:
      While I like, and find it occasionally useful that in my system I can differentiate [A-Z] [a-z] etc and was surprised it didn't by default, I can see this isn't necessarily a common expectation.
      
      I had an expectation of what a character in square brackets would match on case-preserving systems where there are sometimes conventions about capitalization of tags in filenames.
      The Globbing Patterns section of the docs didn't clarify - but if it's never been raised before I guess it's a minor concern and I'm fine with this being closed. I have my workaround.
      
      
      You're right, the performance gain is illusory if you have to normalize.
      (for all but small result sets)
      In my case I'm using it mainly as part of a system for interactive viewing, so am often not normalizing - but then the speed difference is not so important for that sort of application.
      
      I wonder if not normalizing makes a memory difference in a long running session doing lots of listings? Probably not a big concern either unless AI keeps eating all our ram forever.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  6. Ticket change [7e24f155bc] (rid 252380) by apnadkarni on 2026-03-31 05:28:29:

    1. closedate changed to: "2461130.7281243517"
    2. closer changed to: "apnadkarni"
    3. login: "apnadkarni"
    4. mimetype: "text/plain"
    5. resolution changed to: "Rejected"
    6. status changed to: "Closed"