oldk1331 wrote:
> 
> > My policy concerning optimizations was mostly reactive.
> > I look at profile data and try to eliminate expensive
> > part.
> 
> This is List, the most basic data structure used everywhere
> in FriCAS, it's worth to optimize List whenever possible.
> 
> > Spreading out copies in different places makes it harder to notice
> > that code is the same.
> 
> Reuse code in different categories is awkward too.
> I don't know why HyperTeX shows List uses map from
> IndexedAggregate and map! from URAGG.

Well, if there are multiple implementations runtime may
choose any of them, essentially at random.

> > BTW2: In case of 'map' or 'map!' with explicit functional
> > argument best optimizations is to inline definition of map
> > into current code, then inline functional argument into
> > it.  With good low level optimizer this can give 10-100
> > time speedup, much more than speeding up 'map' can
> > give.
> 
> I didn't realize that compiled map can be this slow.
> I do a simple benchmark shows in the most simple case,
> map is 1x slower than for loops.

Well, it depends on many factors:

- how good the low level optimizer is.  sbcl has reasonable
  optimizer but not very good.  On average it seem to
  generatre code with about half of speed of gcc code.
  In particular sbcl is likely to miss some optimizations
  that gcc can find after inlining.
- Lisp safety settings: by default Lisp check several things,
  in particular checks if array accesses are in bounds.
  Changing safety to 0 gives much faster code (but if code
  has bugs it may crash like C code).
- You test with list on unrealistically big data.  List node
  on 64 bit machine takes 16 bytes so you had 160 MB in
  smaller test and 1.6 GB in bigger.  That size is bigger
  than largest CPU caches, so data had to go from RAM.
  Caches can be read much faster, so you should see bigger
  ratios on smaller data.  Also, arrays are faster to
  access seqentially than lists, so ratios are likely
  to be bigger for arrays.


-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to