Christophe Rhodes | 1 Sep 2009 14:16
Favicon

OUTPUT-REPLACEMENT restart for fd-streams external-format

Hi,

I'm nervous of some work that I'm doing, and I'd quite like a
sanity-check before I continue too far, because it involves fd-streams
(and I know that several people have thrown their hands up in horror at
the fd-streams "logic").

The two attached patches implement proper error checking for the utf-8
format (so that surrogate codepoints aren't sent through, for example),
and an OUTPUT-REPLACEMENT restart to allow the program to send something
different in the event of an encoding error.


This interactive functionality, while nice (if it works) isn't the
actual objective; what I actually need is "liberal" or possibly
"interchange" versions of external formats, so that we don't have the
disastrous situation of trying to tell the user (via the debugger) that
some character in a string isn't encodable in the external format that
the debugger is using.  If I can get that functionality with the
generality of the restart approach, though, I'll go for it (even if that
functionality ends up not being used).

Anyway, the actual questions: firstly, does anything look directly wrong
or problematic with the above patches; secondly, I'm also attaching a
test file; can people suggest any other tests that I should be doing?

(Continue reading)

Karol Swietlicki | 2 Sep 2009 01:20
Picon

NREVERSE and REVERSE micro-optimization.

This is not that big of an improvement, but here goes.

NREVERSE and REVERSE both perform run-time dispatch on type.
Adding something like this:

(deftransform reverse ((seq) (list))
  `(sb-impl::list-reverse* seq))
(deftransform nreverse ((seq) (list))
  `(sb-impl::list-nreverse* seq))
(deftransform reverse ((seq) (vector))
  `(sb-impl::vector-reverse* seq))
(deftransform nreverse ((seq) (vector))
  `(sb-impl::vector-nreverse* seq))

should take care of that. Another thing to consider would be the
inlining the various <type>-reverse* functions, but that is a
different matter altogether.

Thoughts?

Karol Swietlicki

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
Raymond Wiker | 4 Sep 2009 13:43
Picon

sb-posix vs Snow Leopard

Trying to build SBCL on Snow Leopard today, I ran into some errors in  
contrib/sb-posix.

Specifically, test.mkdir.3 and test.rmdir.3 fail because mkdir/rmdir  
fail because Snow Leopard throws EISDIR when you try to mkdir/rmdir /.  
I'm guessing that this may be because / is a mount point. Changing  
these tests to use /usr instead works (on Snow Leopard, at least),  
but /usr is itself a candidate for being a separate mount point.

Next, stat-mode.6 fails. I thought this was because sb-posix had the  
wrong value for S_IFSOCK, but that does no appear to be the case...  
instead, it appears that sb-posix:stat or sb-posix:stat-mode picks up  
the wrong value. This could (possibly) be an alignment issue.

Using a small C program I get (for the directory test-lab in contrib/ 
sb-posix):

mode = 04075 (note: octal)

using (format t "~o~%" (sb-posix:stat-mode (sb-posix:stat #p"sb-posix/ 
test-lab/"))), I get

146034

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
(Continue reading)

John Fremlin | 4 Sep 2009 13:59
Picon
Favicon

MOP and mmap'd manardb

We (MSI) have just released a development version of our memory mapped
MOP database. There's a lot that can be improved with it but it has a
test suite and has been bashing stuff out for a while.

http://github.com/ilitirit/manardb/tree/master

Object instantiation seems a little slow on SBCL (just my impression
compared to Allegro 8.1 -- could be completely wrong) and I wonder if
there is something I'm doing wrong?

Basically each mm-object of a class descended from mm-metaclass has a
normal instance %ptr slot which gives an index into our mmap'd
regions. I guess should play more with allocate-instance and avoid doing
initialize-instance. Any wisdom appreciated!

Unfortunately as all mmap slots are always boundp, we have to munge the
general initialize-instance to set default slot values. This is quite
unfortunate. Is there a more sensible way of doing this (along the lines
of the way structure slots are handled)?

The normal slots are mmap'd, which are persistently stored in the mapped
regions and are accessed via overridden slot-value-using-class. This is
just

(defmethod slot-value-using-class ((class mm-metaclass) (object mm-object) (slotd mm-effective-slot-definition))
  (declare (ignorable class))
  (funcall (the mm-slot-definition-reader (slot-definition-reader-function slotd)) object))

(defmethod (setf slot-value-using-class) (new-value (class mm-metaclass) (object mm-object) (slotd mm-effective-slot-definition))
  (declare (ignorable class))
(Continue reading)

Pascal Costanza | 4 Sep 2009 15:17

Re: MOP and mmap'd manardb


On 4 Sep 2009, at 13:59, John Fremlin wrote:

> We (MSI) have just released a development version of our memory mapped
> MOP database. There's a lot that can be improved with it but it has a
> test suite and has been bashing stuff out for a while.
>
> http://github.com/ilitirit/manardb/tree/master
>
> Object instantiation seems a little slow on SBCL (just my impression
> compared to Allegro 8.1 -- could be completely wrong) and I wonder if
> there is something I'm doing wrong?

Not sure, there could be many reasons.

However, I can notice a few issues from taking a first look at the code:

+ You define a method on shared-initialize for your metaclass.  
According to the CLOS MOP specification, you are not allowed to do  
that, your program is thus not portable. You have to define methods on  
initialize-instance and reinitialize-instance instead.

+ What compilation settings do you use? Maybe SBCL just performs more  
checks that you may want to switch off? (Just guessing here.)

+ Your slot-xyz-using-class methods specalize not only on the  
metaclass and the slot definition class, but also on the object.  
That's redundant, it doesn't buy you anything, since you want  
instances of the metaclass to inherit from the object class anyway.  
Leaving out the specialize may allow SBCL to use faster caches.
(Continue reading)

Scott L. Burson | 5 Sep 2009 01:42

Re: MOP and mmap'd manardb

On Fri, Sep 4, 2009 at 6:17 AM, Pascal Costanza <pc <at> p-cos.net> wrote:


On 4 Sep 2009, at 13:59, John Fremlin wrote:

> Unfortunately as all mmap slots are always boundp, we have to munge
> the
> general initialize-instance to set default slot values. This is quite
> unfortunate. Is there a more sensible way of doing this (along the
> lines
> of the way structure slots are handled)?

What do you mean by 'munge' (sorry, I'm not a native speaker)?

From the Jargon File:

http://www.catb.org/jargon/html/M/munge.html

Definition 3 is probably the applicable one.

I would have said "frob".

-- Scott

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Sbcl-devel mailing list
Sbcl-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-devel
Nicolas Neuss | 5 Sep 2009 12:46
Picon
Picon

Re: MOP and mmap'd manardb

John Fremlin <jf <at> msi.co.jp> writes:

> Object instantiation seems a little slow on SBCL (just my impression
> compared to Allegro 8.1 -- could be completely wrong) and I wonder if
> there is something I'm doing wrong?

Calling make-instance with initargs turned out to be quite slow for me.
Replacing it by a call without arguments and setting the slots
afterwards helped me.  (Of course, you should do such ugly optimizations
only if really necessary.)

Nicolas

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
A.M.Raportirenko | 6 Sep 2009 17:23
Picon

problems in "~G" format specification

In sbcl-1.0.30 

* (format nil "~G"
MOST-POSITIVE-DOUBLE-FLOAT)
"179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.
   "

* (format nil "~G" 9.6000000000000474E-2)
"9.60000000000004700e-2"

* (format nil "~G" 0.04165461138601871)
"4.16546113860187140e-2"

After applying attached patches (I'm loking for  them in cmucl sources), all 
staff slitly better.  

* (format nil "~G" MOST-POSITIVE-DOUBLE-FLOAT)
"1.7976931348623157e+308"

* (format nil "~G" 9.6000000000000474E-2)
"9.600000000000047e-2"

* (format nil "~G" 0.04165461138601871)
"4.1654611386018714e-2"

But for this cmucl give also rounded value
* (format nil "~G" -0.04165461138601871)
"-4.165461138601871e-2"

Anatoly
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Sbcl-devel mailing list
Sbcl-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-devel
John Fremlin | 7 Sep 2009 08:16
Picon
Favicon

Re: MOP and mmap'd manardb

Hi Pascal,

Pascal Costanza <pc <at> p-cos.net> writes:

> On 4 Sep 2009, at 13:59, John Fremlin wrote:
>
>> We (MSI) have just released a development version of our memory mapped
>> MOP database. There's a lot that can be improved with it but it has a
>> test suite and has been bashing stuff out for a while.
>>
>> http://github.com/ilitirit/manardb/tree/master
>>
>> Object instantiation seems a little slow on SBCL (just my impression
>> compared to Allegro 8.1 -- could be completely wrong) and I wonder if
>> there is something I'm doing wrong?
>
> Not sure, there could be many reasons.
>
> However, I can notice a few issues from taking a first look at the code:
>
> + You define a method on shared-initialize for your
> metaclass. According to the CLOS MOP specification, you are not
> allowed to do  that, your program is thus not portable. You have to
> define methods on  initialize-instance and reinitialize-instance
> instead.

Thanks for this input. I wasn't aware of that (it isn't covered in AMOP
as far as I can see). I cargo culted the idea from Elephant. But you are
quite correct according to
http://clisp.cons.org/impnotes/mop-classes.html#mop-cl-init-mo

It is now fixed and I've pushed the updates. Thanks!

> + What compilation settings do you use? Maybe SBCL just performs more
> checks that you may want to switch off? (Just guessing here.)

Not sure to be honest, I'm starting with a general (proclaim '(optimize
speed)) before the project is loaded ;-)

> + Your slot-xyz-using-class methods specalize not only on the
> metaclass and the slot definition class, but also on the object.
> That's redundant, it doesn't buy you anything, since you want
> instances of the metaclass to inherit from the object class anyway.
> Leaving out the specialize may allow SBCL to use faster caches.

That makes sense, I'll do that.

[...]

>> Unfortunately as all mmap slots are always boundp, we have to munge
>> the general initialize-instance to set default slot values. This is
>> quite unfortunate. Is there a more sensible way of doing this (along
>> the lines of the way structure slots are handled)?
>
> What do you mean by 'munge' (sorry, I'm not a native speaker)?

I mean that the way I do it is not at all nice and pretty. I think it is
probably clearer to show the code

(defmethod initialize-instance :before ((instance mm-object) &rest initargs)
  (declare (optimize speed) (dynamic-extent initargs))
  (cond ((eq '%ptr (first initargs)) ;;; XXX this is for speed; if %ptr is given it must be first
	 (setf (%ptr instance) 
	       (second initargs)))
	(t
	 (let ((class (class-of instance)))
	   (setf (%ptr instance) (mm-metaclass-alloc class))
	   
    ;;; XXX this is a horrible hack because we don't support unbound slots
    ;;; not in shared-initialize because that is more likely to destroy the system's optimizations????
	   (let ((slot-definitions (class-slots class)))
	     (loop for s in slot-definitions do
		   (when (and (slot-definition-memory-mapped s)
			      (slot-definition-initfunction s))
		     (unless (get-properties initargs (slot-definition-initargs s))
		       (setf (slot-value-using-class class instance s) 
			     (funcall (slot-definition-initfunction s))))))))))
  instance)

> Note that you can also define methods on make-instance and allocate-
> instance, if that helps.

The situation when most instance creation occurs is when an object is
instantiated from the database into a Lisp object (generally with one
slot, (hopefully) a fixnum "mptr").

It is possible for the object to have normal instance slots (caches or
temporary slots). Those should be initialized according to the normal
rules. It would be possible to generate an compiled function to do this
explicitly for all such slots -- firstly calling allocate-instance(?)
directly and then the init-functions for each slot.

One approach I was considering was to inherit from structure-class
instead of standard-class, etc. This would finesse the initialisation as
structure slots are also never unbound. But I think that is not really
portable?  (And perhaps not sensible)

[...]

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
John Fremlin | 7 Sep 2009 08:19
Picon
Favicon

Re: MOP and mmap'd manardb

Nicolas Neuss <neuss <at> math.uni-karlsruhe.de> writes:

> John Fremlin <jf <at> msi.co.jp> writes:
>
>> Object instantiation seems a little slow on SBCL (just my impression
>> compared to Allegro 8.1 -- could be completely wrong) and I wonder if
>> there is something I'm doing wrong?
>
> Calling make-instance with initargs turned out to be quite slow for me.
> Replacing it by a call without arguments and setting the slots
> afterwards helped me.  (Of course, you should do such ugly optimizations
> only if really necessary.)

This makes sense I guess. At the moment we make an object-instantiator
function like this

	  (compile nil
		   `(lambda (index)
		      (declare (optimize speed) (type mindex index))
		      (make-instance ,class '%ptr (make-mptr ,(mm-metaclass-tag class) index))))))

And changing it to setf the %ptr instead is not any more ugly . . .

We could easily call allocate-instance and setf all the normal slots to
their defined initfunctions too . . .

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

Gmane