Thursday, December 10, 2009

partcl-nqp


pmichaud and I and a few others are trying out the latest parrot compiler tools to see if we can create up with a version of partcl that is more maintainable, and will benefit more directly from toolchain improvements that target rakudo (Perl 6 on parrot) and other languages.

The base tool for this is NQP-rx; it's a small compiler for a subset of Perl 6 that targets PIR; It provides a much improved syntax over PIR, even when calling PIR itself - it provides a lot more sugar.

This means that nearly all of the handrolled PIR that was created is no longer needed. There are few cases where it is, and that is pushing development of NPQ-rx so that we can eliminate that PIR and rewrite it NQP.

Currently, there are currently two NQP-rx grammars, one for the language itself, and one for the tcl-specific regular expression language (ARE).

While the ARE is a work in progress (bits are added as needed to pass tests), adding this at all would have been very painful in old partcl (which currently relies on the perl5-like expression engine available via PGE in parrot.) We'll be adding more grammars for globbing, and probably the [format] and [binary] mini-languages as well.

The builtins (that are done) are now all written in NQP - and not having to write them in assembly (even macro'd assembly) makes them much shorter, easier to understand and maintain.

Big Goals:
  1. pass all the tcl based tests written for partcl (Already running 12 of the original all-tcl tests)
  2. start running the spec tests again.
  3. pass almost as many spec tests as partcl...
At which point this new version will become the primary version.

If you're interested in Tcl, parrot, or Perl 6, check us out. There are plenty of small bits of NQP that can be written, and I'd be happy for the help. If you know Tcl but not Perl 6, or Perl 6, but not Tcl, doesn't matter, you can contribute. ^_^


Saturday, October 24, 2009

partcl now passing 4,089 spec tests

With the cleanup of several segfaults in parrot and some recent improvements to ::tcl::mathop, partcl is now passing over 4K of the official 8.5.6 test suite!

That leaves expr.test as the last big source of potentially passing tests that aren't being counted; 347 tests in that file pass before an error due to promotion to bigints causes the file to abort.

Special thanks to moritz for providing CPU cycles for testing.

svn2git

I've moved the repository from svn hosted at googlecode to git at github.

Thanks to dukeleto at parrot.org for doing the heavy lifting on the repository migration.

For now, everything else is staying at googlecode, and I have a pointer on the main page to the github repo.

I had been using git-svn for a while to interact with the old svn repo, and while I really loved the git-like features it provided, there were enough annoyances with git-svn that making the full switch makes development easier for me.

Also, it might encourage Matt to commit some fixes. =-)

Tuesday, September 1, 2009

Now passing 3,363 tcl spec tests

Immediately after parrot 1.5.0 was released, many branches were merged back into trunk, which temporarily disrupted our ability to run the spec test suite.

Thanks to NotFound++ on the parrot team, all of these new failures have been resolved, and we're now able to run the spec test suite again!

Since the speed of partcl has improved a little since we started tracking spec test results, and to give future segfaults more of an opportunity to present themselves, we're now running every file in the test suite that runs to completion (even if they're all skipped).

With various advancements, and a lack of (random) segfaults, we're now running more test files and passing more tests than ever:

Previous High: Files 67 Total 5145 Passed 2972 Skipped 1352 Failed 821 Time: 4374s
Current: Files 93 Total 7397 Passed 3363 Skipped 1989 Failed 2045 Time: 6651s

There are still a few segfaults (but these are repeatable) and out of memory errors remaining, and they're on files with a relatively large set of already passing tests; getting those to run to completion will give us another big bump on the numbers.

Saturday, June 27, 2009

Improved interactive mode

In real tcl, you can use interactive mode to run commands like a shell; There's now just enough logic in partcl to do this as well.

Most of the infrastructure for this was already in place; just added a minimal version of
  • [file executable] - only checks executable status for other, not group or owner.
  • [file split] - isn't windows-friendly, nor does it deal with potentially confusing chars like '~'
  • [exec] - ignores all of the shell metachars and just invokes parrot's spawnw opcode as is.

$ ~/bird/bin/parrot tcl.pbc
% ls src
binary.c binary.h binary.o class grammar macros.pir mathops.pir ops pmc returncodes.pasm tclsh.pir

% rm src/binary.o

% ls src
binary.c binary.h class grammar macros.pir mathops.pir ops pmc returncodes.pasm tclsh.pir


Most of the heavy lifting is done by init.tcl from the standard library.

Friday, June 12, 2009

Partcl now passing 2,972 tcl spec tests

Thanks to prompting from kbk on irc (#tcl at freenode), I finally fixed the parsing of string.test.

It had been complaining about the \udead escape in that file; That isn't really a valid codepoint, and while Tcl accepts it as if it were, parrot (which uses ICU internally) throws an exception when trying to create a string that contains it. So, (at kbk's suggestion), I settled for now to convert any codepoints in the \udead range to \ufffd. That allowed the test to parse...

... but it then ran out of memory, as several other tests have been doing since I started running the tests again.

I've been working with chromatic to try to provide test cases to show where the memory leaks have been coming from, but I've only been going after things I could spot with valgrind. Today, someone on irc (#parrot at irc.parrot.org) posted a very small sample program that eventually ran out of memory... because the garbage collector apparently wasn't.

The small PIR example allowed chromatic to identify and fix that issue in parrot, and partcl has now reclaimed several files which had been exhausting a 1/2 gig of memory.

Current results, over 67 test files that run to completion:

Total 5145 Passed 2972 Skipped 1352 Failed 821

That's the highest number of attempted & passing tests since I started keeping track. It's an additional 1181 passing since the 8th, when I started running the spec tests again.

Monday, June 8, 2009

SpecTest updates

It's been about 4 and a half months since the last "official" spec test run -- partcl was offline for most of that time.

I've finally caught back up with parrot development, can build against svn-latest, an installed parrot, have added a few minor features.

We've lost several files (See http://code.google.com/p/partcl/wiki/SpecTestStatus). I'm running the tests on a machine with a 0.5G ram limit - previously these were running on a machine with no virtual memory limit, so they'd be able to complete. I've opened a ticket with the parrot developers for the biggest parrot memory leak I was able to find with a "hello word" in partcl (See https://trac.parrot.org/parrot/ticket/732). Hopefully they can get that and some other leaks closed.

So, since a lot has changed (including the hardware) between those last two runs, there's not much to compare directly. I'll try to get more, regular updates going forward.

Edit: Actual Spectest results

Monday, June 1, 2009

NaN support

Now that partcl is passing all tests again, took some time over the weekend to add NaN support.

NaN now parses in expressions, and is represented in bytecode as a TclFloat PMC with a value of NaN; most of the operators and functions now [error] appropriately when presented with NaN as an argument; all the partcl tests for NaN are un-skipped and passing.

Thursday, May 28, 2009

Working again after parrot 1.0

Partcl once again builds against parrot (tested against r39220), and passes everything in 'make test'!

While there haven't been any functional changes since the last post, we are now building against an installed parrot; that involved quite a few changes to partcl's build process.

There have also been some incompatible parrot changes since last we built; we're now tracking all of those changes.

Once parrot 1.3 is released, we can switch to just building against an installed monthly release of parrot!

Thanks to allison, Infinoid, NotFound, pmichaud, and cotto from #parrot for their fixes to both partcl and parrot to get us afloat again.

Thursday, March 12, 2009

Distracted, but still here.

I've been working with the core parrot team trying to get as much in order as possible for the upcoming 1.0 release.

Once that release is out the door, I'll come back and make sure that we have a version of partcl that runs against parrot 1.0.

-Coke

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.


Sunday, December 21, 2008

some headway

After spending some time just treading water with parrot updates, we've made some headway against the spec tests, which is nice. ^_^

Thanks to dgp on #tcl on freenode for his suggestion for a stub for [interp alias] that let us run basic.test to completion!

We regressed on  compile.test with the recent updates, but added five more spec test files that run to completion. That's 320 more passing tests, include a few extras in already completing files.

I also tracked down the expected boolean value but got "" error that is blocking many of the spec tests from running any tests; turns out that the constraint framework in tcltest.tcl (which helps determine if a given test in the file should be run or not) requires a minimal version of [trace] in order to work. Pulling at this thread, the trace refers to [namespace code], which means we also need [namespace inscope] ; I have a work in progress on each of these, but it's not quite ready for checkin. Thanks to pmichaud on #parrot for some thoughts on how trace (or tie in p5) might work on parrot.

Thursday, December 18, 2008

Speedups since parrot 0.8.1

I got partcl's trunk working with parrot's trunk again, catching up with some changes in parrot that we couldn't deal with because of segfaults we were seeing.

With the updates, 'make test' now passes again in trunk, and 'make spectest' completes, giving the same results it did against 0.8.1; Here's a snippet from our progress tracker:

"date","revision","parrot revision","files","test","pass","fail","skip","time in seconds"
"2008-11-19 12:51",159,"v0.8.1",57,4001,2341,1059,601,12550
"2008-12-18 12:15",195,"r34059",57,4001,2341,1059,601,9232

So, with no functional changes, we've gone from 3.5 hours to run the tests to 2.6 hours. Which is still terribly slow, but down from horrifically slow.

I've also identified a parrot segfault that is blocking completion of the spec test "expr-old.test"; which would get us at least 254 more passing tests. This particular segfault is also impacting rakudo perl, so hopefully between the two of us we can get a small test case for core parrot developers to resolve the issue.

Wednesday, December 17, 2008

Not just for developers anymore?

When we moved partcl out of parrot's svn repository, one of the goals was to target a stable version of parrot so that we could work without having things break underneath us. (One of the reasons I'm looking forward to parrot 1.0.); I've ended up turning this requirement sideways a bit: I want a stable version for users of partcl (All 1.2 of you.)

I've now created a "stable" branch of the partcl svn repository that tracks a released version of parrot (currently 0.8.1). The download instructions for partcl now show you how to get a combination of parrot & partcl that work together.

Hopefully after every parrot release, we'll be able to update our stable branch to track it. Unfortunately, due to some issues that cropped up near the end of the 0.8.2 development lifecycle, we missed that release.

I'd definitely be interested in feedback, especially from folks that use tcl on a regular basis.

Monday, November 10, 2008

October 2008 roundup

Just a brief update…

Done a bit of work since the last post, fixing up as many blockers as possible running the spec test; Current status is available on the wiki. Short version: 2182 passing tests.

Eliminated some unused code, added minor cleanups and a bit of new functionality still hidden by the aforementioned blockers. Got partcl working with parrot 0.8.0, and then rapidly depending on a newer svn revision. Convinced Matt Diephouse to write some code (yay!), got a patch from julian notfound to fix the build using C++, and some documentation updates from Jerry Gay.

partcl, while not taking advantage of the Parrot Compiler Toolkit (PCT), still uses the Parser Grammar Engine (PGE) heavily† - looks like a recent Hague grant to Patrick Michaud from The Perl Foundation will provide some speedups to PGE, which in turn can only make us go faster. 


† You can see this by using the -t4 option to parrot (trace subroutines) and running any small tcl program, even ../../parrot -t4 tcl.pbc -e "puts hi"  and sorting through the output.

Tuesday, October 7, 2008

Leaving the nest...

I've just moved partcl's main development repository into our googlecode repository.

If you're interested in contributing, check out our googlecode wiki.

This should help with parrot's 1.0 goals regarding installation, as well as give partcl a slightly more stable development environment.

I've created two mailing lists:
  • partcl-commits: announce only: wiki and svn commit diffs are sent here.
  • partcl-dev general dev discussion and ticket updates.
 

Tuesday, September 30, 2008

Spec Test Status

Added a wiki page to the googlecode site:

http://code.google.com/p/partcl/wiki/SpecTestStatus

This document will track the issues with the various spec tests. If you're interested in contributing to partcl, helping keep this list updated would be very helpful; just need to be able to run the tests and see how each test ends.

Monday, September 29, 2008

Running tcl's official test suite...

(this post rehashes some content found at the old blog.)

With recent updates, partcl can now use the tcltest.tcl library that comes with tcl 8.5.4 [1]

For some time, partcl has been limping along with our hand-rolled Test::More analog on a slightly processed version of tcl's .test files [2]. This generated TAP output, and was amenable to running via the standard perl testing tools.

The current version of 'make spectest' is processing the raw .test files from the CVS repository. [3] tcl's test output format isn't TAP [4] but it's easily understood: output is bad. Here's a clean run with partcl of a single test file.

$ ./tclsh t_tcl/llength.test
llength.test: Total 6 Passed 6 Skipped 0 Failed 0

Here's some output from a failing test for comparison - we haven't implemented [case] in partcl because it's deprecated, so our failure mode here doesn't match the spec.

==== case-3.3 single-argument form for pattern/command pairs FAILED
==== Contents of test case:
    list [catch {case z in {a 2 b}} msg] $msg
---- Result was:
1 {invalid command name "case"}
---- Result should have been (exact matching):
1 {extra case pattern with no body}
==== case-3.3 FAILED

It will also report on differences in return value, making it very obvious what needs fixing from the development side. For example, This allowed me to easily update some exceptions being thrown by partcl that were using a default parrot type instead of the specific one that corresponds to tcl's [error].

I've checked a file into the repository to track the progress of the suite. This is analogous to the file rakudo (Perl 6 on parrot) is using.

"date","revision","files","test","pass","fail","skip"
"2008-09-25 00:00",31396,38,1481,743,290,448
"2008-09-26 04:51",31427,56,3659,2463,812,384

Most of the gains in the first day are from small improvements to code invoked by the test suite, rather than any new real features, though there are a few improvements there as well. 

We still have a bit of work to do to successfully execute all the test files (and even more to pass all the tests.).

The most individual tests we ever logged passing with the converted version of the files was 3031; With the 700 or so passing tests in test files that don't run to completion yet (and therefore aren't in that listing above), we've already exceeded that. (I don't want to add those passes to the tracking file yet because they're harder to count if the test file doesn't pass. Plus it feels like cheating.)

Next to come is a document describing the failing test files, or (hopefully) the failing individual tests. This will be used to drive whatever tuits I have available, hopefully getting the biggest number of passing tests per tuit. This will also point anyone interested in contributing at some hopefully small effort that give us a concrete result.

  1. Not exactly a pristine copy: one of the core features of tcltest (where should I send my output?) requires some relatively advanced functionality - tcl's tests are not designed like perl6's to allow new implementations to ease into things. I've tacked on 2 replacement subs in our copy of tcltest that for now always say "just print to stdout/stderr". Still, that's two oneline procedures compared to the original 3375 lines of tcltest.tcl
  2. The additional processing consisted of loading our version of Test::More that had a  stripped down version of [test]. It only let us run the very basic tests, though; now that we are running the native tests, we can now at least try to run some of the more complicated ones, which should help bring up our passing ratio.
  3. The 'spectest' target checks out a copy of the test directory from 8.5.4 tagged release of tcl's CVS repository, and then uses a small script to execute only those tests that we know run to completion. 
  4. Adding an option to tcltest that generated TAP is something that could be done upstream in tcl itself, and would allow that project to integrate with any TAP based testing tool.

what is partcl?

partcl is a from scratch implementation of tcl (8.5.4) targeting the parrot virtual machine.

The source code is currently distributed with parrot (in the languages/tcl directory).

Issues are recorded at the project's googlecode site.

There's been sporadic blogging about the project at Coke's use.perl journal - I'll be posting here going forward.