Giter VIP home page Giter VIP logo

funcmap's Introduction

funcmap PHP extension

Problem: how to detect unused/dead legacy functions in production code? Solution: collect all the functions that ARE used and remove them from the list of functions available. What's left is unused.

funcmap is a simple PHP extension that collects names of all userspace functions that's been called and writes them down to a text file from time to time. To reduce the resource usage, you can limit the probability of that event.

Configuration

  • funcmap.enabled bool (PHP_INI_SYSTEM) - enable/disable the extension. The extension won't do anything at all if this setting is set to false. Default value: false
  • funcmap.logfile string (PHP_INI_ALL) - path to the logfile. File must be writable by PHP process user, otherwise you'll get an error in the logs. The filename may contain '%pid%' pattern, so that each child could write to its own file. Adding the '%pid%' pattern is strongly recommended for multiprocess PHP installations, otherwise you'll most likely end up with garbage results. Default value: ""
  • funcmap.probability int (PHP_INI_SYSTEM) - enable data collection with this probability. This is probablity in percents, so any valuu greater than 100 will be treated as 100, i.e. "always enabled". Setting it to a value <= 0 will result in no data being written ever. Default value: 100
  • funcmap.flush_interval_sec int (PHP_INI_ALL) - write collected data to the disk each N seconds (and on process shutdown). Zero value means "write on process shutdown only" (PHP-FPM processes are shut down, for example, when they reach their request limit). Default value: 0

Example configuration

funcmap.enabled=1                            # enable the extension
funcmap.logfile=/tmp/logs/funcmap_%pid%.log  # each PHP process writes to its own log file
funcmap.flush_interval_sec=200               # write data each 200 seconds if the process lives longer than that
funcmap.probability=2                        # collect data for 2% script executions only

funcmap's People

Contributors

mikhainin avatar rez1dent3 avatar tony2001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

funcmap's Issues

too few arguments to function 'php_funcmap_write_and_cleanup_map'

Hello. An error was made while synchronizing with an internal package. 47fcc9a

A method was called with no arguments. I think it should be 0

php_funcmap_write_and_cleanup_map();

  - git clone https://github.com/badoo/funcmap.git /opt/funcmap
  - cd /opt/funcmap
  - /usr/bin/phpize8.0
  - ./configure
  - make -j4
  - make install

trace

│ │ build-libs/setup  funcmap.lo 
│ │ build-libs/setup  libtool: compile:  cc -I. -I/opt/funcmap -I/opt/funcmap/include -I/opt/funcmap/main -I/opt/funcmap         ↵
│ │ build-libs/setup  -I/usr/include/php/20200930 -I/usr/include/php/20200930/main -I/usr/include/php/20200930/TSRM              ↵
│ │ build-libs/setup  -I/usr/include/php/20200930/Zend -I/usr/include/php/20200930/ext -I/usr/include/php/20200930/ext/date/lib  ↵
│ │ build-libs/setup  -DHAVE_CONFIG_H -g -O2 -c /opt/funcmap/funcmap.c  -fPIC -DPIC -o .libs/funcmap.o
│ │ build-libs/setup  /opt/funcmap/funcmap.c: In function 'zif_funcmap_flush':
│ │ build-libs/setup  /opt/funcmap/funcmap.c:386:2: error: too few arguments to function 'php_funcmap_write_and_cleanup_map'
│ │ build-libs/setup    386 |  php_funcmap_write_and_cleanup_map();
│ │ build-libs/setup        |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│ │ build-libs/setup  /opt/funcmap/funcmap.c:196:13: note: declared here
│ │ build-libs/setup    196 | static void php_funcmap_write_and_cleanup_map(int in_shutdown) /* {{{ */
│ │ build-libs/setup        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│ │ build-libs/setup  make: *** [Makefile:209: funcmap.lo] Error 1
│ ├ Info
│ └ Building stage build-libs/setup (51.10 seconds) FAILED

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.