Artifacts Associated With Ticket 02d5d65d70adab97
Ticket change [90c938ccf2] (rid 233382) by sebres on 2024-09-13 11:35:11:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized 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 initialized to: "any"
- is_private initialized to: "0"
- login: "sebres"
- priority initialized to: "5 Medium"
- private_contact initialized to: "50e9528765c18296566374b3fde2df942c394efd"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "sebres"
- subsystem initialized to: "- New Builtin Commands"
- title initialized to:
File subsystem commands and operations suffer from unneeded (but expensive) path normalization
- type initialized to: "Bug"
Ticket change [b43c183594] (rid 233383) by sebres on 2024-09-13 11:36:07:
- login: "sebres"
- mimetype: "text/plain"
- severity changed to: "Important"
- subsystem changed to: "37. File System"
Ticket change [100654cbe0] (rid 233405) by sebres on 2024-09-13 13:25:12:
- icomment:
Fixed in branch [/vdiff?from=0c5f93a2d2c02cf9&to=bug-02d5d65d70adab97|bug-02d5d65d70adab97] for 8.6. All tests pass (win/unix), there is almost no overhead visible anymore in performance regressions tests. I'll merge it later if no objections follow.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"
- icomment:
Ticket change [f9ad82f0fb] (rid 233419) by dgp on 2024-09-13 18:46:59:
- icomment:
If someone can get to it before I can, please check this revision doesn't cause troubles with trofs. https://math.nist.gov/~DPorter/tcltk/trofs/
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [4155e6330d] (rid 233429) by sebres on 2024-09-13 21:39:41:
- icomment:
Why should it, Don?<br/> I hope the fix affects only absolute paths (in native FS) or relative paths if cwd is native, otherwise I guess tcl should already have caused troubles previously too. One case may be surely a bit incompatible or unexpected behaviour of functions in VFS-definition (e. g. filesystemPathTypeProc or pathInFilesystemProc), but then they can be adjusted to consider "new" handling. However it is surely worth to check the branch against few VFS.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [4a824c4250] (rid 233430) by juliannoble2 on 2024-09-14 01:05:24:
- icomment:
This issue has bugged me for a long time. I assume we could close this too now as I think it's essentially the same problem? https://core.tcl-lang.org/tcl/tktview/411f52ed87e313dd49e2
- login: "juliannoble2"
- mimetype: "text/plain"
- icomment:
Ticket change [55f164ae24] (rid 233436) by sebres on 2024-09-14 09:47:42:
- icomment:
Indeed, [411f52ed87e313dd49e2] looks very similar. However I'd like to see what would happen with 9.0 once this branch gets merged, since it seems to have a bit different timing (suspecting something around tilde-expansion changes).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [300c25b564] (rid 233438) by oehhar on 2024-09-14 17:10:58:
- icomment:
Sergey, great work ! Julian refers to ticket [411f52ed87e313dd49e2].
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment:
Ticket change [7607f37a3d] (rid 233444) by jan.nijtmans on 2024-09-14 21:32:04:
- icomment:
At least the [https://github.com/tcltk/tcl/actions/runs/10860554987|Github ACTIONS] build doesn't show any errors. Since 8.6.15 is close to release, I suggest to wait until after this release for the merge. After that: no objection from me.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [c97c2c202c] (rid 233445) by jan.nijtmans on 2024-09-14 21:33:39:
- icomment:
Hm. Better point to the [https://github.com/tcltk/tcl/actions/runs/10860554984|Github ACTIONS] build on Windows. They pass too.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [3755a4ea96] (rid 233451) by sebres on 2024-09-15 11:16:50:
- icomment:
Just a note for me: the check for tilde expansion (marked with TODO in the branch) is indeed not really necessary for 9.0, because <i>file pathtype ~/test</i> is "relative" since merge of TIP#602, where still "absolute" for 8.x. However, it'd be better to have a common function that'll be able to tell whether normalization is needed. Or maybe to move some logic into VFS-definition for Tcl_FSGetNativePath (where it basically belongs to).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [37358503a9] (rid 233536) by sebres on 2024-09-17 15:57:41:
- icomment:
8.6.15 is released, thus the fix is merged now in all branches >= 8.6.<br/> For 8.7+ there was additional unneeded normalization in zipfs, which is solved in [ed87833280], and merged as whole thing in 9.0 in [265dc4708a3bf925] + small amend hereafter (removing tilde expansion check for windows). I hope the major issues of [411f52ed87e313dd49e2] are fixed too now (at least the performance regression of 8.7+).<br/> However there was also mentioned a <i>glob</i> command (which is notoriously slow under windows)... I don't think there is good a way to speed-up it together with <i>file normalize</i>, excepting possibly a new option like <i>file normalize -fast ...</i> what could do normalization similar translated path + sym-links, but without FindFirstFileW and co (so no unique path generation).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [1c81e7de4b] (rid 233537) by sebres on 2024-09-17 15:58:15:
- closedate changed to: "2460571.16545472"
- closer changed to: "sebres"
- login: "sebres"
- mimetype: "text/plain"
- status changed to: "Closed"
Ticket change [2ca15e06cf] (rid 233545) by jan.nijtmans on 2024-09-18 08:21:24:
- assignee changed to: "sebres"
- closer changed to: "nobody"
- icomment:
All --enable-symbols=mem builds for 8.7 and 9.0 are failing now on all platforms. There appears to be a memory leak. Therefore, re-opening. @sebres, can you have a look at this? I suspect the changes in the zipfs, since 8.6 doesn't have that part, and the leak is visible on all platforms not only Windows.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- status changed to: "Open"
Ticket change [8f319d82e9] (rid 233547) by sebres on 2024-09-18 10:40:47:
- icomment:
Hmm... Indeed. It is because Tcl_FSGetTranslatedPath in opposite to Tcl_FSGetNormalizedPath always returns an incremented object reference (why basically? like normPathPtr, translatedCwdPtr is also stored in the internal representation and it'd be no needs to increase it at all). Anyway will fix it asap. By the way, I noticed your comment only accidental - because there are no mails from tcl-repo in the mailing list anymore since 27th Aug (the mails [Tk] arriving, but not [Tcl])... And it is surely not my system, because in SF mailing list archive also nothing since 27th Aug.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [58f41915dd] (rid 233553) by sebres on 2024-09-18 10:56:21:
- closedate changed to: "2460571.95580083"
- closer changed to: "sebres"
- icomment:
Mem-leak is fixed in [536390e4258fbef0], thus close.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- status changed to: "Closed"
Ticket change [955b82e15e] (rid 235649) by dgp on 2024-12-02 13:00:27:
- closedate changed to: "2460647.04198557"
- closer changed to: "dgp"
- icomment:
The memory leak fix needs to be backported to the 8.6 branch, right? I see leaks in the 8.6.16 release candidate.
- login: "dgp"
- mimetype: "text/plain"
Ticket change [0a4cfc2ab3] (rid 235650) by dgp on 2024-12-02 13:08:40:
- closedate changed to: "2460647.04768518"
- icomment:
No. That memleak fix is in zipfs code, which isn't in Tcl 8.6. This major system rewrite in a patch release of a stable branch has instead introduced some other memleaks. Searching....
- login: "dgp"
- mimetype: "text/plain"
Ticket change [b9f42233d2] (rid 235651) by dgp on 2024-12-02 13:35:23:
- closedate changed to: "2460647.06624785"
- icomment:
The commit [a6a5870235ce08b2] modifies the routine TclFSCwdIsNative(), adding a call to Tcl_FSGetCwd(). That call (eventually) allocates a Tcl_Obj in line 735: tsdPtr->cwdPathPtr = Tcl_NewStringObj(str, len); and that allocation leaks. Not yet clear to me why the existing refcount housekeeping isn't able to handle this. - login: "dgp"
- mimetype: "text/plain"
Ticket change [bc5db7e692] (rid 235653) by dgp on 2024-12-02 13:58:52:
- closedate changed to: "2460647.08255398"
- icomment:
Maybe this is easy. Documentation for Tcl_FSGetCwd() says "...The result already has its reference count incremented for the caller. When it is no longer needed, that reference count should be decre‐ mented." This new call doesn't seem to be following the instructions. Will try that as a fix. - login: "dgp"
- mimetype: "text/plain"
Ticket change [28ac18472e] (rid 235667) by sebres on 2024-12-02 14:39:42:
- closedate changed to: "2460647.11090851"
- closer changed to: "sebres"
- icomment:
Good catch, Don!.. I added small amend [e4feb601a833fa18] to avoid possible theoretical segfault. However it'd be nice to have some routine updating cwdPath (tsdPtr->cwdPathPtr) and epoch without to return incremented reference (so one could use it instead of Tcl_FSGetCwd for the init purposes).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"