Skip to content

Instantly share code, notes, and snippets.

View krakjoe's full-sized avatar

Joe Watkins krakjoe

View GitHub Profile
@krakjoe
krakjoe / gist:4271903
Created December 12, 2012 21:43
jemalloc.patch
diff -ur a/php-src-jemalloc-zendmm/Zend/zend_alloc.c b/php-src-jemalloc-zendmm/Zend/zend_alloc.c
--- a/php-src-jemalloc-zendmm/Zend/zend_alloc.c 2012-12-12 06:59:10.000000000 +0100
+++ b/php-src-jemalloc-zendmm/Zend/zend_alloc.c 2012-12-12 22:35:24.000000000 +0100
@@ -38,17 +38,20 @@
#endif
#ifdef HAVE_MEM_JEMALLOC
-# ifndef JEMALLOC_NO_DEMANGLE
-# define JEMALLOC_NO_DEMANGLE
+# ifdef JEMALLOC_PREFIX
@krakjoe
krakjoe / gist:4273826
Created December 13, 2012 03:38
custom-allocators apply on top of patch from earlier today, tested with jemalloc, tcmalloc, GC_, should be flexible enough to give them all a good testing ...
diff -ur a/php-src-jemalloc-zendmm/Zend/zend_alloc.c b/php-src-jemalloc-zendmm/Zend/zend_alloc.c
--- a/php-src-jemalloc-zendmm/Zend/zend_alloc.c 2012-12-12 06:59:10.000000000 +0100
+++ b/php-src-jemalloc-zendmm/Zend/zend_alloc.c 2012-12-13 03:00:41.000000000 +0100
@@ -37,18 +37,19 @@
# include <process.h>
#endif
-#ifdef HAVE_MEM_JEMALLOC
-# ifndef JEMALLOC_NO_DEMANGLE
-# define JEMALLOC_NO_DEMANGLE
@krakjoe
krakjoe / demo.php
Last active December 2, 2016 05:28
PCNTL+pools+workers+pthreads
<?php
declare(ticks=1);
/*
This is your container for workers, it is only used in the process itself, so there is no need to descend from pthreads
*/
class Pool {
public $max;
public $config;
public $stop;
@krakjoe
krakjoe / pthreads-helper
Last active August 20, 2019 21:05
pthreads-helper to download/install php+pthreads isolated
#!/bin/bash
# This should be a path that the user executing the script can read and write
PHP_PATH=/opt/php-ts
# This should be a sensible version of PHP
PHP_VERSION=7.0.0
# This should be a sensible mirror for your location
PHP_MIRROR=uk1.php.net
# This should be a released version of pthreads
PHP_PTHREADS=3.1.5
# This should be set to 0 if you do not want to remove build directories
@krakjoe
krakjoe / v.php
Created February 27, 2013 18:37
editable configuration originating from APC by example...
<?php
/*
An example of read/writable multi-threaded configuration
*/
class Config extends Stackable {
public function __construct($config) {
$this->map($config);
}
/* this makes everything safe */
@krakjoe
krakjoe / bench.php
Created March 22, 2013 10:53
Zend/bench.php for pthreads ...
<?php
if (function_exists("date_default_timezone_set")) {
date_default_timezone_set("UTC");
}
class GStore extends Stackable {
public function run(){}
public $value;
@krakjoe
krakjoe / igbinary.patch
Created March 26, 2013 08:13
igbinary apcu patch
diff -uNr igbinary-1.1.1/apc_serializer.h igbinary-1.1.1-apcu-patched/apc_serializer.h
--- igbinary-1.1.1/apc_serializer.h 2011-03-14 12:32:48.000000000 +0000
+++ igbinary-1.1.1-apcu-patched/apc_serializer.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,81 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | APC |
- +----------------------------------------------------------------------+
- | Copyright (c) 2006-2011 The PHP Group |
- +----------------------------------------------------------------------+
@krakjoe
krakjoe / get_object_stats
Last active December 15, 2015 14:39
get_objects_count function for RFC
--- php-virgin/Zend/zend_builtin_functions.c 2013-04-04 16:44:42.930473062 +0100
+++ php-nts/Zend/zend_builtin_functions.c 2013-04-10 08:39:54.716250434 +0100
@@ -64,6 +64,7 @@
static ZEND_FUNCTION(is_subclass_of);
static ZEND_FUNCTION(is_a);
static ZEND_FUNCTION(get_class_vars);
+static ZEND_FUNCTION(get_objects_count);
static ZEND_FUNCTION(get_object_vars);
static ZEND_FUNCTION(get_class_methods);
static ZEND_FUNCTION(trigger_error);
@krakjoe
krakjoe / php_api.h
Last active December 15, 2015 18:38
a (completely untested) unified php api, perhaps, just the "gist" ... its correct "enough" ...
/* +----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
--- php-virgin/ext/standard/info.c 2013-04-04 16:44:43.017473544 +0100
+++ php-nts/ext/standard/info.c 2013-04-04 16:49:59.395083830 +0100
@@ -1148,6 +1148,37 @@
RETURN_TRUE;
}
+/* {{{ proto array phpconfopts()
+ Returns the array of configuration options in a processable format */
+PHP_FUNCTION(phpconfopts)
+{