
编程语言
feilengcui008
这个作者很懒,什么都没留下…
展开
-
PHP扩展开发-执行流程与扩展结构
在开发扩展之前,最好了解下PHP内核的执行流程,PHP其实主要包括两个方面: SAPI Zend VM 内部扩展Zend VM是PHP的虚拟机,与JVM类似,都是各自语言的编译/执行的核心。它们都会把各自的代码先编译为一种中间代码,PHP的通常叫opcode,Java通常叫bytecode,不同的是PHP的opcode直接被Zend VM的执行单元调用对应的C函数执行,不会显示保留下原创 2015-03-13 12:43:33 · 779 阅读 · 0 评论 -
Lambda与闭包
写本文的目的是通过javascript/c++11/java8/python/scala等几种语言对lambda和闭包的支持的对比,探讨下lambda和闭包的区别与联系,以及作用域的trick。在阅读这篇文章前,首先熟悉以下几个概念(有些概念不会谈,只是和本文所谈的lambda和闭包对比理解),摘自维基百科:--Closure--In programming languages, closures原创 2015-05-18 14:35:47 · 1887 阅读 · 0 评论 -
C++ RVO/NRVO以及move语义的影响
C++返回值优化和具名返回值优化是编译器的优化,在大多数情况下能提高性能,但是却难以受程序员控制。C++11中加入了move语义的支持,由此对RVO和NRVO会造成一定影响。下面以一段代码来说明。RVO和NRVO在分别在copy/move construct,copy/move assignment八种简单情况,测试条件是g++ 4.8.2和clang++ 3.4,默认优化。#include <io原创 2015-05-09 13:22:40 · 2087 阅读 · 0 评论 -
C/C++内存对齐
有时会在c/c++中看到这种形式#pragma pack(n)#pragma pack()前一句代表设置对齐的字节数为n,而不是编译器默认的对齐字节数(ubuntu 14.04 x86_64下为8),后一句代表恢复默认值,合理地使用内存对齐能减少程序占用的内存空间,使用不当也会降低存取效率从而降低程序性能。在分析内存对齐时,只需要采用以下的原则,这里以一段代码简单解释下#include <stdi原创 2015-03-09 15:40:10 · 730 阅读 · 0 评论 -
Linux下调试与性能分析工具的总结
(此文主要用来记录一些调试,性能测试与分析等工具的用法,备忘)GDB常用调试命令和调试技巧命令status info => 查看程序本身相关信息 args => 打印参数breakpoints => 断点信息files => 进程的地址空间详细内容sharedlibrary => 加载的共享库frame => 栈帧line => 当前所在行locals => 当前栈帧中的变量re原创 2016-05-03 18:53:34 · 3390 阅读 · 0 评论 -
Linux网络编程之简单总结
SVM1.概述⇒\Rightarrow brief introductionSVM全称Support_Vector_Machine,即支持向量机,是机器学习中的一种监督学习分类算法,一般用于二分类问题。对于线性可分的二分类问题,SVM可以直接求解,对于非线性可分问题,其也可以通过核函数将低维映射到高维空间从而转变为线性可分。对于多分类问题,SVM经过适当的转换,也能加以解决。相对于传统的分类算法如l原创 2015-03-04 22:37:33 · 1154 阅读 · 0 评论 -
Linux下ELF文件格式
(in English for practice^_^)In this article,I will talk about the ELF files for Linux,and their diffs as to comprehend the linking process in a diff view angle.There are many articles talking about tha原创 2015-09-13 21:57:33 · 854 阅读 · 0 评论 -
Linux下x86_64进程地址空间布局
关于Linux 32位内存下的内存空间布局,可以参考这篇博文Linux下C程序进程地址空间局关于源代码中各种数据类型/代码在elf格式文件以及进程空间中所处的段,在x86_64下和i386下是类似的,本文主要关注vm.legacy_va_layout以及kernel.randomize_va_space参数影响下的进程空间内存宏观布局。情形一:vm_legacy_va_layout=1 ke原创 2015-03-08 23:33:26 · 4959 阅读 · 0 评论 -
Linux网络编程之多进程
multiprocess mode//fork server#include <stdio.h>#include <string.h>#include <unistd.h>#include <sys/socket.h>#include <netdb.h>#include <stdlib.h>#include <netinet/in.h>#include <sys/wait.h>#i原创 2015-03-03 10:28:10 · 612 阅读 · 0 评论 -
Linux网络编程之epoll
epoll-nonblocking(Level-Trigger)with epoll each time we exec epoll it return the fds which have events,it behaves better than select/poll.You can use both blocking and nonblocking in LT mode,but only n原创 2015-03-09 10:09:56 · 681 阅读 · 0 评论 -
Y Combinator
由于匿名函数(通常成为lambda函数但是跟lambda calculus不同)在递归时无法获得函数名,从而导致一些问题,而Y Combinator能很好地解决这个问题。利用不动点的原理,可以利用一般的函数来辅助得到匿名函数的递归形式,从而间接调用无法表达的真正的匿名函数。下面以一个阶乘的递归来说明。#Python版本,后面会加上C++版本#F(f) = fdef F(f,n): ret原创 2015-05-14 19:26:10 · 1113 阅读 · 0 评论 -
Tornado源码阅读
一、官方实例博客源码官方blog实例,此处摘抄了main函数部分def main(): tornado.options.parse_command_line() http_server=tornado.httpserver.HTTPServer(Application())#listen()函数是核心,他做的事情有:# (1)调用netutil中的bind_socket,返回原创 2015-03-09 12:08:21 · 1069 阅读 · 0 评论 -
PHP7源码笔记一
1.builtin types基本定义在Zend/zend_types.h和Zend/zend.h中 主要的几种:原始类型:zend_bool,zend_uchar,zend_intptr_t.. 封装的用户直接接触的类型 zend_string,zend_array(HashTable),zend_object,zend_resource,zend_function..内部使用: zv原创 2015-09-12 19:31:48 · 960 阅读 · 0 评论 -
Linux网络编程之多线程
multithread mode//thread server#include <stdio.h>#include <stdlib.h>#include <netinet/in.h>#include <netdb.h>#include <pthread.h>#include <unistd.h>#define MAX_READ_CHUNK 2*1024*1024#define KEE原创 2015-03-03 10:29:23 · 550 阅读 · 0 评论 -
Linux网络编程之select
select-nonblocking modethe select-nonblocking mode is simple but the fd number is usually limited to 1024,although if we dont need very high concurrency number like the front server(nginx etc),we can原创 2015-03-03 10:31:03 · 514 阅读 · 0 评论 -
Linux网络编程之poll
poll-nonblocking modethe poll is like select,it uses struct pollfd to replace the read_set,write_set,error_set of select,and it has no limitation of the fd number like select.struct pollfd { in原创 2015-03-03 10:33:07 · 562 阅读 · 0 评论 -
Python主进程hang住的两个原因
最近使用Python遇到两个非常不好定位的问题,表现都是Python主进程hang住。最终定位出一个是subprocess模块的问题,一个是threading.Timer线程的问题。subprocess模块不当使用的问题Python的subprocess比较强大,基本上能替换os.system、os.popen、commands.getstatusoutput的功能,但是在使用的过程中需要注意参数s原创 2016-10-16 17:08:06 · 4778 阅读 · 0 评论