From: Francis W. <f.j...@li...> - 2024-01-04 17:11:26
|
There is also the function with!-timeout defined in "rlisp/inter.red", which I presume is portable, at least between CSL and PSL, and might be closer to what Nasser is looking for. Francis ________________________________ From: Arthur Norman <ac...@ca...> Sent: 04 January 2024 9:48 AM To: Nasser M. Abbasi <nm...@12...> Cc: red...@li... <red...@li...> Subject: Re: [Reduce-algebra-developers] Does reduce have a way to set timelimit on an operation? The CSL version has a resource!-limit function available at the symbolic code4 level that can restrict time used, the amount of memory cycled through, the amount of output generated or the number of lisp-level errors noticed and recovered from. I put that in for when I was wanting to run some tests and profiling, and an example use is in csl/cslbase/buildreduce.lsp where you will find the sequence walltime := timeofday(); eval '(resettime1); rr := resource!-limit(list('in_list1, mkquote packge, t), cpulimit, % CPU time per test conslimit, % megaconses 10000,% allow ten megabytes of I/O -1); % Do not limit Lisp-level That was not put in for what I will describe as ordinary or casual users. And for "Reduce" as a whole things are generally made easy-user-visible and documented in the main manual if they are liable to be provided when the Reduce sources are built on any platform - and in our case that means CSL, PSL, [Common Lisp, emacs Lisp, a Java-based Lisp,...]. >From early on Reduce tended to value providing the same experience everywhere - even in relatively resource-poor locations - over having the glossiest possible interface. Each version of Reduce ough to do do what the manual documents, but each will have a significant number of extra capabilities inherited from the underlying Lisp implementation and visible through "symbolic mode". So resouce!-limit which evaluates a form subject to limits is in CSL, but PSL and Common-Lisp based veraions will equally have their own specialities that may prove really important to some users - typically to power users. To the extent that resource!-limit is documented the test in csl/cslbase/eval3.cpp (!!) says // (resource!-limit form time space io errors C_stack Lisp_stack) // Evaluate the given form and if it succeeds return a // list whose first item is its value. If it fails in the ordinary manner // then its failure (error/throw/restart etc) gets passed back through // here in a transparent manner. But if it runs out of resources this // function catches that fact and returns an atomic value. // Resource limits are not precise, and are specified by the // subsequent arguments here: // time: an integer giving a time allowance in seconds // space: an integer giving a measure of memory that may be used, // expressed in units of "megaconses". This may only be // checked for at garbage collection and so small values // will often be substantially overshot. This is space // allocated - the fact that memory gets recycled does not // get it discounted. // io: an integer limiting the number of kilobytes of IO that may // be performed. // errors:an integer limiting the number of times traditional // Lisp errors can occur. Note that if errorset is used // you could have very many errors raised. // C_stack:in integer limiting (in Kbytes) the max depth of C // stack that may be used. The cut-off may be imprecise. // Lisp_stack: an integer limiting (in Kbytes) the max depth of // the Lisp stack that may be used. // In each case specifying a negative limit means that that limit does // not apply. But at least one limit must be specified. // If calls to resource!-limit are nested the inner ones can only // reduce the resources available to their form. // // Note that code within CSL can call the C function resource_exceeded() to // note that resources have expired. Because this is not supported by PSL or other Lisps it is probable that we do not want to make it a trivial user-level command or feature. Arthur _______________________________________________ Reduce-algebra-developers mailing list Red...@li... https://lists.sourceforge.net/lists/listinfo/reduce-algebra-developers |