libera/#commonlisp - IRC Chatlog
Search
14:47:48
dim
can I have a defmethod with an eql specifier on nil, like (defmethod foo (variant (eql nil)))?
14:49:41
beach
The AMOP uses the preposition "to" for specialization, and I think that's a good idea, so a method "on" a generic function specialized "to" null.
14:51:08
dim
well in my case I'm maintaining code that already has (defgeneric adjust-data-types (catalog variant) (:documentation "Adjust PostgreSQL data types depending on the variant we target."))
14:51:52
dim
it just happens that sometimes the variant is nil, I'm not sure why, and I'm okay with it being nil after all (two values are supported at the moment, :pgdg and :redshift, and nil would behave the same as :pgdg, I'm okay with that)
14:52:15
dim
(defmethod adjust-data-types ((catalog catalog) (variant (eql nil))) catalog) ; that's what I have in my code now
14:52:33
pjb
equivalent to: (defmethod adjust-data-types ((catalog catalog) (variant null)) catalog)
14:53:31
dim
given that context, I think I prefer the (eql nil) specified, it's better aligned with the intention here somehow
14:54:46
pjb
I think using (variant null) is more efficient than using (variant (eql nil)), but that would depend on the compiler.
14:58:04
dim
oh I don't have a perf issue there, it's done in a costly part of the code and only once
14:58:50
atgreen
Using --lose-on-corruption --disable-debugger worked. Corruption triggered in cl-postgres: https://paste.centos.org/view/51641cc2
15:01:07
_death
nasty (safety 0) in that function (parse-message-binary-parameters) which may hide something else
15:18:05
aeth
The user *may* choose to (safety 0) in a deployed application anyway to avoid type checks on tightly optimized code that has type declarations, but that's on them. Because now any bug that shows up in the real world is completely opaque unless you can reproduce it. And some library code may erroneously rely on type declarations to type *check*, which now becomes a type *assumption* in SBCL (safety
15:19:21
aeth
Imo, the only time (safety 0) makes sense is if you absolutely positively must avoid bounds checking inside of a loop where you're absolutely sure that you can't go out of bounds, but that can go inside of a LOCALLY to limit the damage. And the implementation can ignore you and bounds check anyway.
15:20:24
aeth
But... that sort of loop usually is operating on data of defined sizes so you usually can get an optimizing compiler to avoid bounds checking by just letting it know that the type is, say, (simple-array single-float (42)). And now something smarter than you is eliminating bounds checks (or not).
15:22:00
aeth
And do you really need the extra speed at the expense of dealing with strange out of bounds bugs? Because that's one of the worst parts of C or C++.
15:22:01
_death
atgreen: I guess submitting a patch would be ideal, but note that you can also restrict optimization settings using sb-ext:restrict-compiler-policy
15:22:54
aeth
99% of code that says `(safety 0)` just recited an incantation off of the internet without realizing the implication to SBCL users (probably > 2/3 of the users of the code in 2022)
15:34:59
NotThatRPG
White_Flame: That has the effect of switching on the "come-from" operator, too! ;-)
16:10:04
jeosol
_death, aeth: I don't remember, does that (declare (optimize (...)) affect all code if done at repl and you load a large system?
16:11:20
pjb
Let the user decide on what he wants. He'll set the optimization levels in his rc file.
16:11:37
jeosol
I was doing some exploration weeks ago, but I didn't see any effect, so thought I didn't set it up correctly
16:12:49
Fade
does asdf have any facility for declaring optimisation level in a given build component?
16:18:15
jeosol
pardon my mixing up the terms. I was referring to setting compiler optimization policies referenced earlier
16:28:39
White_Flame
jeosol: I believe that's undefined how it spreads across future loads and whatever
16:29:30
White_Flame
I tend to build some form of configuration parameter for optimization, and have scoped declarations for different sections as they need it
16:29:52
Bike
"As with other defining macros, it is unspecified whether or not the compile-time side-effects of a declaim persist after the file has been compiled."
16:30:00
jeosol
Trying to add that at code or file level is not feasible for me, so I'll just work with the rc level if that works
16:31:08
White_Flame
"Such a declaration, sometimes called a global declaration or a proclamation, is always in force unless locally shadowed."
16:31:52
jeosol
After my limited tests, I just use the defaults for now, and just focus on the DSA bits in the code and look for any improvements
16:33:52
White_Flame
as long as your image lasts through all compilation, I would suspect that has some effect
16:34:30
White_Flame
then there's also ASDF to consider and what it might shadow for its various compiles & loads it orchestrates
16:43:26
NotThatRPG
White_Flame: ASDF does not attempt to shadow, but does nothing to avoid systems it loads from affecting global context of the image. Again, because the spec is so unclear, ASDF doesn't have the ability to do anything portable, so just punts.
16:43:30
_death
jeosol: in computation-intensive code declarations can help a lot, so if you already use good algorithms and data structures, you may still benefit by sprinkling them after profiling (maybe after other performance-related operations, such as reduction in consing or caching)
16:44:17
NotThatRPG
_death: On a function-by-function basis, this is easy and its effects predictable. Trying to build an entire system with (optimize (speed 3)) on the other hand...
16:46:11
jeosol
_death: yes, that is my plan exactly. I go through the code sections that were written in a hurry and rewriting to avoid unnecessary calculations or consing. It's small stuffs for now. I really on an external exe for benchmarking but hope to write replicate the code in the exe in the future
16:46:25
_death
NotThatRPG: indeed.. sometimes it's even more localized.. for example I have a macro where I know the body is going to run for many iterations and often needs performance, so I declare (speed 3) in a locally there.. but then, a few uses aren't critical, so I have to reintroduce (speed 0) (or should it be speed 1? :) manually
16:46:49
jeosol
the exe code is basically Ax=b type systems that are solved repeatedly (fluid mechanics problem)
16:50:46
_death
NotThatRPG: maybe I should split the uses and have two operators instead (another option would be to pass an argument, but I don't think I'd like that)
16:51:35
NotThatRPG
Macro argument that controls whether or not the `(locally (declare (optimize (speed 3))))` goes into the expansion?
16:54:03
_death
sometimes I just keep the default (speed 3) and add a type declaration or two to avoid the compiler notes.. but I think two operators could be a better signal to the human reading the code
16:58:25
jeosol
I am discussing with some folks next week who may ask: what is the CL macros I talk about. I saw this link: https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node97.html#:~:text=The%20Common%20Lisp%20macro%20facility,as%20in%20most%20other%20languages. which I think is good. I don't think they'll understand but I can try to explain in layman terms
16:59:15
jeosol
basically, I use macros to generate a lot of functions that have symmetry in the function body.
17:00:04
NotThatRPG
It's a deep matter, because CL has the notion of the running image, which macro expansion can access. None of the conventional compiled languages have anything comparable. I'm not sure whether that features in your code.
17:06:12
jeosol
The key two aspects of CL I highlighted were CLOS and Macros. The person may or may not know or heard about CL but I will ask them first.
17:06:41
_death
jeosol: http://web.archive.org/web/20120124144817/http://weitz.de/macros.lisp may be of interest
17:07:05
jeosol
I came across a guy who told me you use Lisp in the early 80's and surprised at use it. He is the deep learning space. I told me one of the compilers has monthly release cycles to this day and he was really surprised
17:13:59
_death
another one is a simple short-circuiting product operator.. like (* (foo) (bar)) .. if FOO returns 0, why should you evaluate BAR (assuming no side effects) ?
18:37:43
NotThatRPG
jeosol: yes, that was... It's relevant to how CL macros differ from macros in other programming languages
18:38:44
NotThatRPG
jeosol: Just waiting for the CL bindings to numpy and pandas to be released! ;-)
19:11:19
Guest491241242
Hi, currently my ql:quickload command loads a library from ultralisp distribution. I would like to download the library from quicklisps projects. How could I specify this?
19:20:43
NotThatRPG
I don't see a way that you can control on a per-system basis which distribution a library comes from. Since quicklisp can make recursive computations, I think you are stuck with a single ordering over all your distributions (i.e., you either always get from ultralisp first or always from ql first).
19:21:23
Guest491241242
I think I managed to do it by disabling the ultralisp using expression (ql-dist:disable (cadr (ql-dist:all-dists)))
19:23:48
NotThatRPG
Guest491241242: Unless you know in exquisite detail all the dependencies of the systems you need, it's not obvious how to control quickloading with > 1 distribution. ISTR there's someone (shinmera?) who has a library that lets you assemble your own distribution.
19:31:32
Guest491241242
NotThatRPG: thanks, currently I don't have a need to use separate distributions or create my own. At some point I had tried something with ultralisp but had not remembered to change it back quicklisp's distribution.
19:53:14
NotThatRPG_away
stylewarning: ? You mean you want to add a new component type that's a conda package? a conda environment?
20:16:34
NotThatRPG_away
Shinmera: I just noticed -- your documentation is a mess! or ... a ".mess" ;-)
20:18:19
NotThatRPG
It occurs to me that it would be nice if we could create a new dist that is just pointers into other dists, without having to actually replicate, but I don't know how hard that would be. HTTP redirection?
20:20:06
Shinmera
or rather, each dist release includes an url for each project's release that it includes.
20:23:33
Shinmera
I also would like to support it using another dist as a project's source (with replication)
20:29:47
stylewarning
NotThatRPG: I'm not 100% sure. I'm thinking of something like :depends-on which ensures foreign dependencies are loaded (?) or installed (?)
20:34:19
Shinmera
stylewarning: I have thought about that problem before but I honestly think it's not a great idea because of the massive diversity of system configuration tools out there that would need to be handled, not to mention the massive variance in *versions* those tools provide.
20:34:41
Shinmera
Instead, if I write a bindings library, I instead ship a version for every platform with the sources.
20:35:29
Shinmera
Once Forge is in a more state of actual existance I want to switch to building the foreign libraries, though.
20:35:30
NotThatRPG
stylewarning: If you want to do that you need to tell ASDF what a conda dependency is. Thinking not very hard about this, I would suggest: (1) you would need to give ASDF some way to find (or create) a conda env that contains the python systems you want. Maybe make a mixin for class (to add to ASDF system classes) to allow an ASDF lisp system to be associated with a conda env. (2) add a SECOND subclass of ASDF system that
20:35:30
NotThatRPG
corresponds to a python package, call it PYTHON-SYSTEM. Then you would have to add (at least) a PERFORM LOAD-OP method for PYTHON-SYSTEM that would know how to load a python system into the conda environment.
20:36:53
NotThatRPG
It's not great that python has so many different loading methods. If your user doesn't have conda installed, and just uses pyenv, for example, they would be SoL.
1:19:48
atgreen
_death, hayley .. reverting SBCL from 2.2.7 to 2.2.6 solved my corruption error from earlier today
1:27:04
hayley
I'm too busy today to look through the cl-postgres code, but it is still possible that it is modifying literals in a way that isn't allowed in Common Lisp, and it's caught by SBCL 2.2.7 now.
1:29:04
hayley
...after a quick glance that doesn't seem likely, but there is a (optimise (safety 0)) declaration that you could remove.
1:46:36
hayley
(setf (aref "blab" 2) #\u) is undefined behaviour. After SAVE-LISP-AND-DIE, SBCL 2.2.7 would put that string in read-only memory, so trying to write to the string would cause a memory fault.
1:47:02
hayley
But I don't think that's the issue; the use of (safety 0) in that function causing a memory fault is more concerning to me now.