Overview
| Artifact ID: | 44d8ad26dbfe32a6e381a0703a6ed77bc5994ca1 |
|---|---|
| Ticket: | 2873596fffffffffffffffffffffffffffffffff
Slowness in passing data through interp eval |
| User & Date: | apnadkarni on 2009-10-06 17:39:20 |
Changes
- assignee changed to: "hobbs"
- cmimetype changed to: "text/plain"
- comment changed to:
I want to process data received over the network in a safe interpreter (although for the purposes of this question, the safe-ness is irrelevant). Roughly speaking, I invoke the safe interpreter as safeinterp eval [list process_request $received_data] What I've found is that invoking the slave interpreter in this manner is slower than processing in the same interpreter by two orders of magnitude or more. Here is a tkcon session simulating the issue: (woof) 51 % interp create ip ip (woof) 52 % ip eval {proc slaveproc arg {}} (woof) 53 % string length [set s [string repeat x 100000]] 100000 (woof) 54 % time {ip eval [list slaveproc $s]} 10 3335.4 microseconds per iteration So roughly, 3.3ms to pass 100K into an empty proc in the slave. By comparison, passing it to a proc in the same interp (using eval for consistency) (woof) 55 % proc masterproc arg {} (woof) 56 % time {eval [list masterproc $s]} 10 9.3 microseconds per iteration So use of a slave interpreter in this fashion is MUCH slower. Timestamping the C code, the slowdown with the slave interp seems to happen because of shimmering in SlaveEval (the internal rep for the list is thrown away and converted to a string and then converted back in the slave). Workaround - Alexander Ferrieux on tcl-core pointed out a workaround. To quote him - ---- While I admit I don't fully understand this necessity, it turns out the multiple-argument code path doesn't have the limitation, since it directly calls Tcl_ConcatObj on its list of arguments, and it is well known that TCO is optimized for all-pure-list arguments (dating back to Paul Duffin's work on Concat objects IIRC). Hence one can derive a script-level idiom guaranteeing a shimmerless path: ip eval [list slaveproc] [list $s] ----- I also tested with 8.5.2. It is equally slow, and what's more Alexander's workaround does not work there (it's still slow), presumably because Tcl_ConcatObj is not optimized in 8.5.2 (conjecture) /Ashok - foundin changed to: "obsolete: 8.6b1.1"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "apnadkarni"
- subsystem changed to: "20. [interp]"
- title changed to: "Slowness in passing data through interp eval"
- type changed to: "Bug"