Forum OpenACS Development: Re: blueprint and *-init.tcl files

Collapse
Posted by Gustaf Neumann on
I will try to paraphrase, allthough I do not feel as an expert on the request processor. apprently the following happens now:

At the begin of every request processing (in every connection thread) the following happens:

      if ! rp_performance_mode ...
         apm_load_any_changed_libraries
apm_load_any_change_libraries does (simplified) the following:
  • foreach "watch", compare remembered dates with file dates
  • if changed, reload the files in the current thread
Certainly, scheduled procs are not directly affected by the reload. It is not ideal that the check is performed before the processing of the user request (users get the impression of slowness) and that it happens in every connection thread.

It would be certainly better to perform this checking in a scheduled sweeper process which does checking once and loads the files via "ns_eval [list source $path/$file]" which cares about updating the blueprints in all interpreters in the background.

Collapse
Posted by Andrew Piskorski on
Gustaf, more importantly, if you use ns_eval instead, then all re-loading of procs should happen once when needed, and you should be able to remove that apm_load_any_changed_libraries hook entirely. No additional scheduled sweeper procs should be necessary, ns_eval should take care of it all.

The ns_eval comments say that all Tcl interps will sync with the new proc state "on their next _ns_atalloc", but I'm not sure what that means. So depending on precisely how ns_eval works, it may be desirable, in the the request processor, to replace the current apm_load_any_changed_libraries hook with some code that insures that the current thread has processed any and all pending ns_eval updates, by triggering one of these _ns_atalloc events or something like that. And since that's probably very fast, it should always run, regardless of whether rp_performance_mode is true or not. (And if necessary a similar light-weight hook could probably be installed somehow for all non-conn Tcl threads as well.)

Basically, it looks like apm_load_any_changed_libraries is just an old ugly hack which only exists because either its author wasn't aware of ns_eval, or ns_eval wasn't available way back then.