zholos / qml

math library for kdb+
http://althenia.net/qml
Other
65 stars 33 forks source link

Loading qml affects run-time of built-in functions #6

Closed robsmith11 closed 7 years ago

robsmith11 commented 7 years ago

This issue isn't a problem as far as I can tell, but the behavior seems very strange to me, so I wanted to ask whether there is a simple explanation and whether it could be affecting other functions negatively.

In the example below, I 1) Start a new kdb 3.4 process. 2) Time the built-in exp function (first execution is slow because of cold-start). 3) Load qml (built from current git master). 4) Time the built-in exp function again and observe an unexpected and significant speed-up (1,710ms vs 2,511ms) 5) Time .qml.exp and observe a further (slight) speed-up, suggesting exp didn't simply get overridden by qml.exp somehow.

q)\t exp 100000000?1f
2776
q)\t exp 100000000?1f
2511
q)\t exp 100000000?1f
2511
q)\t exp 100000000?1f
2511
q)\l qml.q
q)\t exp 100000000?1f
1710
q)\t exp 100000000?1f
1710
q)\t exp 100000000?1f
1710
q)\t .qml.exp 100000000?1f
1698
q)\t .qml.exp 100000000?1f
1698
q)\t .qml.exp 100000000?1f
1698
robsmith11 commented 7 years ago

After further testing, I believe this behavior is actually unrelated to qml:

q)\t exp 10000000?1f
277
q)\t exp 10000000?1f
251
q)\t exp 10000000?1f
251
q)\t exp 10000000?1f
251
q)exp each 0 1;
q)\t exp 10000000?1f
170
q)\t exp 10000000?1f
170
q)\t exp 10000000?1f
170

I still can't explain it though...