Timing function problem

Started by cameyo, September 18, 2019, 05:26:55 AM

Previous topic - Next topic

Lutz

#15
Yes, using your definition of 'merge', time is increasing on my system too.


> ./merge-time
2837.097
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
3596.99
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
4144.72
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
4526.995
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
5021.806
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
5475.793
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
5927.577
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
6196.546
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
6451.934
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
6576.566
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
8244.489
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
10133.406
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
7734.864
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
7595.829
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
9027.866
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
7656.296
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
7687.444
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
7974.064
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
8514.397000000001
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
8105.182
(598 576460752303423488 418 3 0 2048 0 10878 10705 1411)
~>

Also printing (sys-info) and you can see, there is no increase in stack levels or lisp cells between the calls to merge. I guess the answer is in stack and memory management of the underlying OS.


(dotimes (i 20)
(println (time (merge (sequence 1 500) (sequence 1 200) <) 500))
(println (sys-info)))

cameyo

#16
Thanks Lutz.

Anyway i have found a strange thing: raising an error on REPL reset the time.

For example, type the following on REPL:
(set)
ERR: missing argument in function set

Now timing the function will restart the problem (but time is reset to first value 1750.432):
(time (merge (sequence 1 500) (sequence 1 200) <) 500)
;-> 1750.432
(time (merge (sequence 1 500) (sequence 1 200) <) 500)
;-> 2218.979
...

Lutz

#17
Over time envrironment and stack memory gets fragmented by certain functions. The error forces a total low level freeing and reallocation of this memory. There is nothing we can do about it without slowing down everywhere, but it is a rare enough problem. Until now, I have never seen this before.

rickyboy

#18
Quote from: "Lutz"Over time envrironment and stack memory gets fragmented by certain functions. The error forces a total low level freeing and reallocation of this memory. There is nothing we can do about it without slowing down everywhere, but it is a rare enough problem. Until now, I have never seen this before.

Thanks, Lutz!
(λx. x x) (λx. x x)

cameyo

#19
Thanks, Lutz !

Grazie Lutz !