Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-05-17
00:32 • Add attachment expand-inplace-commit.patch to ticket [842446ffffffffff|... artifact: dc6cbf5f06 user: msofer
00:32 • Ticket [842446ffff] {expand} bcc alternatives status still Closed with 4 oth... artifact: 443c8346dc user: msofer
00:32 • Closed ticket [842446ffff]. artifact: 9564008938 user: msofer
2004-02-03
23:35 • Ticket [842446ffff]: 4 changes artifact: d3774ae7c6 user: dkf
2003-11-22
20:24 • Add attachment expand.bench to ticket [842446ffff] artifact: 0b8017a3c2 user: msofer
20:24 • Ticket [842446ffff] {expand} bcc alternatives status still Open with 4 other... artifact: 229180e5bb user: msofer
20:21 • Ticket [842446ffff]: 4 changes artifact: cbce20ced2 user: msofer
20:21 • Add attachment expand.result to ticket [842446ffff] artifact: c089eb1964 user: msofer
20:21 • Ticket [842446ffff] {expand} bcc alternatives status still Open with 4 other... artifact: 14ff4b075a user: msofer
08:36 • Ticket [842446ffff]: 4 changes artifact: 9e1acce1a0 user: msofer
08:35 • Ticket [842446ffff]: 4 changes artifact: ef3f9848c7 user: msofer
07:56 • Ticket [842446ffff]: 4 changes artifact: f3e75ba5bf user: msofer
07:54 • Ticket [842446ffff]: 4 changes artifact: 6ab84c6d18 user: msofer
2003-11-20
05:42 • Ticket [842446ffff]: 4 changes artifact: 391bff9c32 user: msofer
05:42 • Add attachment expand-inplace.patch to ticket [842446ffffffffff|842446f... artifact: ddf6a0a3c9 user: msofer
05:41 • Ticket [842446ffff] {expand} bcc alternatives status still Open with 4 other... artifact: c2d5c51603 user: msofer
05:41 • Ticket [842446ffff]: 4 changes artifact: f55ad857db user: msofer
05:41 • Add attachment expand-list.patch to ticket [842446ffffffffff|842446ffff... artifact: 640b047ff8 user: msofer
2003-11-18
05:55 • Ticket [842446ffff] {expand} bcc alternatives status still Open with 4 other... artifact: 49f4f6cc28 user: msofer
05:55 • Ticket [842446ffff]: 4 changes artifact: b462f24b48 user: msofer
03:27 • Ticket [842446ffff]: 4 changes artifact: 768ff01c1c user: msofer
03:27 • Ticket [842446ffff]: 4 changes artifact: 7143a84c86 user: msofer
03:04 • Ticket [842446ffff]: 4 changes artifact: 29202333fa user: dgp
03:02 • Ticket [842446ffff]: 6 changes artifact: d74f42c6ca user: dgp
2003-11-17
06:21 • Ticket [842446ffff]: 4 changes artifact: d874f4b4ec user: msofer
03:22 • Ticket [842446ffff]: 4 changes artifact: e6d101dfd9 user: dkf
2003-11-16
01:33 • Ticket [842446ffff]: 5 changes artifact: 1e9bef02eb user: msofer
2003-11-15
05:24 • Ticket [842446ffff]: 4 changes artifact: e0f8f9f93e user: msofer
2003-11-14
22:24 • New ticket [842446ffff]. artifact: 9ed480c13f user: msofer

{expand} bcc alternatives

Closed / Accepted842446ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-11-14 22:24:02
Enclosing an alternative implementation for the
bytecoded {expand} functionality - this is the update
of tip157.patch.2 of [Patch 827119]. It builds the
expanded command as a list at stacktop,instead of
expanding into the stack (or malloc'ed mem if not
enough stack present).

This is likely to be slower than the version in HEAD in
the worst case (more ckalloc and copying), but it is
somewhat simpler:
  - no instructions with variable number of operands
  - the maximal stack required by the bytecode is still
known at compile time
msoferplain2003-11-15 05:24:02
File Added - 67546: expand-list.patch
msoferplain2003-11-16 01:33:07
File Added - 67604: expand-inplace.patch

Logged In: YES 
user_id=148712

Attached expand-inplace.patch that expands directly to the
stack, without copying non-expanded arguments. The execution
stack is grown at run time if it is not large enough to
accomodate this command.
It is simpler IMHO than the implementation at HEAD, and
should be slightly faster too. It does not require
instructions with variable number of arguments (+).
Assigned to dgp for comment.
dkfplain2003-11-17 03:22:56
Logged In: YES 
user_id=79902

expand-inplace.patch is faster than HEAD on short expansions
but blows up when built with --enable-symbols=all due to
failing the max-stack-depth check.

expand-list.patch is slower than HEAD on short expansions,
and like the HEAD it is safe with --enable-symbols=all

Test code used for this evaluation:
   proc foo args {llength [list {expand}$args]}
msoferplain2003-11-17 06:21:40
File Deleted - 67604: 



File Added - 67706: expand-inplace.patch

Logged In: YES 
user_id=148712

Inplace patch revised: better stack estimation, fix for
compile-debug that bypasses the stack depth check when an
expansion is in progress.
dgpplain2003-11-18 03:02:56
Logged In: YES 
user_id=80530


looks like it should work.
dgpplain2003-11-18 03:04:55
Logged In: YES 
user_id=80530

BTW, the expandLinkList
declaration is in the wrong place.
msoferplain2003-11-18 03:27:29
Logged In: YES 
user_id=148712

who put it there?
msoferplain2003-11-18 03:27:30
File Deleted - 67706: 



File Added - 67792: expand-inplace.patch
msoferplain2003-11-18 05:55:48
Logged In: YES 
user_id=148712

Updated expand-inplace, corrected compile time stack depth
estimation:
  - fix thread-safety (spotted by dkf)
  - added detailed comments
msoferplain2003-11-18 05:55:49
File Deleted - 67792: 



File Added - 67809: expand-inplace.patch
msoferplain2003-11-20 05:41:13
File Added - 68031: expand-list.patch
msoferplain2003-11-20 05:41:14
File Deleted - 67546:
msoferplain2003-11-20 05:42:12
File Deleted - 67809: 



File Added - 68032: expand-inplace.patch

Logged In: YES 
user_id=148712

Patches updated so that they apply to HEAD
msoferplain2003-11-22 07:54:23
File Added - 68266: expand.result

Logged In: YES 
user_id=148712

Attached a benchmark script and timing results: results show
that
  - t(list) < t(inplace) < t(eval) < t(head)
        for [{expand}$cmd] (resp. [eval $cmd])
  - t(inplace) < t(head) < t(list)
       for [cmd A {expand}$lst B]
msoferplain2003-11-22 07:56:21
File Added - 68267: expand.bench
msoferplain2003-11-22 08:35:39
File Deleted - 68266: 



File Added - 68268: expand.result

Logged In: YES 
user_id=148712

Oops - that was a wrong benchmark, not measuring much.
Updated files,not definitive yet.

The results are similar - except that both head and inline
show nonlinear behaviour in the list size.
msoferplain2003-11-22 08:36:56
File Deleted - 68267: 



File Added - 68269: expand.bench
msoferplain2003-11-22 20:21:28
Logged In: YES 
user_id=148712

New, expanded benchmark. Summarizing the results when
expanding lists of up to 10 elements (typical case?):
H: HEAD, I: Inplace, L: list, timings in usecs/call:
- for [{expand}$cmd]:  H7, I6, L5 (pure list opt: 6)
- for [$cmd A {expand}$lst B]: H7, I6, L9
- as before, but A and B longer expanded lists: H18, I15, L22
Amazingly, the list version seems to be faster when
expanding long lists (100 to 1000 elements).

Given the very slight differences, I'm inclined to opt for
the list-based version: it is much simpler and it does not
interfere with the evaluation stack mechanics. Other opinions?
msoferplain2003-11-22 20:21:29
File Deleted - 68269: 



File Added - 68306: expand.result
msoferplain2003-11-22 20:24:45
File Added - 68307: expand.bench
dkfplain2004-02-03 23:35:59
Logged In: YES 
user_id=79902

Speed vs. Simplicity?  Err, hard choice.
msoferplain2004-05-17 00:32:09
Logged In: YES 
user_id=148712

Committed the inplace version while still in alpha -
committed path attached.

The advantages are:
  - faster
  - no changes to INST_INVOKE(1|4)
  - simpler compilation code
  
Another difference, with pros and cons, is that the
execution stack is grown when needed, instead of allocating
a temporary buffer. Pro: faster execution  for subsequent
{expand}, where the probability of not having enough stack
is lower. Con: memory is allocated forever after, not
returned to the OS.
msoferplain2004-05-17 00:32:10
File Added - 87354: expand-inplace-commit.patch
Log in (anonymous is fine) to add a comment.

Attachments: