Monday, January 26, 2009

partcl progress, January 2009

Keeping up with parrot

Lots of commits this month to keep up with changes in parrot trunk; a recent push in that project to finally remove some items marked as deprecated forced me to finally update our code. This should make things go more smoothly once parrot declares a 1.0 release.

There is one regression in our core tests at the moment due to a recent change in how parrot handles attributes on PMCs. (C-level data structures resembling objects). 

[Trace]? Not yet

I added a basic version of trace that allowed us to parse several specification tests that we previously were unable to; However, the simple version of [trace] involved invoking the tcl compiler with an [uplevel] command (which in turn, invokes the tcl compiler...) on every read access of a traced array; this resulted in about a 4x slowdown in the test suite, so I had to back it out. As we see speedups in other areas, it should be possible to re-enable this.

Run init.tcl

Grabbed a copy of init.tcl from the tcl repository (updating to target 8.5.6 while I was at it.). We are now running this on interpreter startup, and getting a few things for free that we had to roll our own for in the past. The biggest remaining thing is to get [unknown] dispatch working to use the unknown defined here. [auto_load] and friends are now working; unknown support is the last stop to getting several builtins written in tcl automatically loadable.

[array startsearch]

Parrot has had iterators for quite some time, and I finally got around to making them accessible to tcl. The implementation for here involved converting the C-based TclArray data structure (which was a simple extension of a parrot Hash) into a PIR-based version. The PIR based code makes it much easier to add per-instance attributes, include information to track open iterators. 

The only remaining bit to fix is how we reuse the named iterators: start 2 searches; kill the last one; start a new search - the name for that in partcl is off by one from the expected name in Tcl.

Convert TclList?

The relative ease of converting TclArray (combined with a suspicion that this would speed up partcl), led me to try to convert the C code for managing lists to PIR as well. The resulting code is much cleaner (PIR doing a lot of the lifting for us).

However, the conversion didn't go smoothly. PIR subclasses of C-based PMCs are not fully equivalent; I never did get all tests passing after the conversion even with some workarounds in place, and one of the tests that did pass did not run appreciably faster. So that work in progress was discarded.

I was somewhat disappointed to find that there were issues with the PIR subclasses, but was sure to report them back to the parrot project as issues to be tracked.

Note to self: Seriously, stop trying to make things go faster if you don't have a profiler. It's not going to be worth it.

Fix stringification of (some) lists

The Tcl spec test "list.test" was aborting before printing out the results, meaning we couldn't count several passing tests. Tracked this down to two edge cases of stringification of lists elements that we got wrong. There are more, but these two prevented successful execution of the tests. Added them to partcl's core tests to avoid regressions; that's another 64 passing spec tests that we can now count.

$ ./tclsh
% list "{ab}xy" "{ab}\\"
{{ab}xy} \{ab\}\\


Review Tests

Went through the list of skipped tests and found a few that were able to be re-instated. As always, our spec test progress is visible, along with current stats on various .test files. Since last month's posting, we're passing another few hundred tests.