Overview
| Artifact ID: | ea722b53d5f2664b2d835566461df476d8171ba2333ac5a2fb382740be6782cd |
|---|---|
| Ticket: | 3d1c409f1afbca6b74f824cffe8dbb4028a410c5
Bad performance: tclThreadAlloc vs. CPU-cache (fragmentation/granularity/etc)... |
| User & Date: | sebres on 2024-11-20 15:50:02 |
Changes
- icomment:
<blockquote>> Does tclThreadAlloc() really have better performance, compared to modern malloc/free implementations?</blockquote> Single-threaded it is marginally better, however the lot of the load remains in user space, and doesn't go in kernel time (syscalls), because Tcl works not in native ways with memory how any C/C++ programs would do, but everything (every object, var, hash-element) expects at least 1 allocation (mostly 2 or more) and alloc/free becomes a mass processing.<br/> Multi-threaded it is many, many times superior, because mostly no locking happens (or coarse-grained locking only if more memory needed) and also touches the kernel rarely. With OS allocator, I saw a tenfold degradation already on 4 threads. It is like GIL in python (not really that, but the effect looks indeed very similar, especially with growth in thread count). So yes, a (smart) memory-manager is still a must for things like Tcl, even with modern OS. Surely with a disadvantage of in tcl-core reserved memory (what can also be solved with a GC, periodically freeing memory, and/or with periodical release of working threads, reaching some idle time).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"