[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Identifying sources of allocations in a toy Mandelbrot package
From: |
Tomas Hlavaty |
Subject: |
Re: Identifying sources of allocations in a toy Mandelbrot package |
Date: |
Fri, 19 Jan 2024 16:33:44 +0100 |
in lisp, a rough heuristic is that anything can allocate memory anytime
another useful heuristic is not to do things that do not need to be
done (not lisp-specific)
>> You have a pretty big vector
>
> The vector is allocated once and not on the same scale as usage,
> measured by profiling or by resident memory in top.
it does not need to be allocated at all
> (eval-when-compile (require 'cl-lib))
have you tried eliminating cl-lib?
> (let* ((cx) (cy) (zr) (zi) (v) (out) (zrt)
^
those parens are unnecessary
also it is ugly to (let (a) (setq a 42) ...)
it is nice to put let around as little forms as possible
then the binding dependencies look clearer
and lack of setf and setq means
I don't have to think unnecessarily about sideeffects
> (output (make-vector (* w h 3) 0))
you dont need the output vector at all, you already have an output
buffer so just write there directly
> (setf cx (+ x0 (* dxp x)))
use let instead of setf and setq, everywhere
> (if (> (+ (* zr zr) (* zi zi)) 4) (cl-return v)
avoid cl-return
> (aset output idx out)
> (aset output (+ idx 1) out)
> (aset output (+ idx 2) out)
insert the value into the output buffer here
- Identifying sources of allocations in a toy Mandelbrot package, Psionic K, 2024/01/17
- Re: Identifying sources of allocations in a toy Mandelbrot package, Psionic K, 2024/01/19
- Re: Identifying sources of allocations in a toy Mandelbrot package,
Tomas Hlavaty <=
- Re: Identifying sources of allocations in a toy Mandelbrot package, Psionic K, 2024/01/19
- Re: Identifying sources of allocations in a toy Mandelbrot package, Psionic K, 2024/01/19
- Re: Identifying sources of allocations in a toy Mandelbrot package, Eli Zaretskii, 2024/01/20
- Re: Identifying sources of allocations in a toy Mandelbrot package, Tomas Hlavaty, 2024/01/20
- Re: Identifying sources of allocations in a toy Mandelbrot package, Psionic K, 2024/01/20
- Re: Identifying sources of allocations in a toy Mandelbrot package, Eli Zaretskii, 2024/01/20
- Re: Identifying sources of allocations in a toy Mandelbrot package, Tomas Hlavaty, 2024/01/26
- Re: Identifying sources of allocations in a toy Mandelbrot package, Psionic K, 2024/01/26
Re: Identifying sources of allocations in a toy Mandelbrot package, Eli Zaretskii, 2024/01/19
Re: Identifying sources of allocations in a toy Mandelbrot package, Psionic K, 2024/01/27