cl-cookbook icon indicating copy to clipboard operation
cl-cookbook copied to clipboard

Request: Add content on profiling and performance tuning

Open sheepduke opened this issue 6 years ago • 6 comments

In my humble opinion one big advantage of Common Lisp is that it can be dramatically fast while providing great power.

Sometimes we just want our programs to be faster, so profiling and performance tuning might be interesting to some people.

Outline:

  • Profiling
    • Macro TIME
    • Macro TRACE and UNTRACE
    • Macro DISASSEMBLE
  • Performance Tuning
    • Macro DECLARE with type, optimize etc
    • Macro INLINE
    • Package INLINED-GENERIC-FUNCTION

I am willing to draft it.

Any idea?

sheepduke avatar Feb 16 '19 07:02 sheepduke

There is something in https://lispcookbook.github.io/cl-cookbook/debugging.html and maybe this chapter about debugging is still missing some useful tips from https://malisper.me/debugging-lisp-part-1-recompilation/

arademaker avatar Feb 16 '19 12:02 arademaker

That would be great !

Related to #104 ? Explaining and showing types.

trace is covered in debugging.

@arademaker I think the most important point of your link is covered (about declaim… debug 3), but there is no "story telling" (as I wasn't able to reproduce).

vindarel avatar Feb 16 '19 13:02 vindarel

True. TRACE is more debug related. My mistake.

Oh! I saw #104 before opening this one, and I totally agree that CL's type system should be introduced for its great flexibility and huge optimization potential.

I think maybe we can add a new page introducing performance related things, including my original outline plus some points referred in #104.

The type system can be explained in detail between section Profiling and Performance Tuning.

By doing so, this page will be organized in an order of profiling -> type system knowledge -> tuning (with examples).

I think it should be logical and practical. What do you think?

sheepduke avatar Feb 16 '19 16:02 sheepduke

Or is it better to introduce type system as a specific chapter?

sheepduke avatar Feb 16 '19 16:02 sheepduke

By doing so, this page will be organized in an order of profiling -> type system knowledge -> tuning (with examples).

sounds really good.

The type system might be introduced gently as a specific chapter (issue 104: "I don't know CL, what good is the type system ?"), and explained in detail within your section ("I wrote some Lisp. What about performance tuning ?"). May I suggest to start with easy things, given IMO this Cookbook is primarily for newcomers ? However, please yourself, whatever you write will be an excellent addition. "publish early publish often" they say :p

vindarel avatar Feb 16 '19 18:02 vindarel

The type system might be introduced gently as a specific chapter (issue 104: "I don't know CL, what good is the type system ?"), and explained in detail within your section ("I wrote some Lisp. What about performance tuning ?").

Sounds reasonable. So in total 2 chapters:

  1. CL's type system and its properties (contents covered in #104).
  2. Performance related stuff (how to use DECLARE will be introduced here).

May I suggest to start with easy things, given IMO this Cookbook is primarily for newcomers ?

Sure. I will draft something ASAP and issue a PR within next week.

sheepduke avatar Feb 17 '19 13:02 sheepduke