Re: [GNC-dev] gnc:debug changes

2020-03-07 Thread Mike Alexander

On 7 Mar 2020, at 5:22, Christopher Lam wrote:

Ok I think your changes are fine. I don't understand qof_log_check I'd 
hope it's not slow.


I just pushed the change.

qof_log_check is called a *lot* and I don't think it's a problem.  It 
does a couple of hash table lookups and a couple of string comparisons, 
but that's it.  The hash table will generally only have half a dozen 
entries so the lookup should be fast.


 Mike
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] gnc:debug changes

2020-03-07 Thread Christopher Lam
On Sat, 7 Mar 2020 at 06:18, Mike Alexander  wrote:

> I understand. Avoiding the call to strify is a good idea and I don't
> intend to change that. I was simply pointing out that evaluating the args
> to gnc:debug may also take some time. In the case you mention presumably
> pricelist already exists, but sometimes the debug output has to be created
> by calling other functions which can take time. I don't think it's possible
> to avoid that by changing gnc:debug, at least not easily.
>
Ok I think your changes are fine. I don't understand qof_log_check I'd hope
it's not slow.
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] gnc:debug changes

2020-03-06 Thread Mike Alexander

On 7 Mar 2020, at 0:39, Christopher Lam wrote:

I'd thought that the log level would be an invariant per session. If 
log levels could be amended mid-session I'd like to see how.


Call qof-log-set-level.  It works fine without the most recent change to 
gnc:debug.  I put a few calls to it into 
gnc:price-quotes-install-sources to test this.  I made sure to compile 
the Scheme code in case compilation changed things.


The gnc:debug was optimized because there was (gnc:debug pricelist) 
whereby a long pricelist (which is realistic) would obligatorily lead 
to string-join and map in strify, and was definitely a  _major_ 
 slowdown. Conclusion: we don't want to call strify with a long list 
unnecessarily.


I understand.  Avoiding the call to strify is a good idea and I don't 
intend to change that.  I was simply pointing out that evaluating the 
args to gnc:debug may also take some time.  In the case you mention 
presumably pricelist already exists, but sometimes the debug output has 
to be created by calling other functions which can take time.  I don't 
think it's possible to avoid that by changing gnc:debug, at least not 
easily.


If log level is not an invariant, assuming qof_log_check is fast, 
would be:


(define (gnc:debug items)
  (when (qof-log-check "gnc" QOF-LOG-DEBUG)
    (gnc-scm-log-debug (strify items


Yes, that's what I have in mind except change the first arg to 
qof-log-check to "gnc.scm" which is the original bug that I was looking 
for.


   Mike
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: [GNC-dev] gnc:debug changes

2020-03-06 Thread Christopher Lam
Hi Mike.

I'd thought that the log level would be an invariant per session. If log
levels could be amended mid-session I'd like to see how.

The gnc:debug was optimized because there was (gnc:debug pricelist) whereby
a long pricelist (which is realistic) would obligatorily lead to
string-join and map in strify, and was definitely a *major* slowdown.
Conclusion: we don't want to call strify with a long list unnecessarily.

If log level is not an invariant, assuming qof_log_check is fast, would be:

(define (gnc:debug items)
  (when (qof-log-check "gnc" QOF-LOG-DEBUG)
(gnc-scm-log-debug (strify items


On Sat, 7 Mar 2020 at 05:25, Mike Alexander  wrote:

> I spent some time yesterday figuring out why gnc:debug never produced
> any output regardless of the gnc.scm log level.  I tracked it down to
> commits 42b6fb9 and b3a4cd6 from last July.  The actual bug is trivial
> (they test for the log level for "gnc" instead of "gnc.scm") but I
> wonder if b3a4cd6 is a good idea.  It has the effect of binding the
> gnc.scm log level on the first call to gnc:debug and ignoring subsequent
> changes to it.  This means that later calls to (qof-log-set-level
> "gnc.scm" ...) will have no effect.  It is sometimes useful to turn on
> and off Scheme debugging around sections of code you care about.
>
> The optimization from b3a4cd6 seems to be relatively minor.  The
> arguments to gnc:debug are evaluated when debugging is off even with
> this change (something I verified) and the call to strify is avoided
> even without it.  All you're really avoiding is the actual call to
> gnc:debug and the call to qof-log-check.  I propose reverting back to
> 42b6fb9 with the bugs in it fixed.  Is this ok? If so I'll push a
> change.
>
>  Mike
> ___
> gnucash-devel mailing list
> gnucash-devel@gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel