Hi Bil,
Was just checking the profile capabilities of s7 and noticed the following:
If there are two separate namespaces (lets) both having function named
foo, their timing info seems to be accumulated (since the timing info
is stored as a lookup table from what I can tell, using only the
functions name as a symbol).
I attach a program that showcases the problem and a naive patch that
uses the 'namespace/function-name as this lookup key.
I'm using *ns-name* in my environment, but could be configurable with
something like (*s7* 'profile-funclet-prefix-symbol).
An entirely different solution would be to add the functions' actual
value to the profile data, so that one can operate its funclet, but
that leaves the symbol conflict to be resolved in some other way,
since I had no idea what to use in the place of symbol_position and
symbol_set_position
What do you think?
diff --git a/s7.c b/s7.c
index 4a943e4..2820c7d 100644
--- a/s7.c
+++ b/s7.c
@@ -50903,7 +50903,13 @@ static s7_pointer g_profile_in(s7_scheme *sc, s7_pointer args) /* only external
s7_int pos;
s7_int *v;
profile_data_t *pd = sc->profile_data;
- func_name = funclet_function(e);
+ func_name = g_string_to_symbol_1(sc, g_format(sc,
+ s7_list(sc, 4,
+ s7_f(sc),
+ s7_make_string(sc, "~A/~A"),
+ s7_symbol_local_value(sc, make_symbol(sc, "*ns-name*"), e),
+ funclet_function(e))),
+ sc->string_to_symbol_symbol);
pos = symbol_position(func_name);
if (pos == PD_POSITION_UNSET)
{
(define (foo . args)
())
(define namespace (inlet))
(with-let namespace
(define *ns-name* 'my-namespace)
(define (foo . args)
()))
(map foo (iota 1000))
(map (namespace 'foo) (iota 2000))
;; (show-profile) output:
;;
;; without patch:
;; foo: calls 3000, time 0.0004 0.0004
;; with patch:
;; my-namespace/foo:calls 2000, time 0.0003 0.0003
;; rootlet/foo: calls 1000, time 0.0001 0.0001
_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist