Merge pull request #2862 from Hypolite/settings-save-perf
Performance improvements: Settings save (alt), profiler, logger
This commit is contained in:
commit
4fdced1a0a
8
boot.php
8
boot.php
|
@ -1100,6 +1100,9 @@ class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_timestamp($stamp, $value) {
|
function save_timestamp($stamp, $value) {
|
||||||
|
if (!isset($a->config['system']['profiler']) || !$a->config['system']['profiler'])
|
||||||
|
return;
|
||||||
|
|
||||||
$duration = (float)(microtime(true)-$stamp);
|
$duration = (float)(microtime(true)-$stamp);
|
||||||
|
|
||||||
if (!isset($this->performance[$value])) {
|
if (!isset($this->performance[$value])) {
|
||||||
|
@ -1176,11 +1179,6 @@ class App {
|
||||||
return implode(", ", $callstack);
|
return implode(", ", $callstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mark_timestamp($mark) {
|
|
||||||
//$this->performance["markstart"] -= microtime(true) - $this->performance["marktime"];
|
|
||||||
$this->performance["markstart"] = microtime(true) - $this->performance["markstart"] - $this->performance["marktime"];
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_useragent() {
|
function get_useragent() {
|
||||||
return(FRIENDICA_PLATFORM." '".FRIENDICA_CODENAME."' ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION."; ".$this->get_baseurl());
|
return(FRIENDICA_PLATFORM." '".FRIENDICA_CODENAME."' ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION."; ".$this->get_baseurl());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
Config values that can only be set in .htconfig.php
|
Config values that can only be set in .htconfig.php
|
||||||
===================================================
|
===================================================
|
||||||
|
|
||||||
There are some config values that haven't found their way into the administration page. This has several reasons. Maybe they are part of a
|
There are some config values that haven't found their way into the administration page.
|
||||||
current development that isn't considered stable and will be added later in the administration page when it is considered safe. Or it triggers
|
This has several reasons.
|
||||||
something that isn't expected to be of public interest. Or it is for testing purposes only.
|
Maybe they are part of a current development that isn't considered stable and will be added later in the administration page when it is considered safe.
|
||||||
|
Or it triggers something that isn't expected to be of public interest. Or it is for testing purposes only.
|
||||||
|
|
||||||
**Attention:** Please be warned that you shouldn't use one of these values without the knowledge what it could trigger. Especially don't do that with
|
**Attention:** Please be warned that you shouldn't use one of these values without the knowledge what it could trigger.
|
||||||
undocumented values.
|
Especially don't do that with undocumented values.
|
||||||
|
|
||||||
The header of the section describes the category, the value is the parameter. Example: To set the directory value please add this
|
The header of the section describes the category, the value is the parameter.
|
||||||
line to your .htconfig.php:
|
Example: To set the directory value please add this line to your .htconfig.php:
|
||||||
|
|
||||||
$a->config['system']['directory'] = 'http://dir.friendi.ca';
|
$a->config['system']['directory'] = 'http://dir.friendi.ca';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Jabber ##
|
## Jabber ##
|
||||||
* debug (Boolean) - Enable debug level for the jabber account synchronisation.
|
* debug (Boolean) - Enable debug level for the jabber account synchronisation.
|
||||||
* logfile - Logfile for the jabber account synchronisation.
|
* logfile - Logfile for the jabber account synchronisation.
|
||||||
|
@ -48,6 +47,7 @@ line to your .htconfig.php:
|
||||||
* ostatus_poll_timeframe - Defines how old an item can be to try to complete the conversation with it.
|
* ostatus_poll_timeframe - Defines how old an item can be to try to complete the conversation with it.
|
||||||
* paranoia (Boolean) - Log out users if their IP address changed.
|
* paranoia (Boolean) - Log out users if their IP address changed.
|
||||||
* permit_crawling (Boolean) - Restricts the search for not logged in users to one search per minute.
|
* permit_crawling (Boolean) - Restricts the search for not logged in users to one search per minute.
|
||||||
|
* profiler (Boolean) - Enable internal timings to help optimize code. Needed for "rendertime" addon. Default is false.
|
||||||
* free_crawls - Number of "free" searches when "permit_crawling" is activated (Default value is 10)
|
* free_crawls - Number of "free" searches when "permit_crawling" is activated (Default value is 10)
|
||||||
* crawl_permit_period - Period in seconds between allowed searches when the number of free searches is reached and "permit_crawling" is activated (Default value is 60)
|
* crawl_permit_period - Period in seconds between allowed searches when the number of free searches is reached and "permit_crawling" is activated (Default value is 60)
|
||||||
* png_quality - Default value is 8.
|
* png_quality - Default value is 8.
|
||||||
|
@ -84,19 +84,15 @@ line to your .htconfig.php:
|
||||||
|
|
||||||
# Administrator Options #
|
# Administrator Options #
|
||||||
|
|
||||||
Enabling the admin panel for an account, and thus making the account holder
|
Enabling the admin panel for an account, and thus making the account holder admin of the node, is done by setting the variable
|
||||||
admin of the node, is done by setting the variable
|
|
||||||
|
|
||||||
$a->config['admin_email'] = "someone@example.com";
|
$a->config['admin_email'] = "someone@example.com";
|
||||||
|
|
||||||
where you have to match the email address used for the account with the one you
|
Where you have to match the email address used for the account with the one you enter to the .htconfig file.
|
||||||
enter to the .htconfig file. If more then one account should be able to access
|
If more then one account should be able to access the admin panel, seperate the email addresses with a comma.
|
||||||
the admin panel, seperate the email addresses with a comma.
|
|
||||||
|
|
||||||
$a->config['admin_email'] = "someone@example.com,someonelese@example.com";
|
$a->config['admin_email'] = "someone@example.com,someonelese@example.com";
|
||||||
|
|
||||||
If you want to have a more personalized closing line for the notification
|
If you want to have a more personalized closing line for the notification emails you can set a variable for the admin_name.
|
||||||
emails you can set a variable for the admin_name.
|
|
||||||
|
|
||||||
$a->config['admin_name'] = "Marvin";
|
$a->config['admin_name'] = "Marvin";
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Config {
|
||||||
* If true the config is loaded from the db and not from the cache (default: false)
|
* If true the config is loaded from the db and not from the cache (default: false)
|
||||||
* @return mixed Stored value or null if it does not exist
|
* @return mixed Stored value or null if it does not exist
|
||||||
*/
|
*/
|
||||||
public static function get($family, $key, $default_value=null, $refresh = false) {
|
public static function get($family, $key, $default_value = null, $refresh = false) {
|
||||||
|
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
|
@ -123,14 +123,14 @@ class Config {
|
||||||
* The value to store
|
* The value to store
|
||||||
* @return mixed Stored $value or false if the database update failed
|
* @return mixed Stored $value or false if the database update failed
|
||||||
*/
|
*/
|
||||||
public static function set($family,$key,$value) {
|
public static function set($family, $key, $value) {
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
$a->config[$family][$key] = $value;
|
$a->config[$family][$key] = $value;
|
||||||
|
|
||||||
// manage array value
|
// manage array value
|
||||||
$dbvalue = (is_array($value)?serialize($value):$value);
|
$dbvalue = is_array($value) ? serialize($value) : $value;
|
||||||
$dbvalue = (is_bool($dbvalue) ? intval($dbvalue) : $dbvalue);
|
$dbvalue = is_bool($dbvalue) ? intval($dbvalue) : $dbvalue;
|
||||||
|
|
||||||
$ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' )
|
$ret = q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' )
|
||||||
ON DUPLICATE KEY UPDATE `v` = '%s'",
|
ON DUPLICATE KEY UPDATE `v` = '%s'",
|
||||||
|
@ -139,8 +139,9 @@ ON DUPLICATE KEY UPDATE `v` = '%s'",
|
||||||
dbesc($dbvalue),
|
dbesc($dbvalue),
|
||||||
dbesc($dbvalue)
|
dbesc($dbvalue)
|
||||||
);
|
);
|
||||||
if($ret)
|
if ($ret) {
|
||||||
return $value;
|
return $value;
|
||||||
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ class PConfig {
|
||||||
* The value to store
|
* The value to store
|
||||||
* @return mixed Stored $value or false
|
* @return mixed Stored $value or false
|
||||||
*/
|
*/
|
||||||
public static function set($uid,$family,$key,$value) {
|
public static function set($uid, $family, $key, $value) {
|
||||||
|
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
|
@ -136,8 +136,9 @@ ON DUPLICATE KEY UPDATE `v` = '%s'",
|
||||||
dbesc($dbvalue),
|
dbesc($dbvalue),
|
||||||
dbesc($dbvalue)
|
dbesc($dbvalue)
|
||||||
);
|
);
|
||||||
if($ret)
|
if ($ret) {
|
||||||
return $value;
|
return $value;
|
||||||
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -678,11 +678,13 @@ function attribute_contains($attr,$s) {
|
||||||
return false;
|
return false;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
if(! function_exists('logger')) {
|
if (! function_exists('logger')) {
|
||||||
/* setup int->string log level map */
|
/* setup int->string log level map */
|
||||||
$LOGGER_LEVELS = array();
|
$LOGGER_LEVELS = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @brief Logs the given message at the given log level
|
||||||
|
*
|
||||||
* log levels:
|
* log levels:
|
||||||
* LOGGER_NORMAL (default)
|
* LOGGER_NORMAL (default)
|
||||||
* LOGGER_TRACE
|
* LOGGER_TRACE
|
||||||
|
@ -692,51 +694,58 @@ $LOGGER_LEVELS = array();
|
||||||
*
|
*
|
||||||
* @global App $a
|
* @global App $a
|
||||||
* @global dba $db
|
* @global dba $db
|
||||||
|
* @global array $LOGGER_LEVELS
|
||||||
* @param string $msg
|
* @param string $msg
|
||||||
* @param int $level
|
* @param int $level
|
||||||
*/
|
*/
|
||||||
function logger($msg,$level = 0) {
|
function logger($msg, $level = 0) {
|
||||||
// turn off logger in install mode
|
|
||||||
global $a;
|
global $a;
|
||||||
global $db;
|
global $db;
|
||||||
global $LOGGER_LEVELS;
|
global $LOGGER_LEVELS;
|
||||||
|
|
||||||
if(($a->module == 'install') || (! ($db && $db->connected))) return;
|
$debugging = get_config('system','debugging');
|
||||||
|
$logfile = get_config('system','logfile');
|
||||||
|
$loglevel = intval(get_config('system','loglevel'));
|
||||||
|
|
||||||
if (count($LOGGER_LEVELS)==0){
|
// turn off logger in install mode
|
||||||
foreach (get_defined_constants() as $k=>$v){
|
if (
|
||||||
if (substr($k,0,7)=="LOGGER_")
|
$a->module == 'install'
|
||||||
$LOGGER_LEVELS[$v] = substr($k,7,7);
|
|| ! ($db && $db->connected)
|
||||||
|
|| ! $debugging
|
||||||
|
|| ! $logfile
|
||||||
|
|| $level > $loglevel
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($LOGGER_LEVELS) == 0) {
|
||||||
|
foreach (get_defined_constants() as $k => $v) {
|
||||||
|
if (substr($k, 0, 7) == "LOGGER_") {
|
||||||
|
$LOGGER_LEVELS[$v] = substr($k, 7, 7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$debugging = get_config('system','debugging');
|
|
||||||
$loglevel = intval(get_config('system','loglevel'));
|
|
||||||
$logfile = get_config('system','logfile');
|
|
||||||
|
|
||||||
if((! $debugging) || (! $logfile) || ($level > $loglevel))
|
|
||||||
return;
|
|
||||||
|
|
||||||
$process_id = session_id();
|
$process_id = session_id();
|
||||||
|
|
||||||
if ($process_id == "")
|
if ($process_id == '') {
|
||||||
$process_id = get_app()->process_id;
|
$process_id = get_app()->process_id;
|
||||||
|
}
|
||||||
|
|
||||||
$callers = debug_backtrace();
|
$callers = debug_backtrace();
|
||||||
$logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
|
$logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
|
||||||
datetime_convert(),
|
datetime_convert(),
|
||||||
$process_id,
|
$process_id,
|
||||||
$LOGGER_LEVELS[$level],
|
$LOGGER_LEVELS[$level],
|
||||||
basename($callers[0]['file']),
|
basename($callers[0]['file']),
|
||||||
$callers[0]['line'],
|
$callers[0]['line'],
|
||||||
$callers[1]['function'],
|
$callers[1]['function'],
|
||||||
$msg
|
$msg
|
||||||
);
|
);
|
||||||
|
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
@file_put_contents($logfile, $logline, FILE_APPEND);
|
@file_put_contents($logfile, $logline, FILE_APPEND);
|
||||||
$a->save_timestamp($stamp1, "file");
|
$a->save_timestamp($stamp1, "file");
|
||||||
return;
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,6 @@ class Conversation extends BaseObject {
|
||||||
$result[] = $item_data;
|
$result[] = $item_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$a->mark_timestamp();
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue