|
2004-09-22
| ||
| 22:48 | • Ticket [729692ffff] redef of bcc'ed commands inoperant in current bcode ... artifact: 0ce974bee6 user: msofer | |
|
2004-03-31
| ||
| 01:10 | • Closed ticket [729692ffff]. artifact: 192a71292d user: msofer | |
| 00:20 | • Open ticket [729692ffff]. artifact: 90278425a2 user: hobbs | |
|
2004-03-30
| ||
| 23:38 | • Closed ticket [729692ffff]. artifact: 24b437a22f user: msofer | |
| 22:49 | • Ticket [729692ffff]: 4 changes artifact: 542ac3e2dd user: dgp | |
| 19:57 | • Ticket [729692ffff]: 4 changes artifact: 488000ac5a user: dkf | |
| 18:24 | • Ticket [729692ffff]: 4 changes artifact: 415cb5a515 user: msofer | |
| 18:20 | • Ticket [729692ffff]: 4 changes artifact: f03e7051e2 user: msofer | |
| 16:43 | • Ticket [729692ffff]: 4 changes artifact: b357d0cb70 user: dkf | |
| 16:24 | • Ticket [729692ffff]: 4 changes artifact: f8ac11a84d user: msofer | |
| 15:08 | • Ticket [729692ffff]: 4 changes artifact: 1ba3595ec7 user: dkf | |
| 07:56 | • Ticket [729692ffff]: 5 changes artifact: c1a2dd5140 user: msofer | |
| 07:43 | • Ticket [729692ffff]: 4 changes artifact: d08a9f5f22 user: msofer | |
| 07:43 | • Add attachment tclbench to ticket [729692ffff] artifact: 6c6e16303f user: msofer | |
| 07:41 | • Ticket [729692ffff] redef of bcc'ed commands inoperant in current bcode ... artifact: f2e2c1b5ef user: msofer | |
| 07:41 | • Add attachment 729692.patch to ticket [729692ffff] artifact: 8812701ec8 user: msofer | |
| 03:46 | • Ticket [729692ffff] redef of bcc'ed commands inoperant in current bcode ... artifact: 3d620c52f5 user: dkf | |
| 03:45 | • Ticket [729692ffff]: 5 changes artifact: a579529000 user: dkf | |
| 01:10 | • Ticket [729692ffff]: 4 changes artifact: 00107cd377 user: msofer | |
|
2004-03-29
| ||
| 10:22 | • Ticket [729692ffff]: 4 changes artifact: fb9e336bc2 user: msofer | |
| 10:22 | • Ticket [729692ffff]: 5 changes artifact: 5639baee18 user: msofer | |
|
2004-03-10
| ||
| 21:02 | • Ticket [729692ffff]: 4 changes artifact: 233139294e user: msofer | |
| 18:54 | • Ticket [729692ffff]: 4 changes artifact: b9e627a3c0 user: dkf | |
| 07:21 | • Ticket [729692ffff]: 4 changes artifact: b514851606 user: msofer | |
| 05:16 | • Ticket [729692ffff]: 4 changes artifact: d72003d536 user: dgp | |
|
2003-11-16
| ||
| 06:24 | • Ticket [729692ffff]: 5 changes artifact: 7dfbb3e024 user: msofer | |
|
2003-11-13
| ||
| 14:22 | • Ticket [729692ffff]: 1 change artifact: 015e3db59e user: rmax | |
| 08:40 | • Ticket [729692ffff]: 1 change artifact: 4ada6d7783 user: dgp | |
|
2003-04-29
| ||
| 16:27 | • New ticket [729692ffff]. artifact: 383c16ddb2 user: rmax | |
redef of bcc'ed commands inoperant in current bcode
Closed / Fixed729692ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 22 years ago
Descriptionplain2003-04-29 16:27:44
The following piece of code doesn't work as expected
due to the empty proc body optimization that went into
Tcl 8.4.
proc bar args {}
proc main {} {
proc bar args {puts "this is bar"}
bar
}
main
While this example is artificial, I stumbled over this
bug in a situation where a (formerly empty) proc got
redefined through by
namespace import -force
and invoked immediately afterwards, all within the same
arm of a switch statement. So it took me some time (and
the help of fellow Tcl'ers on the chat) to find out
what's going on.
dgp Ticket [729692ffff]: 1 change
[History diff]2003-11-13 08:40:17
rmax Ticket [729692ffff]: 1 change
[History diff]2003-11-13 14:22:44
msoferplain2003-11-16 06:24:32
Logged In: YES
user_id=148712
Not much that we can do about that? This is really a
fundamental bug in the bytecode model: once a bytecode is
running, it can't be modified.
In your example, changes to bytecompiled commands called
from within main's body will not affect main while it is
running. Another example is
proc tst {} {
rename set _set
proc set args {puts GOTCHA}
set x 1
rename set {}
rename _set set
}
Running tst the new definition of 'set' will be ignored,as
it was bytecompiled.
dgpplain2004-03-10 05:16:10
Logged In: YES user_id=80530 OK, this may go nowhere, but here's a thought. We have epoch counters that tell us whether we need to recomile a whole unit of bytecode before executing it. Some bytecode execution can increment the epoch counter. Can't we check for an increment after we execute those bytecodes, and if we see one, abandon bytecode execution and switch over to direct string evaluation? (leaving any recompile for the next evaluation of the whole bytecode unit) Is this merely difficult, or fundamentally impossible?
msoferplain2004-03-10 07:21:25
Logged In: YES user_id=148712 This is very similar to bug 495830, at least in its causes. The general solution could well involve defining a new bytecode for either 'command start' or 'command end' that checks for (interp validity, epochs, ...) and switches to direct string evaluation in exceptional cases.
dkfplain2004-03-10 18:54:44
Logged In: YES user_id=79902 I think we're not talking 'impossible' but rather 'exceptionally difficult' and possibly even 'impossible with the current bytecode engine'. The nub of the problem is what happens if you redefine [while] inside a [while] loop and then try to call that redefined [while] while still executing that loop. You have to be able to invalidate sections of bytecode and replace them with bytecodes of potentially different length without invalidating the outer bytecodes which are still in use (change those and you're also altering the semantics of Tcl, and it's a non-trivial change at best.)
msoferplain2004-03-10 21:02:59
Logged In: YES
user_id=148712
Idea - but may be costly in runtime. Define INST_START_CMD
and INST_END_CMD. Let the bc engine have two states:
- normal N: execute bytecodes
- exceptional E: find next command from the source,
interpret it
State N:
INST_START_CMD: check epoch; if ok do nothing, else
switch state to E and rexec INST_START_CMD
INST_END_CMD: a noop
State E:
INST_START_CMD: find in the sources the command
corresponding to the next command; interpret it and push its
result on the stack; jump to the instruction after the
corresponding INST_END_CMD
INST_END_CMD: a noop
It can possibly be made marginally more efficient (in the
sense of it being less costly in state E). But I do think
this approach could work. Feedback?
msoferplain2004-03-29 10:22:02
Logged In: YES user_id=148712 Enclosed a tentative patch for review; more test cases needed. Note that this also fixes [Bug 495830].
msoferplain2004-03-29 10:22:04
File Added - 81711: 729692.patch
msoferplain2004-03-30 01:10:21
File Deleted - 81711: File Added - 81782: 729692.patch Logged In: YES user_id=148712 Fixed patch to work correctly with precompiled scripts - the new instruction is effectively a noop for them.
dkfplain2004-03-30 03:45:03
Logged In: YES user_id=79902 It all looks like a good patch to me taking a good route to solve the problem, but I can't test ATM because of the other things I've got cooking in various sandboxes; I assume that the updated test suite works?
dkf Ticket [729692ffff]: 1 change
[History diff]2004-03-30 03:46:31
msoferplain2004-03-30 07:41:52
File Deleted - 81782: File Added - 81838: 729692.patch Logged In: YES user_id=148712 Slightly modified patch and tclbench results attached. The patch produces a small overall slowdown in the whole benchmark suite. Bytecode intensive tests are noticeably slowed down: 5-10% (loops, base64, klist, list iterate, ...) with two bad ~15-20% cases (sha1, heapsort).
msoferplain2004-03-30 07:43:03
File Added - 81839: tclbench
msoferplain2004-03-30 07:56:21
Logged In: YES
user_id=148712
Note that this patch introduces a new bug that requires
fixingbefore applying:
while 1 {}
does not check for asyncs.
dkfplain2004-03-30 15:08:30
Logged In: YES user_id=79902 An idea that occurred to me is that we should not issue this instruction multiple times in a row (currently possible when compiling a command whose argument is itself a compiled command) since the first instance will more than adequately protect all subsequent ones. On the other issue: Perhaps we need a counter to do the asynch stuff that is reset when a startcmd instruction is processed? We could make the counter have a relatively long period, of course, so only very evil BC loops would have any danger of hitting it.
msoferplain2004-03-30 16:24:32
Logged In: YES user_id=148712 I was actually thinking of compiling an INST_START_CMD into every empty loop body. Any downside to that?
dkfplain2004-03-30 16:43:09
Logged In: YES user_id=79902 Hmm. If the target was the next instruction, that'd be OK. However, we'd also need to be careful to only do this in the case when the body was empty (or at least empty of bytecodes). In the non-empty case, the body's own startcmds would be better. Without this particular niggle, I think it would be fairly easy to add the extra information to the compileenv to help generate only minimal numbers of startcmds, which would probably help with the speed.
msoferplain2004-03-30 18:20:18
Logged In: YES user_id=148712 The minimisation of INST_START_CMDs (ISC) looks to me like (yet another) job for a post-compile optimiser. In general, if there are two ISCs such that: (a) there is no intervening jump or jump target (including the second ISC) (b) there is no intervening invocation or variable access (in TEBC terms: instructions that do not DECACHE_STACK_INFO) then the second ISC can be effectively eliminated.
msoferplain2004-03-30 18:24:56
Logged In: YES user_id=148712 (Topic now changed to discussion of the patch ... OT for the bug ticket? Should I rather open a patch ticket?) Further possible usage for ISC (assuming no redundancy elimination): enabling of command tracing in bcc'ed code.
dkfplain2004-03-30 19:57:46
Logged In: YES user_id=79902 We need to work out what duties the ISC serves and optimise it for that. The more it does, the less it can be optimised.
dgpplain2004-03-30 22:49:54
Logged In: YES user_id=80530 I'm all in favor of making further improvements, but how about committing the fix we have to the HEAD?
msoferplain2004-03-30 23:38:44
Logged In: YES user_id=148712 Patch committed; we'll improve on it during alpha if necessary. New bug item for the missing async checks during empty loops.
hobbsplain2004-03-31 00:20:27
Logged In: YES user_id=72656 IMO this patch should be reversed if miguel's slowdown numbers are accurate. This was a known issue, and is a pathological case that is acceptable when documented. It's not acceptable to take up to a 10% slowdown for the core just to support this.
msoferplain2004-03-31 01:10:38
Logged In: YES user_id=148712 Closed again - performance bug 926164 now open.
msoferplain2004-09-22 22:48:39
Logged In: YES user_id=148712 The fix has been corrected; it was wrong whenever the newly-interpreted script returns TCL_BREAK or TCL_CONTINUE.
Log in (anonymous is fine) to add a comment.
Attachments:
- tclbench [download] added by msofer on 2004-03-30 07:43:03. [details]
- 729692.patch [download] added by msofer on 2004-03-30 07:41:52. [details]