Overview
| Artifact ID: | 90c938ccf23984a65975780944dcb0f04f9ba1d6e75788be8bcc3428d6f480d8 |
|---|---|
| Ticket: | 02d5d65d70adab975fce0c87800140999ab80f3e
File subsystem commands and operations suffer from unneeded (but expensive) path normalization |
| User & Date: | sebres on 2024-09-13 11:35:11 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
It looks like more than 20 years (for instance since 2003 in [da7df285d16e6c30]), tcl's file related functions and commands suffer from unneeded path normalization and therefore unnecessarily slower than they may be. This is almost invisible if one is testing with constant path (literals), because they hold then normalized path in internal representation, but very well bothering on variable path objects, what is mostly the normal case, if paths gets generated, read from somewhere, anyway dynamically constructed every time before their usage.<br/> But the path normalization is very expensive, especially it is noticeable on hosts with rude corporate "protection" software like AV/DLP/Endpoint-Protection/Whatever-else-bothers-dev-to-work. Just note that particularly by windows the function <i>TclpObjNormalizePath</i> doing <i>GetFileAttributesExW</i> + <i>WinReadLinkDirectory</i> + <i>FindFirstFileW</i> (basically glob)! Below are 2 examples illustrating this behaviour on such a host. Note that _determ_fn always creates new object, and <i>string trim</i> is used only to force this, as well as the costs of such path generation is almost to neglect (0.01%), additionally the T:-drive used here is a RAM-disk: <code><pre> % proc _determ_fn {i} { string trimright "T:/TestCLU/a7/40vbp43/vu/3g/616q4bet2lf53lf88vo5q2.ent " } % timerate { set fn [_determ_fn 123] }; # costs of deterministic path generation <b>0.457163 µs/# 2081613 # 2187404 #/sec 951.636 net-ms</b> % set fn [_determ_fn 123]; timerate { close [open $fn] }; # 1 time normalization <b style="color:green;">1411.53 µs/# 709 # 708.45 #/sec 1000.774 net-ms</b> % timerate { set fn [_determ_fn 123]; close [open $fn] }; # every time normalization <b style="color:red;">3060.91 µs/# 327 # 326.70 #/sec 1000.917 net-ms</b> </pre></code> The cost of such (unneeded here!) normalization overhead - 1650 µs, so <b>more than 50%.</b> The same is valid for another, much faster file commands like <i>file exists</i>, <i>file attributes</i>, <i>file stat</i> etc. However there the overhead may be <b>up to 95%</b> under normal circumstances or <b>up to 1000%</b> on hosts with rude corporate infrastructure or for UNC-paths over network (samba, cifs, nfs, etc): <code><pre> % set fn [_determ_fn 123]; timerate { file exists $fn }; # 1 time normalization <b style="color:green;">4.277398 µs/# 116259 # 233786 #/sec 497.286 net-ms</b> % timerate { set fn [_determ_fn 123]; file exists $fn }; # every time normalization <b style="color:red;">1505.03 µs/# 665 # 664.44 #/sec 1000.845 net-ms</b> </pre></code> <b>I would like to emphasise once again</b> - the constant literal paths is rather an exception, because the normal case is usually a dynamic path object that is created or read from somewhere instantly before its usage: corresponds the second (red) case in both illustrations above. I already fixed this and will try to provide a solution soon together with performance regression-test coverage. - foundin changed to: "any"
- is_private changed to: "0"
- login: "sebres"
- priority changed to: "5 Medium"
- private_contact changed to: "50e9528765c18296566374b3fde2df942c394efd"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "sebres"
- subsystem changed to: "- New Builtin Commands"
- title changed to:
File subsystem commands and operations suffer from unneeded (but expensive) path normalization
- type changed to: "Bug"