On Mon, Aug 03, 2026 at 05:13:38PM +0800, Qian Yun wrote:
>
> Kernel cache recycle is effective for long running sessions.
Recycling kernels usualy helps, that is clear. Discussion that
we had was about details of the tuning.
You may also try the following function and some its variations:
test_kernels(n : Integer, m : Integer) : List(Expression(Integer)) ==
res : List(Expression(Integer)) := []
e1 := []$List(OutputForm)
for i in 1..n repeat
m1 := random(m)
o := m1::OutputForm
s := script('x, [[o], e1, e1, e1])$Symbol
k := s::Expression(Integer)
cons(k, res)
res
FYI, on the first run I get:
r1 := test_kernels(100000, 25000);
Compiling function test_kernels with type (Integer, Integer) -> List
(Expression(Integer))
Type: List(Expression(Integer))
Time: 37.00 (EV) + 0.04 (GC) = 37.05 sec
Second run is much faster (about 1.70s), after few runs it stabilises
at about 0.27s.
Runtime clearly grows nonlinearly (probably quadratically) with
increasing parameters. But stabilised behaviour indicates that
it should be quite a bit faster if we implemented change that
you suggested, that is skipping linear search when we know that
binary search can not miss.
You can also try some variation, say adding test for odd m1 before
'cons' in the function, so that half of created kernels immediately
becomes garbage (in function above there all kernels are live).
Also, to test impact of garbage collection we should allocate
enough data before or during test.
--
Waldek Hebisch