dg / dibi

Dibi - smart database abstraction layer
https://dibiphp.com
Other
488 stars 135 forks source link

Dibi event performs too many filesystem stat calls #426

Closed maryo closed 11 months ago

maryo commented 1 year ago

Hi. Thanks for the library (and for the others OFC :-]).

I'm not sure what is the exact reason why there is the is_file check in https://github.com/dg/dibi/blob/master/src/Dibi/Event.php#L66

I believe it's something clever but I'm not sure what is the condition trying to prevent, evaled source? Or something else could be there?

Perhaps it's not intended to use the logger/profiler in production but we do it to collect some metrics (and not only metrics). When it's enabled (or a listener is registered) then each SQL query performs several system stat calls which slows our server. Looks like it does not hit stat cache (stat is actually cached just for the last stat check).

So... what about removing the is_file entirely or replacing it with something else? ;-)

dg commented 1 year ago

In $row['file'] doesn't always have to be a filename (ie inner-code etc), but it could probably be simplified to a test that it ends with .php.

maryo commented 1 year ago

Oh I see. I'm not sure if testing just the .php at the end is reliable enough though. I've created a PR but I couldn't find a way how to reproduce the inner-code issue. For example this #0 [internal function]: {closure}('foo') https://3v4l.org/6gDAv does not contain the file key at all. Any idea 👼?