freenode/#sicl - IRC Chatlog
Search
13:35:57
beach
Do you know whether SBCL optimizes TYPEP with a constant atomic type specifier according to the idea that Bike had this morning (UTC+2)?
13:37:20
beach
Basically do the same thing as with SLOT-VALUE, i.e. turn (TYPEP ... 'TYPE) into a (TYPE ...) where TYPE is a generic function.
13:38:32
beach
In SICL, it would be more like turning it into (funcall (car (load-time-value (find-typep-function 'type))) ...).
13:38:39
scymtym
i don't think SBCL ever does that. i had that idea as well when i tested the fast-gf-like thing for SBCL
13:39:24
scymtym
since the benefits over independent TYPEPs would be even more substantial (i would expect)
13:40:53
scymtym
but i may have assumed more general decision trees for that case, now that that i think about it
13:42:01
beach
As I pointed out, the TYPEP thing is often done manually: (defgeneric foop (x) (:method (x) nil) (:method ((x foo)) t))
13:43:42
beach
Well, I think Bike should try this out in some implementation, write down the result in the form of a paper, and submit it to ELS.
13:44:41
scymtym
the commonality being the need to more or less inline a funcallable instance at a call site
13:45:57
Bike
well what i was thinking was just the sicl version. if you're okay with leaning on semantic restrictions you can just inline the predicate, and usually the predicate is small so it should be fine.
13:48:52
beach
That would be the essence of the paper. How to get that machinery to work, even though the definition of the type changes.
13:49:33
Bike
hm, maybe i'm confused. for typep with a constant class a generic function makes some sense and clasp already does that for defstruct.
13:50:05
Bike
for general types i don't know. things like integer ranges wouldn't improve. maybe something like (or (array some-type) (array some-other-type)) would.
13:50:32
Bike
well yes, but the atomic type specifiers are often names for non atomic type specifiers.
13:51:53
beach
The point here is that with the fast generic-function machinery, we get a lot of flexibility.
13:53:44
scymtym
integer range dispatch can be used for tags, stamps and actual integer (at least fixnum) values
13:54:44
beach
Again, I think the machinery for making this stuff work in the presence of DEFTYPE and DEFCLASS after compilation of the TYPEP form would be the essence of the paper.
13:55:12
beach
Optimizations could be speculated about as possible, but not necessarily before the paper submission.
13:56:48
Bike
So i mean the idea is you have (typep x 'foo) expand into (funcall (car (load-time-value (find-typep-cell 'foo))) x), right? then if foo is an integer range you can just have the function be a non-generic.
13:59:27
beach
The interesting part, to me, is what happens if you have (typep x 'foo), and a class named foo. At compile time, you have a class BAR that is a subclass of FOO, so TRUE is returned for BAR.
14:00:32
beach
Yes, but you have to describe what happens when this new DEFCLASS is executed. That is non-trivial.
14:03:56
Bike
well, i do think it's interesting, but i thought it was just an obvious extension of what you're already doing with cells, i guess
14:06:30
Bike
oh, so for deftype you axe all the methods, put in a new one on T that just does the type predicate.
14:08:44
scymtym
so answering the original question, SBCL inserts SB-KERNEL::CACHED-TYPEP if the type is undefined and a SB-KERNEL:CLASSOID-CELL-TYPEP if a class-based is chosen for the type
14:10:31
scymtym
i don't see how the latter can work if the type is redefined in way that makes the class-based test inappropriate, but i haven't tried it
14:10:34
beach
Does it mean that SBCL takes advantage of the fact that types can not be redefined between compile time and run time? Other than classes.
14:17:11
beach
It might be necessary to invent a new type of generic function and new types of methods.
14:19:23
beach
Methods on compute-applicable-methods-using-classes, compute-discriminating-function, compute-effective-method, at least.
14:19:57
beach
Plus the description of how the call history is impacted. Clearing it will probably always work, but there might be smarter things to do.
14:20:45
beach
Like if you have classes FOO (), BAR (FOO), BAZ (BAR) and you redefine BAZ not to be a subclass anymore, you can leave entries on BAR in the call history.
14:22:34
Bike
Well i mean we can, right now, define (defgeneric foop (x) (:method ((x foo)) t) (:method (x) nil)), and it has to work and be sensitive to redefinitions of subclasses and so on.
14:23:23
beach
It doesn't matter much. People don't like to see "go read that other paper first, before you bother reading this one".
14:25:43
beach
The main claim though is that this technique is faster than what is currently done, while being more flexible about redefined types between compile time and run time.
14:27:08
Bike
as far as actual code goes i can get some numbers on how a generic function compares to a cpl search in clasp, at least
14:27:53
beach
And you can also do an estimate of the work involved in *any* implementation for both solutions.
14:29:07
Bike
yeah, i mean, it's a linear search rather than a binary search, though it's a bit complicated by the fact i imagine the class will usually pbe pretty close to the front of the cpl
14:34:02
beach
And, to get to the class precedence list, you need another generic-function call I would think.
14:34:50
beach
So put yourself in the situation of an implementation without the fast generic dispatch.
14:35:57
beach
So you might be looking at a dozen or so additional memory accesses for existing implementations.
14:36:54
jcowan
beach: in response to your question about how predicate-based (rather than type-based) generic function dispatch can be made efficient, I do require any such predicates to be pure and functional, and I may introduce the idea of a predicate being "too complex" in an implementation-specific way
14:37:19
jcowan
though to my mind, if you want to dispatch on the primality of an integer argument, you should be prepared to pay the price of it.
14:43:11
scymtym
the most complicated part was introducing lexical bindings for the match variables in the patterns
15:24:58
shka_
You were not kidding when you said that writing common lisp implementation in full common lisp makes it a lot simpler
15:28:48
beach
He is a very smart man. I would not have the wisdom to lower my expectation for political reasons.
15:30:00
beach
In his place, I would have made the wrong decision, and nobody would have been using my stuff.
15:34:09
beach
Free software is an established concept, so one can hope that it would be possible to pay more attention to things like security.
15:40:49
beach
He is basically explaining that there are extremely few people in my situation, i.e., who don't need grants, who already have tenure, who are not going to be promoted before retirement, so they can do what they want.
20:57:03
jcowan
If there had been a SBCL-class compiler for CL in 1987, then GCC-in-CL might have been feasible. But CMUCL was only running in MacLisp at that point.
20:58:27
jcowan
the earlier compiler was running on the Perq and on MIPS machines, but was certainly not suitable for writing a general purpose C compiler in, not to mention a portable one