Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-07-24
06:22 • Closed ticket [1953758fff]: CONCAT1 of ByteArrays plus 6 other changes artifact: cf987bb48f user: ferrieux
2008-06-30
06:24 • Ticket [1953758fff]: 4 changes artifact: 7630b6d853 user: ferrieux
2008-06-29
16:06 • Add attachment binconcat2.patch to ticket [1953758fff] artifact: e14f407439 user: ferrieux
16:06 • Ticket [1953758fff] CONCAT1 of ByteArrays status still Open with 4 other cha... artifact: bcabc8befb user: ferrieux
2008-06-28
22:47 • Ticket [1953758fff]: 5 changes artifact: af060562c9 user: msofer
01:46 • Ticket [1953758fff]: 4 changes artifact: cdc4e6f4e2 user: dgp
2008-04-29
15:56 • Ticket [1953758fff]: 5 changes artifact: e258cc52ab user: ferrieux
06:47 • Add attachment binconcat.patch to ticket [1953758fff] artifact: 4930ea989a user: ferrieux
06:47 • Ticket [1953758fff] CONCAT1 of ByteArrays status still Open with 4 other cha... artifact: 4d4336dab5 user: ferrieux
2008-04-28
23:47 • New ticket [1953758fff]. artifact: 0dea7d7485 user: ferrieux

CONCAT1 of ByteArrays

Closed1953758fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 18 years ago
Descriptionplain2008-04-28 23:47:33
So far, the CONCAT1 instruction goes through the string reps of all objects, even when all are byte arrays. This compromises performance in heavy byte-juggling code since it means converting back and forth to UTF-8. This is odd since [string range] et al. do have an optimization for the byte array case.

The attached patch (against 8.5.1) fixes that, by first looping through all to-be-concatenated objects to check whether they are all byte arrays (or empty strings).
In that case, all operations are done at byte array level, while keeping the very same logic regarding in-place operation if possible (unshared first object).

Moreover, the inclusion of the empty string case allows for the "K-free K" idiom $x[set x {}], which in the end allows the following in-place byte array growing operation:

      set x $x[set x {}]$y

Test suite OK, and stepped through gdb to check most branches.
ferrieuxplain2008-04-29 06:47:35
File Added - 276219: binconcat.patch
ferrieuxplain2008-04-29 15:56:40
Logged In: YES 
user_id=496139
Originator: YES

Miguel, reassigning this to you on Donal's advice.
Hope you don't mind :-}
dgpplain2008-06-28 01:46:25
Logged In: YES 
user_id=80530
Originator: NO


when applied to HEAD, the compiler has
some gripes about this patch:

/home/dgp/cvs/tcl/unix/../generic/tclExecute.c: In function ‘TclExecuteByteCode’:
/home/dgp/cvs/tcl/unix/../generic/tclExecute.c:2221: warning: pointer targets in assignment differ in signedness
/home/dgp/cvs/tcl/unix/../generic/tclExecute.c:2224: warning: pointer targets in assignment differ in signedness
/home/dgp/cvs/tcl/unix/../generic/tclExecute.c:2230: warning: pointer targets in assignment differ in signedness
/home/dgp/cvs/tcl/unix/../generic/tclExecute.c:2244: warning: pointer targets in assignment differ in signedness
msoferplain2008-06-28 22:47:49
Logged In: YES 
user_id=148712
Originator: NO

This looks OK for commit to HEAD after fixing those warnings; Alex, please do. 

It would be nice to insure that the testsuite covers any possible gotcha, eg different combinations of concat'ing bytearrays, empties and other things at first/other places.

It'd be also nice to check if tclbench will expose the improvement, and to write a small bench to include there if not.
ferrieuxplain2008-06-29 16:06:58
File Added - 283079: binconcat2.patch

Logged In: YES 
user_id=496139
Originator: YES

Thanks for the green light.

The just attached update fixes the warnings.
FWIW, these warnings don't appear with msys/mingw, based on gcc 3.4.2.
Maybe you compiled on unix with a more modern gcc ?

Will now do my fist solo flight with non-anon cvs :-)
File Added: binconcat2.patch
ferrieuxplain2008-06-30 06:24:07
Logged In: YES 
user_id=496139
Originator: YES

Committed to HEAD.
Will now prepare test and tclbench cases.
ferrieuxplain2008-07-24 06:22:27
Logged In: YES 
user_id=496139
Originator: YES

Test suite updated with a relative speed test (detect overhead of conversions).
Log in (anonymous is fine) to add a comment.

Attachments: