通过使用 Prelink 优化程序启动速度
#!/bin/bash
#=========================================================
# Author : Junjie Huang
# Email : acm@gmail.com
# Last modified : 2018-05-07 17:43
# Filename : elf_dependencies_analyzer.sh
# Description : a tool to analyze dependencies for elf
#=========================================================
ROOT_ELF=""
MAX_DEPTH=0
SYS_ROOT=$(pwd)
LD_LIB_PATH=""
CHECK_PRELINK=0
PRINT_PATH=0
IGNORE_SCANNED=0
DRAW_WITH_DOT=0
SAVE_IN_CSV=0
function usage() {
echo -e "\nUsage : `basename $0` [OPTION...] [FILES]"
echo "Note :"
echo " -c Check if the elf file has been prelinked or not"
echo " -p Print the path of elf; otherwise print name as default"
echo " -i Ignore the elf file which has been scanned, to be unique"
echo " -g | --graph Draw the dependencies graphs with graphviz and dot"
echo " -t | --table Generate the depencies table in cvs format"
echo " -h | --help Get help"
echo " --depth=MAX_DEPTH The max depth to scan"
echo " --root=ROOT_PATH Prefix all paths with ROOT_PATH "
echo " --ld-library-path=LD_LIBRARY_PATH What LD_LIBRARY_PATH should be used"
echo ""
}
if [[ $# -lt 1 ]]; then
usage
exit 1
fi
# parse the arguments
for i in "$@"; do
case $i in
-c)
CHECK_PRELINK=1
shift
;;
-p)
PRINT_PATH=1
shift
;;
-i)
IGNORE_SCANNED=1
shift
;;
-g|--graph)
DRAW_WITH_DOT=1
shift
;;
-t|--table)
SAVE_IN_CSV=1
shift
;;
-d=*|--depth=*)
MAX_DEPTH="${i#*=}"
shift
;;
-r=*|--root=*)
SYS_ROOT="${i#*=}"
shift
;;
-l=*|--ld-library-path=*)
LD_LIB_PATH="${i#*=}"
shift
;;
-h|--help)
usage
exit 1
;;
*)
ROOT_ELF=$i
;;
esac
done
ROOT_ELF_PATH=${SYS_ROOT}${ROOT_ELF}
ROOT_ELF_NAME=$(basename ${ROOT_ELF_PATH})
LD_LIB_LIST=($(echo ${LD_LIB_PATH} | tr : ' '))
DOT_SOURCE_FILE=${ROOT_ELF_NAME}".dot"
DOT_OUTPUT_FILE=${ROOT_ELF_NAME}".png"
CSV_SOURCE_FILE=${ROOT_ELF_NAME}".csv"
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
RESET=$(tput sgr0)
last_child_mask=()
scanned_elf_list=()
function print_hierarchy_symbols() {
if [[ $depth -gt 0 ]]; then
local i=1
while [[ $i -lt $depth ]]; do
if [[ ${last_child_mask[$i]} -eq 0 ]]; then
echo -n '│ '
else
echo -n ' '
fi
i=$((i+1))
done
if [[ ${last_child_mask[$depth]} -eq 0 ]]; then
echo -n '├──'
else
echo -n '└──'
fi
fi
}
# PARAMETER 1: ELF file path
function print_file_path() {
local path=$1
local name=$(basename $path)
if [[ SAVE_IN_CSV -eq 1 ]]; then
save_in_cvs ${name}
fi
print_hierarchy_symbols
if [[ ${CHECK_PRELINK} -eq 1 ]]; then
if [[ $(readelf -S ${path} | grep -i "prelink") ]]; then
if [[ ${PRINT_PATH} -eq 1 ]]; then
echo "${GREEN}${path} [y]${RESET}"
else
echo "${GREEN}${name} [y]${RESET}"
fi
else
if [[ ${PRINT_PATH} -eq 1 ]]; then
echo "${RED}${path} [n]${RESET}"
else
echo "${RED}${name} [n]${RESET}"
fi
fi
else
if [[ ${PRINT_PATH} -eq 1 ]]; then
echo "${MAGENTA}${path}${RESET}"
else
echo "${MAGENTA}${name}${RESET}"
fi
fi
}
function generate_dot_header() {
if [[ -f ${DOT_SOURCE_FILE} ]]; then
rm -rf ${DOT_SOURCE_FILE}
fi
cat << EOT >> ${DOT_SOURCE_FILE}
digraph "${ROOT_ELF_NAME}" {
graph [
rankdir=LR
bgcolor=white
fontsize=10
]
edge [
color=blue
]
node [
shape=record
fontcolor=red
color=black
style=filled
fillcolor=white
]
EOT
}
# PARAMETER 1: parent elf path
# PARAMETER 2: current elf path
function draw_in_dot() {
local pre=$(basename $1)
local cur=$(basename $2)
echo " \"$pre\" -> \"$cur\";" >> ${DOT_SOURCE_FILE}
}
function generate_dot_footer() {
echo "}" >> ${DOT_SOURCE_FILE}
}
# PARAMETER 1: ELF file name
function save_in_cvs() {
local elf=$1
if [[ $depth -gt 0 ]]; then
local i=1
while [[ $i -le $depth ]]; do
echo -n ', ' >> ${CSV_SOURCE_FILE}
i=$((i+1))
done
fi
echo $elf >> ${CSV_SOURCE_FILE}
}
# PARAMETER 1: ELF file path
function list_dependencies() {
local elf_list=$(readelf -d $1 | grep NEEDED | \
awk -F'[' '{print $2}' | awk -F']' '{print $1}')
echo ${elf_list}
}
depth=0
# PARAMETER 1: ELF file path
function dependencies_scan() {
local target=$1
local dep_list=($(list_dependencies ${target})) #array
if [[ ${IGNORE_SCANNED} -eq 1 ]]; then
if [[ ${scanned_elf_list[@]} =~ (^|[[:space:]])"${target}"($|[[:space:]]) ]]; then
return
else
scanned_elf_list+=(${target})
fi
fi
for elf_name in "${dep_list[@]}"; do
local file_list=()
if [[ ${#LD_LIB_LIST[@]} -ne 0 ]]; then
for lib in "${LD_LIB_LIST[@]}"; do
lib=${SYS_ROOT}${lib}
if [[ -d ${lib} ]]; then
file_list=($(find ${lib} -name ${elf_name}))
if [[ ${#file_list[@]} -ne 0 ]]; then
break
fi
fi
done
else
file_list=($(find . -name ${elf_name}))
fi
if [[ ${#file_list[@]} -eq 0 ]]; then
#file_list=($(find . -name ${elf_name}))
#echo "could not found ${elf_name}"
continue
fi
((depth++))
if [[ ${dep_list[-1]} = ${elf_name} ]]; then
last_child_mask[$depth]=1
else
last_child_mask[$depth]=0
fi
file_path=${file_list[0]}
print_file_path ${file_path}
if [[ ${DRAW_WITH_DOT} -eq 1 ]]; then
draw_in_dot ${target} ${file_path}
fi
if [[ $(echo ${file_path} | grep "") ]]; then
dependencies_scan ${file_path}
elif [[ $depth -lt ${MAX_DEPTH} ]]; then
dependencies_scan ${file_path}
fi
((depth--))
done
}
function main() {
if [[ ${DRAW_WITH_DOT} -eq 1 ]]; then
generate_dot_header
fi
if [[ ${SAVE_IN_CSV} -eq 1 ]]; then
rm -rf ${CSV_SOURCE_FILE}
fi
print_file_path ${ROOT_ELF_PATH}
dependencies_scan ${ROOT_ELF_PATH}
if [[ ${DRAW_WITH_DOT} -eq 1 ]]; then
generate_dot_footer
if [[ $(which dot) ]]; then
dot -Tpng -o ${DOT_OUTPUT_FILE} ${DOT_SOURCE_FILE}
else
echo "Could not find \"dot\" command, please install graphviz!"
fi
fi
}
main
推荐阅读
-
通过使用 Prelink 优化程序启动速度
-
中文顶刊上用准自然实验识别的实证文章有哪些?有的附程序和code, 不看至少需要收藏一下!-经济研究 [1]刘啟仁,赵灿.税收政策激励与企业人力资本升级[J].经济研究,2020,55(04):70-85. [2]李广众,朱佳青,李杰,李新春.经理人相对绩效评价与企业并购行为:理论与实证[J].经济研究,2020,55(03):65-82. [3]张克中,欧阳洁,李文健.缘何“减税难降负”:信息技术、征税能力与企业逃税[J].经济研究,2020,55(03):116-132. [4]周波,赵国昌.中国间接税税负归宿研究:汽车市场准自然实验的证据[J].经济研究,2020,55(03):133-147. [5]毛其淋.贸易政策不确定性是否影响了中国企业进口?[J].经济研究,2020,55(02):148-164. [6]刘瑞明,毛宇,亢延锟.制度松绑、市场活力激发与旅游经济发展——来自中国文化*改革的证据[J].经济研究,2020,55(01):115-131. [7]施新政,高文静,陆瑶,李蒙蒙.资本市场配置效率与劳动收入份额——来自股权分置改革的证据[J].经济研究,2019,54(12):21-37. [8]王永钦,吴娴.中国创新型货币政策如何发挥作用:抵押品渠道[J].经济研究,2019,54(12):86-101. [9]唐宜红,俞峰,林发勤,张梦婷.中国高铁、贸易成本与企业出口研究[J].经济研究,2019,54(07):158-173. [10]张琦,郑瑶,孔东民.地区环境治理压力、高管经历与企业环保投资——一项基于《环境空气质量标准(2012)》的准自然实验[J].经济研究,2019,54(06):183-198. [11]冯晨,陈舒,白彩全.长期人力资本积累的历史根源:制度差异、儒家文化传播与国家能力塑造[J].经济研究,2019,54(05):146-163. [12]刘柏惠,寇恩惠,杨龙见.增值税多档税率、资源误置与全要素生产率损失[J].经济研究,2019,54(05):113-128. [13]陈林,万攀兵.《京都议定书》及其清洁发展机制的减排效应——基于中国参与全球环境治理微观项目数据的分析[J].经济研究,2019,54(03):55-71. [14]范子英,赵仁杰.法治强化能够促进污染治理吗?——来自环保法庭设立的证据[J].经济研究,2019,54(03):21-37. [15]夏怡然,陆铭.跨越世纪的城市人力资本足迹——历史遗产、政策冲击和劳动力流动[J].经济研究,2019,54(01):132-149. [16]毛其淋.人力资本推动中国加工贸易升级了吗?[J].经济研究,2019,54(01):52-67. [17]齐绍洲,林屾,崔静波.环境权益交易市场能否诱发绿色创新?——基于我国上市公司绿色专利数据的证据[J].经济研究,2018,53(12):129-143. [18]李明,李德刚,冯强.中国减税的经济效应评估——基于所得税分享改革“准自然试验”[J].经济研究,2018,53(07):121-135. [19]陈德球,陈运森.政策不确定性与上市公司盈余管理[J].经济研究,2018,53(06):97-111. [20]杜鹏程,徐舒,吴明琴.劳动保护与农民工福利改善——基于新《劳动合同法》的视角[J].经济研究,2018,53(03):64-78. [21]许和连,王海成.简政放权改革会改善企业出口绩效吗?——基于出口退(免)税审批权下放的准自然试验[J].经济研究,2018,53(03):157-170. [22]苏冬蔚,倪博.转融券制度、卖空约束与股价变动[J].经济研究,2018,53(03):110-125. [23]毕青苗,陈希路,徐现祥,李书娟.行政审批改革与企业进入[J].经济研究,2018,53(02):140-155. [24]李艳,杨汝岱.地方国企依赖、资源配置效率改善与供给侧改革[J].经济研究,2018,53(02):80-94. [25]陈林.自然垄断与混合所有制改革——基于自然实验与成本函数的分析[J].经济研究,2018,53(01):81-96. [26]赵西亮.教育、户籍转换与城乡教育收益率差异[J].经济研究,2017,52(12):164-178. [27]陆蓉,何婧,崔晓蕾.资本市场错误定价与产业结构调整[J].经济研究,2017,52(11):104-118. [28]*生,李好,马伟力,林秉旋.融资融券交易的信息治理效应[J].经济研究,2017,52(11):150-164. [29]钱雪松,方胜.担保物权制度改革影响了民营企业负债融资吗?——来自中国《物权法》自然实验的经验证据[J].经济研究,2017,52(05):146-160. [30]王朝阳,王振霞.涨跌停、融资融券与股价波动率——基于AH股的比较研究[J].经济研究,2017,52(04):151-165. [31]范子英,彭飞.“营改增”的减税效应和分工效应:基于产业互联的视角[J].经济研究,2017,52(02):82-95. [32]马述忠,张洪胜.集群商业信用与企业出口——对中国出口扩张奇迹的一种解释[J].经济研究,2017,52(01):13-27. [33]余明桂,钟慧洁,范蕊.业绩考核制度可以促进央企创新吗?[J].经济研究,2016,51(12):104-117. [34]林卉,许尤洋,刘峰.中国资本市场“框架效应”现象的实证研究——基于中组部18号文的自然实验[J].经济研究,2016,51(12):161-175. [35]刘啟仁,黄建忠.人民币汇率、依市场定价与资源配置效率[J].经济研究,2016,51(12):18-31. [36]叶青,赵良玉,刘思辰.独立董事“政商旋转门”之考察:一项基于自然实验的研究[J].经济研究,2016,51(06):98-113. [37]范子英,彭飞,刘冲.政治关联与经济增长——基于卫星灯光数据的研究[J].经济研究,2016,51(01):114-126. [38]毛其淋,许家云.中间品贸易*化与制造业就业变动——来自中国加入WTO的微观证据[J].经济研究,2016,51(01):69-83. [39]赵绍阳,臧文斌,尹庆双.医疗保障水平的福利效果[J].经济研究,2015,50(08):130-145. [40]*生,陈晨,林秉旋.卖空机制提高了中国股票市场的定价效率吗?——基于自然实验的证据[J].经济研究,2015,50(04):165-177. [41]李科,徐龙炳,朱伟骅.卖空限制与股票错误定价——融资融券制度的证据[J].经济研究,2014,49(10):165-178. [42]简泽,张涛,伏玉林.进口*化、竞争与本土企业的全要素生产率——基于中国加入WTO的一个自然实验[J].经济研究,2014,49(08):120-132. [43]范子英,李欣.部长的政治关联效应与财政转移支付分配[J].经济研究,2014,49(06):129-141. [44]陈刚,李树.司法独立与市场分割——以法官异地交流为实验的研究[J].经济研究,2013,48(09):30-42+70. [45]范子英,田彬彬.税收竞争、税收执法与企业避税[J].经济研究,2013,48(09):99-111. [46]简泽,干春晖,余典范.银行部门的市场化、信贷配置与工业重构[J].经济研究,2013,48(05):112-127. [47]李树,陈刚.环境管制与生产率增长——以APPCL2000的修订为例[J].经济研究,2013,48(01):17-31. [48]马双,张劼,朱喜.最低工资对中国就业和工资水平的影响[J].经济研究,2012,47(05):132-146. [49]白重恩,李宏彬,吴斌珍.医疗保险与消费:来自新型农村合作医疗的证据[J].经济研究,2012,47(02):41-53. [50]叶光亮,邓国营,黎志刚.个人住房贷款行为与房贷调控的有效性分析[J].经济研究,2011,46(S1):105-115. 经济学季刊 [1]王剑程,李丁,马双.宽带建设对农户创业的影响研究——基于“宽带乡村”建设的准自然实验[J].经济学(季刊),2020,19(01):209-232. [2]李仲飞,于守金,曹夏平.产业信贷政策对于房地产企业债务的影响——基于银行业359号“限贷”文件的准自然实验分析[J].经济学(季刊),2019,18(04):1373-1396. [3]吕铁,王海成.放松银行准入管制与企业创新——来自股份制商业银行在县域设立分支机构的准自然试验[J].经济学(季刊),2019,18(04):1443-1464. [4]陈晓红,朱蕾,汪阳洁.驻地效应——来自国家土地督察的经验证据[J].经济学(季刊),2019,18(01):99-122. [5]刘行,叶康涛,陆正飞.加速折旧政策与企业投资——基于“准自然实验”的经验证据[J].经济学(季刊),2019,18(01):213-234. [6]毛其淋,许家云.外资进入如何影响了本土企业出口国内附加值?[J].经济学(季刊),2018,17(04):1453-1488. [7]王智波,韩希.废止收容遣送制度的经济影响——基于检验最优城市理论的实证研究[J].经济学(季刊),2018,17(03):1013-1034. [8]卢盛峰,吴一平,谢潇.历史名片的经济价值——来自中国城市更名的证据[J].经济学(季刊),2018,17(03):1055-1078. [9]郭峰,熊瑞祥.地方金融机构与地区经济增长——来自城商行设立的准自然实验[J].经济学(季刊),2018,17(01):221-246. [10]*,李培鑫,李丽霞.*合作、市场整合与城市群经济绩效——基于长三角城市经济协调会的实证检验[J].经济学(季刊),2017,16(04):1563-1582. [11]边文龙,王向楠,李冉.保险费率市场化效果的解释和评估[J].经济学(季刊),2017,16(04):1477-1498. [12]刘怡,耿纯,赵仲匡.出口退税*间分担对产品出口的影响[J].经济学(季刊),2017,16(03):1011-1030. [13]倪骁然,朱玉杰.卖空压力影响企业的风险行为吗?——来自A股市场的经验证据[J].经济学(季刊),2017,16(03):1173-1198. [14]毛其淋,许家云.中间品贸易*化提高了企业加成率吗?——来自中国的证据[J].经济学(季刊),2017,16(02):485-524. [15]刘瑞明,赵仁杰.匿名审稿制度推动了中国的经济学进步吗?——基于双重差分方法的研究[J].经济学(季刊),2017,16(01):173-204. [16]范子英,田彬彬.政企合谋与企业逃税:来自国税局长异地交流的证据[J].经济学(季刊),2016,15(04):1303-1328. [17]丘心颖,郑小翠,邓可斌.分析师能有效发挥专业解读信息的作用吗?——基于汉字年报复杂性指标的研究[J].经济学(季刊),2016,15(04):1483-1506. [18]马榕,石晓军.中国债券信用评级结果具有甄别能力吗?——基于盈余管理敏感性的视角[J].经济学(季刊),2016,15(01):197-216. [19]李楠,林矗.太平天国战争对近代人口影响的再估计——基于历史自然实验的实证分析[J].经济学(季刊),2015,14(04):1325-1346. [20]管汉晖,陈博凯.货币的非国家化:汉代中国的经历(前175—前144年)[J].经济学(季刊),2015,14(04):1497-1518. [21]陈思霞,卢盛峰.分权增加了民生性财政支出吗?——来自中国“省直管县”的自然实验[J].经济学(季刊),2014,13(04):1261-1282. [22]马双,孟宪芮,甘犁.养老保险企业缴费对员工工资、就业的影响分析[J].经济学(季刊),2014,13(03):969-1000. [23]马双,甘犁.最低工资对企业在职培训的影响分析[J].经济学(季刊),2014,13(01):1-26. [24]何浩然.公共政策的效果能否被准确预测?来自中国塑料袋使用限制政策的自然实验证据[J].经济学(季刊),2012,11(04):1305-1322. [25]雷晓燕.管理医疗模式的影响差异——来自加州医疗救助的经验证据[J].经济学(季刊),2010,9(01):333-348. 管理世界 [1]李永友,王超.集权式财政改革能够缩小城乡差距吗?——基于“乡财县管”准自然实验的证据[J].管理世界,2020,36(04):113-130. [2]肖静华,胡杨颂,吴瑶.成长品:数据驱动的企业与用户互动创新案例研究[J].管理世界,2020,36(03):183-205. [3]贾建民,耿维,徐戈,郝辽钢,贾轼.大数据行为研究趋势:一个“时空关”的视角[J].管理世界,2020,36(02):106-116+211-212. [4]黄俊威,龚光明.融资融券制度与公司资本结构动态调整——基于“准自然实验”的经验证据[J].管理世界,2019,35(10):64-81. [5]陈林,万攀兵,许莹盈.混合所有制企业的股权结构与创新行为——基于自然实验与断点回归的实证检验[J].管理世界,2019,35(10):186-205. [6]刘冲,刘晨冉,孙腾.交通基础设施、金融约束与县域产业发展——基于“国道主干线系统”自然实验的证据[J].管理世界,2019,35(07):78-88+203. [7]周茂,李雨浓,姚星,陆毅.人力资本扩张与中国城市制造业出口升级:来自高校扩招的证据[J].管理世界,2019,35(05):64-77+198-199. [8]陈胜蓝,马慧.贷款可获得性与公司商业信用——中国利率市场化改革的准自然实验证据[J].管理世界,2018,34(11):108-120+149. [9]毛其淋,许家云.贸易政策不确定性与企业储蓄行为——基于中国加入WTO的准自然实验[J].管理世界,2018,34(05):10-27+62+179. [10]赵静,*昌,刘峰.高铁开通与股价崩盘风险[J].管理世界,2018,34(01):157-168+192. [11]钟覃琳,陆正飞.资本市场开放能提高股价信息含量吗?——基于“沪港通”效应的实证检验[J].管理世界,2018,34(01):169-179. [12]叶菁菁,吴燕,陈方豪,王宇晴.个人所得税减免会增加劳动供给吗?——来自准自然实验的证据[J].管理世界,2017(12):20-32+187. [13]谢贞发,严瑾,李培.中国式“压力型”财政激励的财源增长效应——基于取消农业税改革的实证研究[J].管理世界,2017(12):46-60+187-188. [14]刘行,赵健宇,叶康涛.企业避税、债务融资与债务融资来源——基于所得税征管*改革的断点回归分析[J].管理世界,2017(10):113-129. [15]李超,李涵.空气污染对企业库存的影响——基于我国制造业企业数据的实证研究[J].管理世界,2017(08):95-105. [16]李文贵,余明桂,钟慧洁.央企董事会试点、国有上市公司代理成本与企业绩效[J].管理世界,2017(08):123-135+153. [17]陈胜蓝,马慧.卖空压力与公司并购——来自卖空管制放松的准自然实验证据[J].管理世界,2017(07):142-156. [18]申广军,邹静娴.企业规模、政企关系与实际税率——来自世界银行“投资环境调查”的证据[J].管理世界,2017(06):23-36. [19]卢盛峰,陈思霞.*偏袒缓解了企业融资约束吗?——来自中国的准自然实验[J].管理世界,2017(05):51-65+187-188. [20]顾乃康,周艳利.卖空的事前威慑、公司治理与企业融资行为——基于融资融券制度的准自然实验检验[J].管理世界,2017(02):120-134. [21]权小锋,尹洪英.中国式卖空机制与公司创新——基于融资融券分步扩容的自然实验[J].管理世界,2017(01):128-144+187-188. [22]倪骁然,朱玉杰.劳动保护、劳动密集度与企业创新——来自2008年《劳动合同法》实施的证据[J].管理世界,2016(07):154-167. [23]许伟,陈斌开.税收激励和企业投资——基于2004~2009年增值税转型的自然实验[J].管理世界,2016(05):9-17. [24]范子英,刘甲炎.为买房而储蓄——兼论房产税改革的收入分配效应[J].管理世界,2015(05):18-27+187. [25]李涵,唐丽淼.交通基础设施投资、空间溢出效应与企业库存[J].管理世界,2015(04):126-136. [26]贾俊雪,宁静.纵向财政治理结构与地方*职能优化——基于省直管县财政*改革的拟自然实验分析[J].管理世界,2015(01):7-17+187. [27]余淼杰,梁中华.贸易*化与中国劳动收入份额——基于制造业贸易企业数据的实证分析[J].管理世界,2014(07):22-31. [28]刘行,叶康涛.金融发展、产权与企业税负[J].管理世界,2014(03):41-52. [29]李泽广,马泽昊.契约环境、代理成本与企业投资—债务期限关系[J].管理世界,2013(08):183-185. [30]叶青,李增泉,李光青.富豪榜会影响企业会计信息质量吗?——基于政治成本视角的考察[J].管理世界,2012(01):104-120. [31]郑新业,王晗,赵益卓.“省直管县”能促进经济增长吗?——双重差分方法[J].管理世界,2011(08):34-44+65. [32]王贤彬,聂海峰.行政区划调整与经济增长[J].管理世界,2010(04):42-53. [33]贾明,张喆.高管的政治关联影响公司慈善行为吗?[J].管理世界,2010(04):99-113+187. [34]聂辉华,方明月,李涛.增值税转型对企业行为和绩效的影响——以东北地区为例[J].管理世界,2009(05):17-24+35. [35]攀登,施东晖,宋铮.证券市场泡沫的生成机理分析——基于宝钢权证自然实验的实证研究[J].管理世界,2008(04):15-23+186. 世界经济 [1]吉赟,杨青.高铁开通能否促进企业创新:基于准自然实验的研究[J].世界经济,2020,43(02):147-166. [2]毛其淋,方森辉.外资进入*化如何影响中国制造业生产率[J].世界经济,2020,43(01):143-169. [3]刘灿雷,王永进.出口扩张与企业间工资差距:影响与机制[J].世界经济,2019,42(12):99-120. [4]林志帆,龙晓旋.卖空威胁能否激励中国企业创新[J].世界经济,2019,42(09):126-150. [5]李嘉楠,代谦,庄嘉霖.开放、市场整合与经济空间变迁:基于近代中国开埠的证据[J].世界经济,2019,42(09):27-51. [6]李磊,王小霞,蒋殿春,方森辉.中国最低工资上升是否导致了外资撤离[J].世界经济,2019,42(08):97-120. [7]郭俊杰,方颖,杨阳.排污费征收标准改革是否促进了中国工业二氧化硫减排[J].世界经济,2019,42(01):121-144. [8]蒋灵多,陆毅,陈勇兵.市场机制是否有利于僵尸企业处置:以外资管制放松为例[J].世界经济,2018,41(09):121-145. [9]施震凯,邵军,浦正宁.交通基础设施改善与生产率增长:来自铁路大提速的证据[J].世界经济,2018,41(06):127-151. [10]李胜旗,毛其淋.关税政策不确定性如何影响就业与工资[J].世界经济,2018,41(06):28-52. [11]曾建光,步丹璐,饶品贵.无偿划转、*补贴与社会福利[J].世界经济,2017,40(07):147-168. [12]马双,邱光前.最低工资对中国劳动密集型出口产品价格的影响[J].世界经济,2016,39(11):80-103. [13]周茂,陆毅,符大海.贸易*化与中国产业升级:事实与机制[J].世界经济,2016,39(10):78-102. [14]彭飞,范子英.税收优惠、捐赠成本与企业捐赠[J].世界经济,2016,39(07):144-167. [15]代谦,别朝霞.财政压力的经济后果:以宋朝的“靖康之变”为例[J].世界经济,2015,38(01):173-192. [16]戴觅,茅锐.外需冲击、企业出口与内销:金融危机时期的经验证据[J].世界经济,2015,38(01):81-104. [17]田巍,余淼杰.中间品贸易*化和企业研发:基于中国数据的经验分析[J].世界经济,2014,37(06):90-112. [18]刘甲炎,范子英.中国房产税试点的效果评估:基于合成控制法的研究[J].世界经济,2013,36(11):117-135. [19]王永进,盛丹.经济波动、劳动力市场摩擦与产业结构[J].世界经济,2013,36(04):22-46. [20]何浩然,陈叶烽.禀赋获得方式影响被试行为是否存在性别差异:来自自然现场实验的证据[J].世界经济,2012,35(04):102-117. [21]周浩,郑筱婷.交通基础设施质量与经济增长:来自中国铁路提速的证据[J].世界经济,2012,35(01):78-97. [22]冯皓,陆铭.通过买房而择校:教育影响房价的经验证据与政策含义[J].世界经济,2010,33(12):89-104. [23]曾海舰,苏冬蔚.信贷政策与公司资本结构[J].世界经济,2010,33(08):17-42. 金融研究 [1]吕朝凤,毛霞.地方金融发展能够影响FDI的区位选择吗?——一个基于城市商业银行设立的准自然实验[J].金融研究,2020(03):58-76. [2]许红梅,李春涛.劳动保护、社保压力与企业违约风险——基于《社会保险法》实施的研究[J].金融研究,2020(03):115-133. [3]胡珺,黄楠,沈洪涛.市场激励型环境规制可以推动企业技术创新吗?——基于中国碳排放权交易机制的自然实验[J].金融研究,2020(01):171-189. [4]诸竹君,黄先海,王煌.交通基础设施改善促进了企业创新吗?——基于高铁开通的准自然实验[J].金融研究,2019(11):153-169. [5]鲁元平,赵颖,石智雷.产假政策与子女长期人力资本积累[J].金融研究,2019(11):57-74. [6]刘杰,陈佳,刘力.投资者关注与市场反应——来自中国证券交易所交易公开信息的自然实验[J].金融研究,2019(11):189-206. [7]陈胜蓝,刘晓玲.中国城际高铁与商业信用供给——基于准自然实验的研究[J].金融研究,2019(10):117-134. [8]张*,王永进,李坤望.贸易*化对制造业企业现金储蓄的影响——预防性动机还是投资挤压?[J].金融研究,2019(09):19-38. [9]段白鸽,王永钦,夏梦嘉.金融创新如何缓解信任品市场失灵?——中国食品安全责任强制保险的自然实验[J].金融研究,2019(09):75-93. [10]陈运森,黄健峤.股票市场开放与企业投资效率——基于“沪港通”的准自然实验[J].金融研究,2019(08):151-170. [11]钱雪松,唐英伦,方胜.担保物权制度改革降低了企业债务融资成本吗?——来自中国《物权法》自然实验的经验证据[J].金融研究,2019(07):115-134. [12]卞元超,吴利华,白俊红.高铁开通是否促进了区域创新?[J].金融研究,2019(06):132-149. [13]杨筝,王红建,戴静,许传华.放松利率管制、利润率均等化与实体企业“脱实向虚”[J].金融研究,2019(06):20-38. [14]张鹏杨,徐佳君,刘会政.产业政策促进全球价值链升级的有效性研究——基于出口加工区的准自然实验[J].金融研究,2019(05):76-95. [15]杨青,吉赟,王亚男.高铁能提升分析师盈余预测的准确度吗?——来自上市公司的证据[J].金融研究,2019(03):168-188. [16]李建军,韩珣.普惠金融、收入分配和贫困减缓——推进效率和公平的政策框架选择[J].金融研究,2019(03):129-148. [17]李广众,贾凡胜.*财政激励、税收征管动机与企业盈余管理——以财政“省直管县”改革为自然实验的研究[J].金融研究,2019(02):78-97. [18]王永钦,徐鸿恂.杠杆率如何影响资产价格?——来自中国债券市场自然实验的证据[J].金融研究,2019(02):20-39. [19]毛其淋.外资进入*化如何影响了中国本土企业创新?[J].金融研究,2019(01):72-90. [20]苏冬蔚,连莉莉.绿色信贷是否影响重污染企业的投融资行为?[J].金融研究,2018(12):123-137. [21]郑志刚,刘思敏,黄继承.我国上市公司策略性股票更名:战略转型还是高位*?[J].金融研究,2018(10):158-173. [22]陈康,刘琦.股价信息含量与投资-股价敏感性——基于融资融券的准自然实验[J].金融研究,2018(09):126-142. [23]朱莹,王健.市场约束能够降低地方债风险溢价吗?——来自城投债市场的证据[J].金融研究,2018(06):56-72. [24]王永钦,陈映辉,熊雅文.存款保险制度如何影响公众对不同银行的信心?——来自中国的证据[J].金融研究,2018(06):109-122. [25]王芳,陈硕,王瑾.农业税减免、农业发展与地方*行为——县级证据[J].金融研究,2018(04):104-120. [26]叶康涛,刘芳,李帆.股指成份股调整与股价崩盘风险:基于一项准自然实验的证据[J].金融研究,2018(03):172-189. [27]王红建,杨筝,阮刚铭,曹瑜强.放松利率管制、过度负债与债务期限结构[J].金融研究,2018(02):100-117. [28]姜军,申丹琳,江轩宇,伊志宏.债权人保护与企业创新[J].金融研究,2017(11):128-142. [29]王攀娜,罗宏.放松卖空管制对分析师预测行为的影响——来自中国准自然实验的证据[J].金融研究,2017(11):191-206. [30]李春涛,刘贝贝,周鹏.卖空与信息披露:融券准自然实验的证据[J].金融研究,2017(09):130-145. [31]胡婷,惠凯,彭红枫.异常波动停牌对股价波动性和流动性的影响研究——来自我国取消异常波动停牌的自然实验[J].金融研究,2017(09):146-160. [32]杨晓兰,金雪军.我国股票市场熔断机制的磁力效应:基于自然实验的证据[J].金融研究,2017(09):161-177. [33]曹春方,陈露兰,张婷婷.“法律的名义”:司法独立性提升与公司违规[J].金融研究,2017(05):191-206. [34]杨筝,刘放,李茫茫.利率市场化、非效率投资与资本配置——基于中国人民银行取消贷款利率上下限的自然实验[J].金融研究,2017(05):81-96. [35]王兵,戴敏,武文杰.环保基地政策提高了企业环境绩效吗?——来自东莞市企业微观面板数据的证据[J].金融研究,2017(04):143-160. [36]冯根福,刘虹,冯照桢,温军.股票流动性会促进我国企业技术创新吗?[J].金融研究,2017(03):192-206. [37]侯青川,靳庆鲁,刘阳.放松卖空管制与公司现金价值——基于中国资本市场的准自然实验[J].金融研究,2016(11):112-127. [38]张三峰,张伟.融资约束、金融发展与企业雇佣——来自中国企业调查数据的经验证据[J].金融研究,2016(10):111-126. [39]王茂斌,孔东民.反腐败与中国公司治理优化:一个准自然实验[J].金融研究,2016(08):159-174. [40]卢盛峰,陈思霞.政策偏袒的经济收益:来自中国工业企业出口的证据[J].金融研究,2016(07):33-47. [41]张龙耀,杨骏,程恩江.融资杠杆监管与小额贷款公司“覆盖率-可持续性”权衡——基于分层监管的准自然实验[J].金融研究,2016(06):142-158. [42]陈海强,韩乾,吴锴.融资约束抑制技术效率提升吗?——基于制造业微观数据的实证研究[J].金融研究,2015(10):148-162. [43]*生,杜爽,林秉旋.卖空交易与股票价格稳定性——来自中国融资融券市场的自然实验[J].金融研究,2015(06):173-188. [44]汪小圈,张红,刘冲.幼年饥荒经历对个人自雇选择的影响[J].金融研究,2015(05):18-33. [45]曾建光,伍利娜,王立彦,諶家蘭.技术进步、信息透明度与开放式基金的资金流量——基于中国开放式基金强制采用XBRL的证据[J].金融研究,2014(08):131-145. [46]马光荣,刘明,杨恩艳.银行授信、信贷紧缩与企业研发[J].金融研究,2014(07):76-93. [47]梁中华,余淼杰.人民币升值与中国出口企业盈利能力——基于面板数据的实证分析[J].金融研究,2014(07):1-15. [48]简泽.银行债权治理、管理者偏好与国有企业的绩效[J].金融研究,2013(01):135-148. [49]余静文.信贷约束、股利分红与企业预防性储蓄动机——来自中国A股上市公司的证据[J].金融研究,2012(10):97-110. 统计研究 [1]王亚飞,廖甍,王亚菲.高铁开通促进了农业全要素生产率增长吗?——来自长三角地区准自然实验的经验证据[J].统计研究,2020,37(05):40-53. [2]胡宗义,李毅.环境信息披露的污染减排效应评估[J].统计研究,2020,37(04):59-74. [3]严文龙,陈宋生,田至立.审计定价管制与交易剩余——2010年审计定价管制失效的自然实验[J/OL].统计研究:1-11[2020-06-05].http://kns.cnki.net/kcms/detail/11.1302.C.20200325.1534.002.html. [4]王立勇,许明.中国精准扶贫政策的减贫效应研究:来自准自然实验的经验证据[J].统计研究,2019,36(12):15-26. [5]许家云.互联网如何影响工业结构升级?——基于互联网商用的自然实验[J].统计研究,2019,36(12):55-67. [6]邹伟,梁平汉.腾飞的翅膀:机场属地化改革与企业库存[J].统计研究,2019,36(11):76-89. [7]徐超,庞保庆,张充.降低实体税负能否遏制制造业企业“脱实向虚”[J].统计研究,2019,36(06):42-53. [8]卢盛峰,陈思霞,张东杰.*推动型城市化促进了县域经济发展吗[J].统计研究,2017,34(05):59-68. [9]许坤,苏扬.逆周期资本监管、监管压力与银行信贷研究[J].统计研究,2016,33(03):97-105. 中国工业经济 [1]谭小芬,钱佳琪.资本市场压力与企业策略性专利行为:卖空机制的视角[J].中国工业经济,2020(05):156-173. [2]于新亮,上官熠文,于文广,李倩.养老保险缴费率、资本——技能互补与企业全要素生产率[J].中国工业经济,2019(12):96-114. [3]饶品贵,王得力,李晓溪.高铁开通与供应商分布决策[J].中国工业经济,2019(10):137-154. [4]王雄元,卜落凡.国际出口贸易与企业创新——基于“中欧班列”开通的准自然实验研究[J].中国工业经济,2019(10):80-98. [5]黄溶冰,赵谦,王丽艳.自然资源资产离任审计与空气污染防治:“和谐锦标赛”还是“环保资格赛”[J].中国工业经济,2019(10):23-41. [6]张国建,佟孟华,李慧,陈飞.扶贫改革试验区的经济增长效应及政策有效性评估[J].中国工业经济,2019(08):136-154. [7]孟庆斌,李昕宇,张修平.卖空机制、资本市场压力与公司战略选择[J].中国工业经济,2019(08):155-173. [8]徐思,何晓怡,钟凯.“一带一路”倡议与中国企业融资约束[J].中国工业经济,2019(07):155-173. [9]任胜钢,郑晶晶,刘东华,陈晓红.排污权交易机制是否提高了企业全要素生产率——来自中国上市公司的证据[J].中国工业经济,2019(05):5-23. [10]宋贺,段军山.财务顾问与企业并购绩效[J].中国工业经济,2019(05):155-173. [11]史贝贝,冯晨,康蓉.环境信息披露与外商直接投资结构优化[J].中国工业经济,2019(04):98-116. [12]王桂军,卢潇潇.“一带一路”倡议与中国企业升级[J].中国工业经济,2019(03):43-61. [13]魏悦羚,张洪胜.进口*化会提升中国出口国内增加值率吗——基于总出口核算框架的重新估计[J].中国工业经济,2019(03):24-42. [14]孙雪娇,翟淑萍,于苏.柔性税收征管能否缓解企业融资约束——来自纳税信用评级披露自然实验的证据[J].中国工业经济,2019(03):81-99. [15]吴晓晖,郭晓冬,乔政.机构投资者抱团与股价崩盘风险[J].中国工业经济,2019(02):117-135. [16]贾俊雪,李紫霄,秦聪.社会保障与经济增长:基于拟自然实验的分析[J].中国工业经济,2018(11):42-60. [17]刘友金,曾小明.房产税对产业转移的影响:来自重庆和上海的经验证据[J].中国工业经济,2018(11):98-116. [18]蒋灵多,陆毅.市场竞争加剧是否助推国有企业加杠杆[J].中国工业经济,2018(11):155-173. [19]钱雪松,康瑾,唐英伦,曹夏平.产业政策、资本配置效率与企业全要素生产率——基于中国2009年十大产业振兴规划自然实验的经验研究[J].中国工业经济,2018(08):42-59. [20]诸竹君,黄先海,余骁.进口中间品质量、自主创新与企业出口国内增加值率[J].中国工业经济,2018(08):116-134. [21]李蕾蕾,盛丹.地方环境立法与中国制造业的行业资源配置效率优化[J].中国工业经济,2018(07):136-154. [22]李贲,吴利华.开发区设立与企业成长:异质性与机制研究[J].中国工业经济,2018(04):79-97. [23]龙小宁,林菡馨.专利执行保险的创新激励效应[J].中国工业经济,2018(03):116-135. [24]周茂,陆毅,杜艳,姚星.开发区设立与地区制造业升级[J].中国工业经济,2018(03):62-79. [25]余静文.企业国有化中的*角色[J].中国工业经济,2018(03):155-173. [26]刘瑞明,李林,亢延锟,赵勇.景点评选、*公共服务供给与地区旅游经济发展[J].中国工业经济,2018(02):118-136. [27]王永进,冯笑.行政审批制度改革与企业创新[J].中国工业经济,2018(02):24-42. [28]史贝贝,冯晨,张妍,杨菲.环境规制红利的边际递增效应[J].中国工业经济,2017(12):40-58. [29]蒋灵多,陆毅.最低工资标准能否抑制新僵尸企业的形成[J].中国工业经济,2017(11):118-136. [30]张小茜,孙璐佳.抵押品清单扩大、过度杠杆化与企业破产风险——动产抵押法律改革的“双刃剑”效应[J].中国工业经济,2017(07):175-192. [31]龙小宁,万威.环境规制、企业利润率与合规成本规模异质性[J].中国工业经济,2017(06):155-174. [32]简泽,谭利萍,吕大国,符通.市场竞争的创造性、破坏性与技术升级[J].中国工业经济,2017(05):16-34. [33]王兵,聂欣.产业集聚与环境治理:助力还是阻力——来自开发区设立准自然实验的证据[J].中国工业经济,2016(12):75-89. [34]林乐,郑登津.退市监管与股价崩盘风险[J].中国工业经济,2016(12):58-74. [35]何靖.延付高管薪酬对银行风险承担的政策效应——基于银行盈余管理动机视角的PSM-DID分析[J].中国工业经济,2016(11):126-143. [36]龙小宁,张训常,杨进.转轨背景下官员兼职规制的经济效应[J].中国工业经济,2016(07):40-56. [37]罗知,赵奇伟,严兵.约束机制和激励机制对国有企业长期投资的影响[J].中国工业经济,2015(10):69-84. [38]赵晶,张书博,祝丽敏.传承人合法性对家族企业战略变革的影响[J].中国工业经济,2015(08):130-144. [39]吴海民,吴淑娟,陈辉.城市文明、交易成本与企业“第四利润源”——基于全国文明城市与民营上市公司核匹配倍差法的证据[J].中国工业经济,2015(07):114-129. [40]范子英.土地财政的根源:财政压力还是投资冲动[J].中国工业经济,2015(06):18-31. [41]韩超,胡浩然.清洁生产标准规制如何动态影响全要素生产率——剔除其他政策干扰的准自然实验分析[J].中国工业经济,2015(05):70-82. [42]唐明哲,刘丰波,林平.价格检验在相关市场界定中的实证运用——对茅台、五粮液垄断案的再思考[J].中国工业经济,2015(04):135-148. 会计研究 [1]朱焱,王玉丹.卖空机制与企业社会责任承担——基于中国融资融券制度的准自然实验研究[J].会计研究,2019(12):58-64. [2]刘行,赵健宇.税收激励与企业创新——基于增值税转型改革的“准自然实验”[J].会计研究,2019(09):43-49. [3]崔学刚,邓衢,邝文俊.卖空交易、市场行情与股价崩盘风险[J].会计研究,2019(06):43-50. [4]张金丹,路军,李连华.审计报告中披露关键审计事项信息有助于提高审计质量吗?——报表盈余和市场感知双维度的经验证据[J].会计研究,2019(06):85-91. [5]陈运森,黄健峤,韩慧云.股票市场开放提高现金股利水平了吗?——基于“沪港通”的准自然实验[J].会计研究,2019(03):55-62. [6]钱雪松,代禹斌,陈琳琳,方胜.担保物权制度改革、融资约束与企业现金持有——基于中国《物权法》自然实验的经验证据[J].会计研究,2019(01):72-78. [7]王仲兵,王攀娜.放松卖空管制与企业投资效率——来自中国资本市场的经验证据[J].会计研究,2018(09):80-87. [8]郝颖,谢光华,石锐.外部监管、在职消费与企业绩效[J].会计研究,2018(08):42-48. [9]吴战篪,陈相伊,吴伟立.融资融券制度与资产增长效应[J].会计研究,2017(06):89-95+97. [10]李丹,袁淳,廖冠民.卖空机制与分析师乐观性偏差——基于双重差分模型的检验[J].会计研究,2016(09):25-31. [11]刘运国,刘梦宁.雾霾影响了重污染企业的盈余管理吗?——基于政治成本假说的考察[J].会计研究,2015(03):26-33+94. [12]王春飞,陆正飞.事务所“改制”、保险价值与投资者保护[J].会计研究,2014(05):81-87+95. [13]陈运森,郑登津,李路.民营企业发审委社会关系、IPO资格与上市后表现[J].会计研究,2014(02):12-19+94. [14]曾建光,伍利娜,谌家兰,王立彦.XBRL、代理成本与绩效水平——基于中国开放式基金市场的证据[J].会计研究,2013(11):88-94+96. 世界经济文汇 [1]蓝嘉俊,方颖,魏下海.性别比失衡下的婚姻匹配与劳动力市场表现——基于独生子女政策准自然实验的实证分析[J].世界经济文汇,2019(04):67-84. [2]赵琳,唐珏,陈诗一.环保管理*垂直化改革的环境治理效应[J].世界经济文汇,2019(02):100-120. [3]周梦天,王之.空气质量信息公开会影响城市房价吗?——基于我国各城市公开PM2.5监测数据的自然实验[J].世界经济文汇,2018(03):20-42. [4]傅家范,刘冲.*注资、存款优势与国有银行反危机信贷投放[J].世界经济文汇,2017(05):75-90. [5]刘金山,*.对口支援政策有效吗?——来自19省市对口援疆自然实验的证据[J].世界经济文汇,2017(04):43-61. [6]陈怡安.父母政治身份、职位背景与子女创业[J].世界经济文汇,2017(01):26-50. [7]范子英.为买房而离婚——基于住房限购政策的研究[J].世界经济文汇,2016(04):1-17. 中国人口、资源与环境 [1]王为东,王冬,卢娜.中国碳排放权交易促进低碳技术创新机制的研究[J].中国人口·资源与环境,2020,30(02):41-48. [2]胡江峰,黄庆华,潘欣欣.碳排放交易制度与企业创新质量:抑制还是促进[J].中国人口·资源与环境,2020,30(02):49-59. [3]张晖,吴霜,张燕媛,虞祎.流域生态补偿政策对受偿地区经济增长的影响研究——以安徽省黄山市为例[J].长江流域资源与环境,2019,28(12):2848-2856. [4]刘常建,许为宾,蔡兰,张孝静.环保压力与重污染企业的银行贷款契约——基于“PM_(2.5)爆表”事件的经验证据[J].中国人口·资源与环境,2019,29(12):121-130. [5]龚梦琪,刘海云,姜旭.中国低碳试点政策对外商直接投资的影响研究[J].中国人口·资源与环境,2019,29(06):50-57. [6]尤济红,陈喜强.区域一体化合作是否导致污染转移——来自长三角城市群扩容的证据[J].中国人口·资源与环境,2019,29(06):118-129. [7]翟华云,刘亚伟.环境司法专门化促进了企业环境治理吗?——来自专门环境法庭设置的准自然实验[J].中国人口·资源与环境,2019,29(06):138-147. [8]张楠,卢洪友,黄健.资源枯竭城市转移支付对经济增长的影响[J].中国人口·资源与环境,2019,29(04):147-156. [9]赵领娣,徐乐.基于长三角扩容准自然实验的区域一体化水污染效应研究[J].中国人口·资源与环境,2019,29(03):50-61. [10]温湖炜,周凤秀.环境规制与中国省域绿色全要素生产率——兼论对《环境保护税法》实施的启示[J].干旱区资源与环境,2019,33(02):9-15. [11]景守武,张捷.新安江流域横向生态补偿降低水污染强度了吗?[J].中国人口·资源与环境,2018,28(10):152-159. [12]黄志平.碳排放权交易有利于碳减排吗?——基于双重差分法的研究[J].干旱区资源与环境,2018,32(09):32-36. [13]雷平,曹黎明,赵连荣.乡土官员对区域经济与环境发展路径的影响[J].中国人口·资源与环境,2018,28(04):163-176. [14]何文剑,徐静文,张红霄.森林采伐限额管理制度能否起到保护森林资源的作用[J].中国人口·资源与环境,2016,26(07):128-136. [15]何浩然,陈安来.中国限制塑料袋使用的政策效果及国际经验借鉴[J].中国人口·资源与环境,2010,20(11):167-174. 中国农村经济 [1]罗斯炫,何可,张俊飚.增产加剧污染?——基于粮食主产区政策的经验研究[J].中国农村经济,2020(01):108-131. [2]丁从明,吴羽佳,秦姝媛,梁甄桥.社会信任与公共政策的实施效率——基于农村居民新农保参与的微观证据[J].中国农村经济,2019(05):109-123. [3]胡新艳,陈小知,米运生.农地整合确权政策对农业规模经营发展的影响评估——来自准自然实验的证据[J].中国农村经济,2018(12):83-102. [4]周振,张琛,彭超,孔祥智.农业机械化与农民收入:来自农机具购置补贴政策的证据[J].中国农村经济,2016(02):68-82. 国际贸易问题 [1]曾守桢,余官胜.行政审批简化与我国对外直接投资增长——基于核准权下放试点的准自然实验实证研究[J].国际贸易问题,2020(04):19-34. [2]刘冲,张辉,吴群锋.进口竞争与企业产品专业化——基于中国多产品企业的研究[J].国际贸易问题,2020(03):22-39. [3]高翔,袁凯华.清洁生产环境规制与企业出口技术复杂度——微观证据与影响机制[J].国际贸易问题,2020(02):93-109. [4]吴嵩博,崔凡.融资约束与中国企业出口市场偏好——基于开发区准自然实验的实证分析[J].国际贸易问题,2020(02):157-174. [5]杨珍增,杨宏.美国“301调查”征税清单调整的政治经济学分析[J].国际贸易问题,2020(01):82-93. [6]张彩云.科技标准型环境规制与企业出口动态——基于清洁生产标准的一次自然实验[J].国际贸易问题,2019(12):32-45. [7]王毅,黄先海,余骁.环境规制是否降低了中国企业出口国内附加值率[J].国际贸易问题,2019(10):117-131. [8]兰健,张洪胜.集群商业信用与出口产品质量——来自中国企业层面的证据[J].国际贸易问题,2019(09):12-25. [9]黄先海,王煌,陈航宇.人口集聚如何影响出口企业加成率:理论机制与经验证据[J].国际贸易问题,2019(07):1-18. [10]张鹏杨,李众宜,毛海涛.产业政策如何影响企业出口二元边际[J].国际贸易问题,2019(07):47-62. [11]孙林,胡玲菲,方巧云.中国*贸易区战略提升中国进口食品质量了吗——基于双重差分模型[J].国际贸易问题,2019(05):54-68. [12]胡浩然.产业政策如何影响出口企业绩效——基于出口加工区企业样本的准自然实验[J].国际贸易问题,2018(12):27-38. [13]章韬,戚人杰.集聚-出口双促进政策的溢出效应——来自出口加工区的微观企业证据[J].国际贸易问题,2017(03):26-38. [14]彭冬冬,杜运苏.中间品贸易*化、融资约束与贸易方式转型[J].国际贸易问题,2016(12):52-63. [15]杜艳,周茂,李雨浓.贸易*化能否提高中国制造业企业资源再配置效率——基于中国加入WTO的倍差法分析[J].国际贸易问题,2016(09):38-49. [16]项后军,何康.自贸区的影响与资本流动——以上海为例的自然实验研究[J].国际贸易问题,2016(08):3-15. [17]刘啟仁,黄建忠.贸易*化、企业动态与行业生产率变化——基于我国加入WTO的自然实验[J].国际贸易问题,2016(01):27-37. [18]申萌,曾燕萍,曲如晓.环境规制与企业出口:来自千家企业节能行动的微观证据[J].国际贸易问题,2015(08):43-50. 南开管理评论 [1]田利辉,王可第.腐败惩治的正外部性和企业创新行为[J].南开管理评论,2020,23(02):121-131+154. [2]胡宁,王雪方,孙莲珂,靳庆鲁.房产限购政策有助于实体企业“脱虚返实”吗——基于双重差分研究设计[J].南开管理评论,2019,22(04):20-31. [3]马惠娴,佟爱琴.卖空机制对高管薪酬契约的治理效应——来自融资融券制度的准自然实验[J].南开管理评论,2019,22(02):61-74. [4]何威风,陈莉萍,刘巍.业绩考核制度会影响企业盈余管理行为吗[J].南开管理评论,2019,22(01):17-30. [5]田轩,孟清扬.股权激励计划能促进企业创新吗[J].南开管理评论,2018,21(03):176-190. [6]陈怡欣,张俊瑞,汪方军.卖空机制对上市公司创新的影响研究——基于我国融资融券制度的自然实验[J].南开管理评论,2018,21(02):62-74. [7]黄俊,黄超,位豪强,王敏.卖空机制提高了分析师盈余预测质量吗——基于融资融券制度的经验证据[J].南开管理评论,2018,21(02):135-148. [8]孙光国,孙瑞琦.控股股东委派执行董事能否提升公司治理水平[J].南开管理评论,2018,21(01):88-98+108. [9]沈洪涛,周艳坤.环境执法监督与企业环境绩效:来自环保约谈的准自然实验证据[J].南开管理评论,2017,20(06):73-82. [10]李茫茫,黎文靖.审计具有保险功能吗——基于*官员变更的自然实验[J].南开管理评论,2017,20(04):93-104. [11]陈运森,郑登津.董事网络关系、信息桥与投资趋同[J].南开管理评论,2017,20(03):159-171. [12]贾凡胜,吴昱,廉柯赟.股利税差别化、现金分红与代理问题——基于财税[2012]85号文件的研究[J].南开管理评论,2016,19(01):142-154. [13]徐莉萍,辛宇.媒体治理与中小投资者保护[J].南开管理评论,2011,14(06):36-47+94. 管理科学学报 [1]李沁洋,许年行.资本市场对外开放与股价崩盘风险——来自沪港通的证据[J].管理科学学报,2019,22(08):108-126. [2]张岩,吴芳,吴晓晖.IPO募资双重管制与资源配置——基于自然实验的经验证据[J].管理科学学报,2018,21(11):76-91. [3]刘志红,王艺明.“省直管县”改革能否提升县级财力水平?[J].管理科学学报,2018,21(10):1-13. [4]陈胜蓝,卢锐.卖空压力与控股股东私利侵占——来自卖空管制放松的准自然实验证据[J].管理科学学报,2018,21(04):67-85. [5]金宇超,靳庆鲁,严青蕾.合谋与胁迫:作为经济主体的媒体行为——基于新闻敲诈曝光的事件研究[J].管理科学学报,2018,21(03):1-22. [6]才静涵,夏乐.卖空制度、流动性与信息不对称问题研究——香港市场的个案[J].管理科学学报,2011,14(02):71-85. [7]王志强,吴世农.我国股票市场透明度变革效应研究[J].管理科学学报,2008,11(05):110-119. 社会学研究 [1]哈巍,赵颖.教学相“涨”:高校学生成绩和评教分数双重膨胀研究[J].社会学研究,2019,34(01):84-105+243-244. [2]程诚.同伴社会资本与学业成就——基于随机分配自然实验的案例分析[J].社会学研究,2017,32(06):141-164+245. 中国的准自然实验真多!
-
测试事物 (I) - 同步和异步 - 同步:当函数调用启动时,调用不会返回或调用者不会继续执行后续操作,直到获得该调用的结果。异步:异步与同步相反,当发出异步过程调用时,调用者可以继续执行后续操作,直到调用者得到结果。调用完成后,通常会通过状态(轮询)、通知(消息)和回调通知调用者。对于异步调用,调用的返回不受调用者的控制。 从上述定义中我们可以看出,同步和异步可以由调用者或被调用者控制。我们暂且将调用者视为客户端,而被调用者视为服务器。 在客户端调用服务器接口后,如果客户端需要等待服务器返回结果才能进行下一步,那么它就是同步的。如果在进行下一步之前不需要等待服务器返回结果,那么它就是同步的。如果在进行下一步之前不需要等待服务器的结果,那么它就是异步的。 服务器本身既可以控制同步,也可以控制异步。对于需要长时间计算的函数,服务器会将其设置为异步,在客户端发出请求后立即向客户端返回结果,这没有任何实际意义,只是表示服务器收到了请求。对于很快就能得到结果的请求,使用同步就很好,返回的结果包含了得到这个请求所需的数据。 那么,同步测试和异步测试需要注意什么呢? 1. 用户体验 现在很多 APP 都有审核的功能,需要用户提供各种信息来完成相应的认证。这些审核可以是自动的,也可以是手动的等。自动审核一般比较快,因为它需要用户提供各种信息来完成相应的认证。自动审核一般比较快,因为需要比对的数据都存在服务器端,直接进行程序比对即可。人工审核则比较慢,快的几分钟,如果赶上周末,2-3 天都不一定。因此,对于自动审核和人工审核,需要合理利用同步和异步,达到最佳的用户体验。 自动审核速度快,用户提交信息后稍微等待一下就应该能得到审核结果,最多在客户端等待不超过 5 秒,看到加载等待一会儿就可以了。在这种情况下,使用同步就非常合适了,客户端没有得到结果,等到服务器端把审核结果传回来马上显示在客户端上,用户的体验会非常好,毕竟很快就得到了答案。 人工审核时,我们不能寄希望于总有一个人一直在那里审核,即使有,快的话也要几分钟,毕竟核对数据什么的都是人工的。用户在这种情况下不能等,但也不能总在这个页面上等。于是异步就派上用场了,客户端发出审核请求,服务器收到后马上告诉客户端我收到了,但不可能给出结果。客户端不管有没有收到服务器的请求,都会告诉用户等待 XX 时间才能查看结果,用户不需要在这个页面上一直等待。直到服务器端计算完成,然后通过推送消息通知客户端,或者用户再次进入身份验证页面进行身份验证结果请求时,才会得知自己的身份验证结果。 进行测试时,如果遇到长时间无法获取结果的界面,建议客户端使用异步请求,以减少用户体验不佳的情况!
-
ssh工作流程及原理-SSH(Secure Shell Protocol,安全的壳程序协议),它可以通过数据包加密技术将等待传输的数据包加密后再传输到网络上。ssh协议本身提供两个服务器功能:一个是类似telnet的远程连接使用shell的服务器;另一个就是类似ftp服务的sftp-server,提供更安全的ftp服务。 连接加密技术简介 目前常见的网络数据包加密技术通常是通过“非对称密钥系统”来处理的。主要通过两把不一样的公钥与私钥来进行加密与解密的过程。 公钥(public key):提供给远程主机进行数据加密的行为,所有人都可获得你的公钥来将数据加密。 私钥(private key):远程主机使用你的公钥加密的数据,在本地端就能够使用私钥来进行解密。私钥只有自己拥有。 SSH工作过程:在整个通讯过程中,为实现SSH的安全连接,服务端与客户端要经历如下五个阶段: 版本号协商阶段 SSH目前包括SSH1和SSH2两个版本,双方通过版本协商确定使用的版本 密钥和算法协商阶段 SSH支持多种加密算法,双方根据本端和对端支持的算法,协商出最终使用的算法 认证阶段 SSH客户端向服务器端发起认证请求,服务器端对客户端进行认证 会话请求阶段 认证通过后,客户端向服务器端发送会话请求 交互会话阶段 会话请求通过后,服务器端和客户端进行信息的交互 一、版本协商阶段 服务器端打开端口22,等待客户端连接; 客户端向服务器端发起TCP初始连接请求,TCP连接建立后,服务器向客户端发送第一个报文,包括版本标志字符串,格式为“SSH-<主协议版本号>.<次协议版本号>.<软件版本号>”,协议版本号由主版本号和次版本号组成,软件版本号主要是为调试使用。 客户端收到报文后,解析该数据包,如果服务器的协议版本号比自己的低,且客户端能支持服务器端的低版本,就使用服务器端的低版本协议号,否则使用自己的协议版本号。 客户端回应服务器一个报文,包含了客户端决定使用的协议版本号。服务器比较客户端发来的版本号,决定是否能同客户端一起工作。如果协商成功,则进入密钥和算法协商阶段,否则服务器断开TCP连接。 说明:上述报文都是采用明文方式传输。 二、密钥和算法协商阶段 服务器端和客户端分别发送算法协商报文给对端,报文中包含自己支持的公钥算法列表、加密算法列表、MAC(Message Authentication Code,消息验证码)算法列表、压缩算法列表等等。 服务器端和客户端根据对端和本端支持的算法列表得出最终使用的算法。 服务器端和客户端利用DH交换(Diffie-Hellman Exchange)算法、主机密钥对等参数,生成会话密钥和会话ID。 由此,服务器端和客户端就取得了相同的会话密钥和会话ID。对于后续传输的数据,两端都会使用会话密钥进行加密和解密,保证了数据传送的安全。在认证阶段,两端会使用会话用于认证过程。 会话密钥的生成: 客户端需要使用适当的客户端程序来请求连接服务器,服务器将服务器的公钥发送给客户端。(服务器的公钥产生过程:服务器每次启动sshd服务时,该服务会主动去找/etc/ssh/ssh_host*文件,若系统刚装完,由于没有这些公钥文件,因此sshd会主动去计算出这些需要的公钥文件,同时也会计算出服务器自己所需要的私钥文件。) 服务器生成会话ID,并将会话ID发给客户端。 若客户端第一次连接到此服务器,则会将服务器的公钥数据记录到客户端的用户主目录内的~/.ssh/known_hosts。若是已经记录过该服务器的公钥数据,则客户端会去比对此次接收到的与之前的记录是否有差异。客户端生成会话密钥,并用服务器的公钥加密后,发送给服务器。 ****服务器用自己的私钥将收到的数据解密,获得会话密钥。 服务器和客户端都知道了会话密钥,以后的传输都将被会话密钥加密。 三、认证阶段 SSH提供两种认证方法: 基于口令的认证(password认证):客户端向服务器发出password认证请求,将用户名和密码加密后发送给服务器,服务器将该信息解密后得到用户名和密码的明文,与设备上保存的用户名和密码进行比较,并返回认证成功或失败消息。 基于密钥的认证(publickey认证):客户端产生一对公共密钥,将公钥保存到将要登录的服务器上的那个账号的家目录的.ssh/authorized_keys文件中。认证阶段:客户端首先将公钥传给服务器端。服务器端收到公钥后会与本地该账号家目录下的authorized_keys中的公钥进行对比,如果不相同,则认证失败;否则服务端生成一段随机字符串,并先后用客户端公钥和会话密钥对其加密,发送给客户端。客户端收到后将解密后的随机字符串用会话密钥发送给服务器。如果发回的字符串与服务器端之前生成的一样,则认证通过,否则,认证失败。 注:服务器端对客户端进行认证,如果认证失败,则向客户端发送认证失败消息,其中包含可以再次认证的方法列表。客户端从认证方法列表中选取一种认证方法再次进行认证,该过程反复进行。直到认证成功或者认证次数达到上限,服务器关闭连接为止。实例
-
包婷婷 (201550484)作业一 统计软件简介与数据操作-SPSS(Statistical Product and Service Solutions),"统计产品与服务解决方案"软件。最初软件全称为"(SolutionsStatistical Package for the Social Sciences),但是随着SPSS产品服务领域的扩大和服务深度的增加,SPSS公司已于2000年正式将英文全称更改为"统计产品与服务解决方案",标志着SPSS的战略方向正在做出重大调整。为IBM公司推出的一系列用于统计学分析运算、数据挖掘、预测分析和决策支持任务的软件产品及相关服务的总称SPSS,有Windows和Mac OS X等版本。 1984年SPSS总部首先推出了世界上第一个统计分析软件微机版本SPSS/PC+,开创了SPSS微机系列产品的开发方向,极大地扩充了它的应用范围,并使其能很快地应用于自然科学、技术科学、社会科学的各个领域。世界上许多有影响的报刊杂志纷纷就SPSS的自动统计绘图、数据的深入分析、使用方便、功能齐全等方面给予了高度的评价。 R统计软件介绍 R是一套完整的数据处理、计算和制图软件系统。其功能包括:数据存储和处理系统;数组运算工具(其向量、矩阵运算方面功能尤其强大);完整连贯的统计分析工具;优秀的统计制图功能;简便而强大的编程语言:可操纵数据的输入和输出,可实现分支、循环,用户可自定义功能。 与其说R是一种统计软件,还不如说R是一种数学计算的环境,因为R并不是仅仅提供若干统计程序、使用者只需指定数据库和若干参数便可进行一个统计分析。R的思想是:它可以提供一些集成的统计工具,但更大量的是它提供各种数学计算、统计计算的函数,从而使使用者能灵活机动的进行数据分析,甚至创造出符合需要的新的统计计算方法。 该语言的语法表面上类似 C,但在语义上是函数设计语言(functional programming language)的变种并且和Lisp 以及 APL有很强的兼容性。特别的是,它允许在"语言上计算"(computing on the language)。这使得它可以把表达式作为函数的输入参数,而这种做法对统计模拟和绘图非常有用。 R是一个免费的*软件,它有UNIX、LINUX、MacOS和WINDOWS版本,都是可以免费下载和使用的。在R主页那儿可以下载到R的安装程序、各种外挂程序和文档。在R的安装程序中只包含了8个基础模块,其他外在模块可以通过CRAN获得。 二、R语言 R是用于统计分析、绘图的语言和操作环境。R是属于GNU系统的一个*、免费、源代码开放的软件,它是一个用于统计计算和统计制图的优秀工具。 R作为一种统计分析软件,是集统计分析与图形显示于一体的。它可以运行于UNIX,Windows和Macintosh的操作系统上,而且嵌入了一个非常方便实用的帮助系统,相比于其他统计分析软件,R还有以下特点: 1.R是*软件。这意味着它是完全免费,开放源代码的。可以在它的网站及其镜像中下载任何有关的安装程序、源代码、程序包及其源代码、文档资料。标准的安装文件身自身就带有许多模块和内嵌统计函数,安装好后可以直接实现许多常用的统计功能。[2] 2.R是一种可编程的语言。作为一个开放的统计编程环境,语法通俗易懂,很容易学会和掌握语言的语法。而且学会之后,我们可以编制自己的函数来扩展现有的语言。这也就是为什么它的更新速度比一般统计软件,如,SPSS,SAS等快得多。大多数最新的统计方法和技术都可以在R中直接得到。[2] 3. 所有R的函数和数据集是保存在程序包里面的。只有当一个包被载入时,它的内容才可以被访问。一些常用、基本的程序包已经被收入了标准安装文件中,随着新的统计分析方法的出现,标准安装文件中所包含的程序包也随着版本的更新而不断变化。在另外版安装文件中,已经包含的程序包有:base一R的基础模块、mle一极大似然估计模块、ts一时间序列分析模块、mva一多元统计分析模块、survival一生存分析模块等等.[2] 4.R具有很强的互动性。除了图形输出是在另外的窗口处,它的输入输出窗口都是在同一个窗口进行的,输入语法中如果出现错误会马上在窗口口中得到提示,对以前输入过的命令有记忆功能,可以随时再现、编辑修改以满足用户的需要。输出的图形可以直接保存为JPG,BMP,PNG等图片格式,还可以直接保存为PDF文件。另外,和其他编程语言和数据库之间有很好的接口。[2] 5.如果加入R的帮助邮件列表一,每天都可能会收到几十份关于R的邮件资讯。可以和全球一流的统计计算方面的专家讨论各种问题,可以说是全世界最大、最前沿的统计学家思维的聚集地.[2] R是基于S语言的一个GNU项目,所以也可以当作S语言的一种实现,通常用S语言编写的代码都可以不作修改的在R环境下运行。 R的语法是来自Scheme。R的使用与S-PLUS有很多类似之处,这两种语言有一定的兼容性。S-PLUS的使用手册,只要稍加修改就可作为R的使用手册。所以有人说:R,是S-PLUS的一个“克隆”。 但是请不要忘了:R是免费的(R is free)。R语言源代码托管在github,具体地址可以看参考资料。[3] 。 R语言的下载可以通过CRAN的镜像来查找。 R语言有域名为.cn的下载地址,有六个,其中两个由Datagurn,由 中国科学技术大学提供的。R语言Windows版,其中由两个下载地点是Datagurn和 USTC提供的。 三、stata Stata 是一套提供其使用者数据分析、数据管理以及绘制专业图表的完整及整合性统计软件。它提供许许多多功能,包含线性混合模型、均衡重复反复及多项式普罗比模式。用Stata绘制的统计图形相当精美。 新版本的STATA采用最具亲和力的窗口接口,使用者自行建立程序时,软件能提供具有直接命令式的语法。Stata提供完整的使用手册,包含统计样本建立、解释、模型与语法、文献等超过一万余页的出版品。 除此之外,Stata软件可以透过网络实时更新每天的最新功能,更可以得知世界各地的使用者对于STATA公司提出的问题与解决之道。使用者也可以透过Stata. Journal获得许许多多的相关讯息以及书籍介绍等。另外一个获取庞大资源的管道就是Statalist,它是一个独立的listserver,每月交替提供使用者超过1000个讯息以及50个程序。 四、PYTHON
-
epoll简介及触发模式(accept、read、send)-epoll的简单介绍 epoll在LT和ET模式下的读写方式 一、epoll的接口非常简单,一共就三个函数:1. int epoll_create(int size);创建一个epoll的句柄,size用来告诉内核这个监听的数目一共有多大。这个参数不同于select中的第一个参数,给出最大监听的fd+1的值。需要注意的是,当创建好epoll句柄后,它就是会占用一个fd值,在linux下如果查看/proc/进程id/fd/,是能够看到这个fd的,所以在使用完epoll后,必须调用close关闭,否则可能导致fd被耗尽。2. int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);epoll的事件注册函数,它不同与select是在监听事件时告诉内核要监听什么类型的事件,而是在这里先注册要监听的事件类型。第一个参数是epoll_create的返回值,第二个参数表示动作,用三个宏来表示:EPOLL_CTL_ADD:注册新的fd到epfd中;EPOLL_CTL_MOD:修改已经注册的fd的监听事件;EPOLL_CTL_DEL:从epfd中删除一个fd;第三个参数是需要监听的fd,第四个参数是告诉内核需要监听什么事,struct epoll_event结构如下:struct epoll_event { __uint32_t events; /* Epoll events */ epoll_data_t data; /* User data variable */};events可以是以下几个宏的集合:EPOLLIN :表示对应的文件描述符可以读(包括对端SOCKET正常关闭); EPOLLIN事件:EPOLLIN事件则只有当对端有数据写入时才会触发,所以触发一次后需要不断读取所有数据直到读完EAGAIN为止。否则剩下的数据只有在下次对端有写入时才能一起取出来了。现在明白为什么说epoll必须要求异步socket了吧?如果同步socket,而且要求读完所有数据,那么最终就会在堵死在阻塞里。 EPOLLOUT:表示对应的文件描述符可以写; EPOLLOUT事件:EPOLLOUT事件只有在连接时触发一次,表示可写,其他时候想要触发,那要先准备好下面条件:1.某次write,写满了发送缓冲区,返回错误码为EAGAIN。2.对端读取了一些数据,又重新可写了,此时会触发EPOLLOUT。简单地说:EPOLLOUT事件只有在不可写到可写的转变时刻,才会触发一次,所以叫边缘触发,这叫法没错的!其实,如果真的想强制触发一次,也是有办法的,直接调用epoll_ctl重新设置一下event就可以了,event跟原来的设置一模一样都行(但必须包含EPOLLOUT),关键是重新设置,就会马上触发一次EPOLLOUT事件。1. 缓冲区由满变空.2.同时注册EPOLLIN | EPOLLOUT事件,也会触发一次EPOLLOUT事件这个两个也会触发EPOLLOUT事件 EPOLLPRI:表示对应的文件描述符有紧急的数据可读(这里应该表示有带外数据到来);EPOLLERR:表示对应的文件描述符发生错误;EPOLLHUP:表示对应的文件描述符被挂断;EPOLLET: 将EPOLL设为边缘触发(Edge Triggered)模式,这是相对于水平触发(Level Triggered)来说的。EPOLLONESHOT:只监听一次事件,当监听完这次事件之后,如果还需要继续监听这个socket的话,需要再次把这个socket加入到EPOLL队列里3. int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int timeout);等待事件的产生,类似于select调用。参数events用来从内核得到事件的集合,maxevents告之内核这个events有多大,这个maxevents的值不能大于创建epoll_create时的size,参数timeout是超时时间(毫秒,0会立即返回,-1将不确定,也有说法说是永久阻塞)。该函数返回需要处理的事件数目,如返回0表示已超时。-------------------------------------------------------------------------------------------- 从man手册中,得到ET和LT的具体描述如下EPOLL事件有两种模型:Edge Triggered (ET)Level Triggered (LT)假如有这样一个例子:1. 我们已经把一个用来从管道中读取数据的文件句柄(RFD)添加到epoll描述符2. 这个时候从管道的另一端被写入了2KB的数据3. 调用epoll_wait(2),并且它会返回RFD,说明它已经准备好读取操作4. 然后我们读取了1KB的数据5. 调用epoll_wait(2)......Edge Triggered 工作模式:如果我们在第1步将RFD添加到epoll描述符的时候使用了EPOLLET标志,那么在第5步调用epoll_wait(2)之后将有可能会挂起,因为剩余的数据还存在于文件的输入缓冲区内,而且数据发出端还在等待一个针对已经发出数据的反馈信息。只有在监视的文件句柄上发生了某个事件的时候 ET 工作模式才会汇报事件。因此在第5步的时候,调用者可能会放弃等待仍在存在于文件输入缓冲区内的剩余数据。在上面的例子中,会有一个事件产生在RFD句柄上,因为在第2步执行了一个写操作,然后,事件将会在第3步被销毁。因为第4步的读取操作没有读空文件输入缓冲区内的数据,因此我们在第5步调用 epoll_wait(2)完成后,是否挂起是不确定的。epoll工作在ET模式的时候,必须使用非阻塞套接口,以避免由于一个文件句柄的阻塞读/阻塞写操作把处理多个文件描述符的任务饿死。最好以下面的方式调用ET模式的epoll接口,在后面会介绍避免可能的缺陷。 i 基于非阻塞文件句柄 ii 只有当read(2)或者write(2)返回EAGAIN时才需要挂起,等待。但这并不是说每次read时都需要循环读,直到读到产生一个EAGAIN才认为此次事件处理完成,当read返回的读到的数据长度小于请求的数据长度时,就可以确定此时缓冲中已没有数据了,也就可以认为此事读事件已处理完成。Level Triggered 工作模式相反的,以LT方式调用epoll接口的时候,它就相当于一个速度比较快的poll(2),并且无论后面的数据是否被使用,因此他们具有同样的职能。因为即使使用ET模式的epoll,在收到多个chunk的数据的时候仍然会产生多个事件。调用者可以设定EPOLLONESHOT标志,在 epoll_wait(2)收到事件后epoll会与事件关联的文件句柄从epoll描述符中禁止掉。因此当EPOLLONESHOT设定后,使用带有 EPOLL_CTL_MOD标志的epoll_ctl(2)处理文件句柄就成为调用者必须作的事情。然后详细解释ET, LT:LT(level triggered)是缺省的工作方式,并且同时支持block和no-block socket.在这种做法中,内核告诉你一个文件描述符是否就绪了,然后你可以对这个就绪的fd进行IO操作。如果你不作任何操作,内核还是会继续通知你的,所以,这种模式编程出错误可能性要小一点。传统的select/poll都是这种模型的代表.ET(edge-triggered)是高速工作方式,只支持no-block socket。在这种模式下,当描述符从未就绪变为就绪时,内核通过epoll告诉你。然后它会假设你知道文件描述符已经就绪,并且不会再为那个文件描述符发送更多的就绪通知,直到你做了某些操作导致那个文件描述符不再为就绪状态了(比如,你在发送,接收或者接收请求,或者发送接收的数据少于一定量时导致了一个EWOULDBLOCK 错误)。但是请注意,如果一直不对这个fd作IO操作(从而导致它再次变成未就绪),内核不会发送更多的通知(only once),不过在TCP协议中,ET模式的加速效用仍需要更多的benchmark确认(这句话不理解)。在许多测试中我们会看到如果没有大量的idle -connection或者dead-connection,epoll的效率并不会比select/poll高很多,但是当我们遇到大量的idle- connection(例如WAN环境中存在大量的慢速连接),就会发现epoll的效率大大高于select/poll。(未测试)另外,当使用epoll的ET模型来工作时,当产生了一个EPOLLIN事件后,读数据的时候需要考虑的是当recv返回的大小如果等于请求的大小,那么很有可能是缓冲区还有数据未读完,也意味着该次事件还没有处理完,所以还需要再次读取: 这里只是说明思路(参考《UNIX网络编程》) while(rs) {buflen = recv(activeevents[i].data.fd, buf, sizeof(buf), 0);if(buflen < 0){// 由于是非阻塞的模式,所以当errno为EAGAIN时,表示当前缓冲区已无数据可读// 在这里就当作是该次事件已处理处.if(errno == EAGAIN)break; else return; }else if(buflen == 0) { // 这里表示对端的socket已正常关闭. } if(buflen == sizeof(buf) rs = 1; // 需要再次读取 else rs = 0; } 还有,假如发送端流量大于接收端的流量(意思是epoll所在的程序读比转发的socket要快),由于是非阻塞的socket,那么send函数虽然返回,但实际缓冲区的数据并未真正发给接收端,这样不断的读和发,当缓冲区满后会产生EAGAIN错误(参考man send),同时,不理会这次请求发送的数据.所以,需要封装socket_send的函数用来处理这种情况,该函数会尽量将数据写完再返回,返回-1表示出错。在socket_send内部,当写缓冲已满(send返回-1,且errno为EAGAIN),那么会等待后再重试.这种方式并不很完美,在理论上可能会长时间的阻塞在socket_send内部,但暂没有更好的办法. ssize_t socket_send(int sockfd, const char* buffer, size_t buflen) { ssize_t tmp; size_t total = buflen; const char *p = buffer; while(1) { tmp = send(sockfd, p, total, 0); if(tmp < 0) { // 当send收到信号时,可以继续写,但这里返回-1. if(errno == EINTR) return -1; // 当socket是非阻塞时,如返回此错误,表示写缓冲队列已满, // 在这里做延时后再重试. if(errno == EAGAIN) { usleep(1000); continue; } return -1; } if((size_t)tmp == total) return buflen; total -= tmp; p += tmp; } return tmp; } 二、epoll在LT和ET模式下的读写方式 在一个非阻塞的socket上调用read/write函数, 返回EAGAIN或者EWOULDBLOCK(注: EAGAIN就是EWOULDBLOCK) 从字面上看, 意思是: * EAGAIN: 再试一次 * EWOULDBLOCK: 如果这是一个阻塞socket, 操作将被block * perror输出: Resource temporarily unavailable 总结: 这个错误表示资源暂时不够, 可能read时, 读缓冲区没有数据, 或者, write时,写缓冲区满了 。 遇到这种情况, 如果是阻塞socket, read/write就要阻塞掉。 而如果是非阻塞socket, read/write立即返回-1, 同 时errno设置为EAGAIN. 所以, 对于阻塞socket, read/write返回-1代表网络出错了. 但对于非阻塞socket, read/write返回-1不一定网络真的出错了. 可能是Resource temporarily unavailable. 这时你应该再试, 直到Resource available. 综上, 对于non-blocking的socket, 正确的读写操作为: 读: 忽略掉errno = EAGAIN的错误, 下次继续读 写: 忽略掉errno = EAGAIN的错误, 下次继续写 对于select和epoll的LT模式, 这种读写方式是没有问题的. 但对于epoll的ET模式, 这种方式还有漏洞. epoll的两种模式 LT 和 ET
-
iCloud 切换区域,中国区保留 appStore(更新)--自 2018 年 2 月 28 日起,中国区 iCloud 由云上贵州管理 苹果公司发布的公告 https://support.apple.com/zh-cn/HT208352 关键词 关键部分 受影响的 iCloud 账户:国家或地区设置为 "中国 "的 Apple ID。 iCloud 包含的服务照片、邮件、通讯录、日历、提醒事项、备忘、书签、钱包、钥匙串、云备份、云驱动器、应用程序数据 新条款和条件: 同意仅出于本协议允许的目的并在中国法律允许的范围内使用服务。 云桂洲在提供服务时应使用合理的技能并尽职尽责,但在适用法律允许的最大范围内,我们不保证或担保您通过本服务存储或访问的任何内容不会意外损坏、崩溃、丢失或根据本协议的条款被删除,如果发生此类损坏、崩溃、丢失或删除,我们不承担任何责任。您应自行负责维护您的信息和数据的适当备份。 Apple 和云上贵州有权访问您存储在服务中的所有数据,包括有权根据适用法律相互之间共享、交换和披露所有用户数据(包括内容)。 本协议的解释、效力和履行应适用*法律。对于因本协议引起的或与本协议有关的任何争议,云桂洲和您同意提交中国国际经济贸易仲裁委员会(CIETAC)根据提交仲裁时有效的法律在北京进行具有约束力的仲裁。 由云桂洲管理,用户选择: 停用; ID 到地区; 受 iCloud(由云桂洲运营)条款和条件约束 首先,我想说说我对数据安全的看法。 当我在朋友圈发布通知时,有些朋友回复说国外的操作并没有多安全,或者国外的安全只是相对于国外而言的等等。首先,我非常感谢这些朋友,这让我反思什么是数据安全。以下观点均属个人观点: 国外的月亮一定比国内圆? 这是一个根深蒂固的问题,只要有人说国外的东西比国内好,就会有人嘲笑崇洋媚外。我觉得我们在某些方面应该向国外学习,比如搜索引擎和版权问题。打开百度搜索 "数据安全",第一行肯定是广告。打开谷歌搜索 "数据安全",第一条就是 "数据安全_百度百科" .....各种版权问题大家都明白,支持正版,但不仅客户一心想找免费破解,就连作者也往往没有保护自己劳动成果或产品的想法。但从另一个层面来说,国内的发展和安全,甩国外几条街。没有说哪里好,哪里不好,辩证地去学习更好。 国外也有别有用心的数据泄露,谈何安全? 从加密解密的角度看,自古以来就没有绝对安全的加密,只有相对安全的做法。苹果的棱镜门、微软的 cpu 漏洞,各种参差不齐的被破解案例 ....是的,这的确是一个很好的论据,但凡事都不能只看一面,当年苹果面对FBI破解手机的要求,几经论证,苹果还是拒绝破解。这点拿到国内,只要上面的文件传达下去,还有企业敢说不吗?还敢说不吗? 关于这次iCloud数据迁移个人看法? 把数据迁移到贵州的云端,相当于把手机的所有数据都存储在贵州的云端服务器上。也许访问数据的速度会快很多,但我会把我的iCloud区放到美国,因为我不想数据存在云上贵州后经常接到莫名其妙的电话或短信,更不想因为乱用国外服务器而被请去喝茶。iCloud一个ID,即从中国账号转到美国区,主要用于数据存在美国服务器上。appStore一个ID,除了注册一个中国ID外,专门用来下载应用用,因为国外ID不支持酷狗和网易云等应用。麻烦的是,用了新的 appStore ID 后,当前的应用还得重新下载安装,因为旧的应用 ID 与新的应用 ID 不兼容,安装不了。最后,iCloud迁移后,国内用户使用美国服务器,估计要 "扶墙 "了。 专业步骤: 首先,进行appleID设置,这是前提条件,否则无法选择转移区域! 取消 appleID 的双重认证 取消家庭共享选项 二、窗口下载并安装 icloud 3.0 版
-
对话NGC蔡岩:从机制创新到价值沉淀,解析DeFi产品开发逻辑 |链捕手 - 真正的DeFi产品首先要有足够的安全性和稳定性,如果能在此基础上有一些功能创新,那就非常好了。像 Uniswap 这样逐渐成为 DeFi 基础架构的产品,可遇而不可求。 链式捕手:固定利率协议之前关注度比较高,但观察下来发现,大部分协议还是类似于传统金融CDO(抵押债务凭证)的玩法,风险系数很高,您如何理解这块业务的价值和风险? 蔡岩:确实有些定息协议类似CDO玩法,背后绑定一个债券,但并不是所有的定息协议都是这样的玩法,像这种CDO玩法的主要代表项目是88mph,背后绑定的是Aave、Compoud这样的借贷协议,在此基础上做定息和浮息债券;像APWine,背后同样是Aave,它会发行期货收益代币来锁定你的收益;Notional本身是做借贷市场的,在此基础上做定息协议。 非 CDO 的玩法,比如 Horizon,更像是一个利率撮合器,背后需要用户通过拍卖产生更合适的目标收益率;像 Saffron、BarnBridge 等是通过风险分级来定义不同的收益率。总的来说,创新还是挺多的。 价值层面是创新和想象力,因为在传统金融领域,比如银行做固定收益证券,或者评级机构给风险分级,这些业务都非常大,利润也很丰厚。而 DeFi 的对口业务给了类似业务很大的想象空间。尤其是固定利率协议的成熟产品不多,尝试各种微创新是很有意义的。 风险程度还是要具体到不同的玩法,比如,在 Aave、Compoud 等借贷协议的固定利率协议背后,如果这些借贷协议受到攻击,与之绑定的固定利率协议也会受损。 同样,如果自己做借贷市场,可能更需要更强的开发能力。再有,如果该程序的机制或参数设计不当,同样会导致协议运行不稳定,并可能造成大量用户清盘。 总的来说,风险在于固定利率协议的设计,这是一个非常复杂的过程,需要不断地尝试和出错。 链式捕捉器:刚刚提到背后是Aave/Compound的固定费率协议风险较大,您认为Aave最大的不确定性和创新点分在哪里? 蔡岩:其实爱钱进一直被认为是走在行业前列的项目,他们的迭代速度非常快,比如率先尝试闪贷、推出新的经济激励模式、推出目前业内首个安全模块、尝试L2解决方案等等。 而在主要的借贷业务上,他们又十分谨慎,比如在抵押率、清算系数等风险参数的设计上相对于其他借贷协议较为保守,并不会存在为了吸引更多借贷资金而降低风险的要求。 与许多 DeFi 项目一样,即使 Aave 进行了多次审计,也无法保证不存在漏洞。前段时间,Aave 刚进入 V2 阶段时,白帽黑客就指出了某个漏洞。 之前的创新点可能是闪电借贷,这是当时业内独一无二的新产品功能,也为 Aave 带来了不少收益。当然,也有人批评闪电贷只能方便黑客实现资金效益的最大化,但工具本身并没有错,未来闪电贷肯定会有更多的应用场景。 其次是安全模块的设计,这有点像项目本身的储备金库,保障项目的安全性,这也是爱维开创的先河。说实话,目前大多数项目都没有做到代币模式的良性或正向运营,也做不到像Aave一样的安全模块,这是一个不小的门槛。 Chaincatcher从某种程度上来说,挖矿模式是DeFi财富效应的根本支撑,但Aave的CEO却说挖矿机制带来的动力是不可持续的,您怎么看这个观点? 蔡岩:"挖矿机制 "不可能失效,因为它是一种激励机制,或者说是项目冷启动的一种方式。但流动性开采亚博体育手机客户端不会一直高涨。比如去年11月的流行性挖矿高APY持续了一两个月就崩盘了,导致DeFi市场大幅回调。 Aave、Uniswap、Synthetix等项目真正爆发进入市值前15名也是在今年2月,我更倾向于这是头部DeFi长期价值的体现。虽然大家都喜欢抢高APY的矿机,但我个人很少参与挖矿,所以我并不觉得流动性挖矿是DeFi的基本面支撑。
-
玩转Java底层:JMX详解 - jconsole与自定义MBean监控工具的实际应用与区别" 在日常JVM调优中,我们熟知的jconsole工具通过JMX包装的bean以图形化形式展示管理数据,而像jstat和jmap这类内建监控工具则由JVM直接支持。本文将以jconsole为例,深入讲解其实质——基于JMX的MBean功能,包括可视化界面上的bean属性查看和操作调用。 MBeans在jconsole中的体现是那些可观察的组件属性和方法,如上图所示,通过名为"Verbose"的属性能看到其值为false,同时还能直接操作该bean的方法,例如"closeJerryMBean"。 尽管jconsole给我们提供了直观的可视化界面,但请注意,这里的MBean并非固定不变,开发者可根据JMX提供的接口将自己的自定义bean展示到jconsole。以下步骤展示了如何创建并注册一个名为"StudyJavaMBean"的自定义MBean: 1. 首先定义接口`StudyJavaMBean`,接口需遵循MBean规范,即后缀为"MBean"且包含getter方法代表属性,如`getApplicationName`,和无返回值的setter方法代表操作,如`closeJerryMBean`。 ```java public interface StudyJavaMBean { String getApplicationName(); void closeJerryMBean(); } ``` 2. 编写接口的实现类`StudyJavaMBeanImpl`,实现接口中的方法: ```java public class StudyJavaMBeanImpl implements StudyJavaMBean { @Override public String getApplicationName() { return "每天学Java"; } @Override public void closeJerryMBean() { System.out.println("关闭Jerry应用"); } } ``` 3. 在代码中注册自定义MBean,涉及的关键步骤包括: - 获取平台MBeanServer - 定义ObjectName,指定唯一的MBean标识符 - 注册MBean到服务器 - 启动RMI连接器服务,以便jconsole能够访问 ```java public void registerMBean() throws Exception { // ... 具体实现省略 ... } ``` 实际运行注册后的MBean,您将在jconsole中发现并查看自定义bean的属性和调用相关方法。然而,这种方式相较于传统的属性/日志查看和HTTP接口,实用性相对有限,可能存在潜在的安全风险。但不可否认的是,JMX及其MBean机制对于获取操作系统信息、内存状态等关键性能指标仍然具有重要价值。例如: 1. **获取操作系统信息**:通过JMX MBean,可以直接获取到诸如CPU使用率、操作系统版本等系统级信息,这对于资源管理和优化工作具有显著帮助。
-
【Netty】「萌新入门」(七)ByteBuf 的性能优化-堆内存的分配和释放都是由 Java 虚拟机自动管理的,这意味着它们可以快速地被分配和释放,但是也会产生一些开销。 直接内存需要手动分配和释放,因为它由操作系统管理,这使得分配和释放的速度更快,但是也需要更多的系统资源。 另外,直接内存可以映射到本地文件中,这对于需要频繁读写文件的应用程序非常有用。 此外,直接内存还可以避免在使用 NIO 进行网络传输时发生数据拷贝的情况。在使用传统的 I/O 时,数据必须先从文件或网络中读取到堆内存中,然后再从堆内存中复制到直接缓冲区中,最后再通过 SocketChannel 发送到网络中。而使用直接缓冲区时,数据可以直接从文件或网络中读取到直接缓冲区中,并且可以直接从直接缓冲区中发送到网络中,避免了不必要的数据拷贝和内存分配。 通过 ByteBufAllocator.DEFAULT.directBuffer 方法来创建基于直接内存的 ByteBuf: ByteBuf directBuf = ByteBufAllocator.DEFAULT.directBuffer(16); 通过 ByteBufAllocator.DEFAULT.heapBuffer 方法来创建基于堆内存的 ByteBuf: ByteBuf heapBuf = ByteBufAllocator.DEFAULT.heapBuffer(16); 注意: 直接内存是一种特殊的内存分配方式,可以通过在堆外申请内存来避免 JVM 堆内存的限制,从而提高读写性能和降低 GC 压力。但是,直接内存的创建和销毁代价昂贵,因此需要慎重使用。 此外,由于直接内存不受 JVM 垃圾回收的管理,我们需要主动释放这部分内存,否则会造成内存泄漏。通常情况下,可以使用 ByteBuffer.clear 方法来释放直接内存中的数据,或者使用 ByteBuffer.cleaner 方法来手动释放直接内存空间。 测试代码: public static void testCreateByteBuf { ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(16); System.out.println(buf.getClass); ByteBuf heapBuf = ByteBufAllocator.DEFAULT.heapBuffer(16); System.out.println(heapBuf.getClass); ByteBuf directBuf = ByteBufAllocator.DEFAULT.directBuffer(16); System.out.println(directBuf.getClass); } 运行结果: class io.netty.buffer.PooledUnsafeDirectByteBuf class io.netty.buffer.PooledUnsafeHeapByteBuf class io.netty.buffer.PooledUnsafeDirectByteBuf 池化技术 在 Netty 中,池化技术指的是通过对象池来重用已经创建的对象,从而避免了频繁地创建和销毁对象,这种技术可以提高系统的性能和可伸缩性。 通过设置 VM options,来决定池化功能是否开启: -Dio.netty.allocator.type={unpooled|pooled} 在 Netty 4.1 版本以后,非 Android 平台默认启用池化实现,Android 平台启用非池化实现; 这里我们使用非池化功能进行测试,依旧使用的是上面的测试代码 testCreateByteBuf,运行结果如下所示: class io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf class io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf class io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf 可以看到,ByteBuf 类由 PooledUnsafeDirectByteBuf 变成了 UnpooledUnsafeDirectByteBuf; 在没有池化的情况下,每次使用都需要创建新的 ByteBuf 实例,这个操作会涉及到内存的分配和初始化,如果是直接内存则代价更为昂贵,而且频繁的内存分配也可能导致内存碎片问题,增加 GC 压力。 使用池化技术可以避免频繁内存分配带来的开销,并且重用池中的 ByteBuf 实例,减少了内存占用和内存碎片问题。另外,池化技术还可以采用类似 jemalloc 的内存分配算法,进一步提升分配效率。 在高并发环境下,池化技术的优点更加明显,因为内存的分配和释放都是比较耗时的操作,频繁的内存分配和释放会导致系统性能下降,甚至可能出现内存溢出的风险。使用池化技术可以将内存分配和释放的操作集中到预先分配的池中,从而有效地降低系统的内存开销和风险。 内存释放 当在 Netty 中使用 ByteBuf 来处理数据时,需要特别注意内存回收问题。 Netty 提供了不同类型的 ByteBuf 实现,包括堆内存(JVM 内存)实现 UnpooledHeapByteBuf 和堆外内存(直接内存)实现 UnpooledDirectByteBuf,以及池化技术实现的 PooledByteBuf 及其子类。 UnpooledHeapByteBuf:通过 Java 的垃圾回收机制来自动回收内存; UnpooledDirectByteBuf:由于 JVM 的垃圾回收机制无法管理这些内存,因此需要手动调用 release 方法来释放内存; PooledByteBuf:使用了池化机制,需要更复杂的规则来回收内存; 由于池化技术的特殊性质,释放 PooledByteBuf 对象所使用的内存并不是立即被回收的,而是被放入一个内存池中,待下次分配内存时再次使用。因此,释放 PooledByteBuf 对象的内存可能会延迟到后续的某个时间点。为了避免内存泄漏和占用过多内存,我们需要根据实际情况来设置池化技术的相关参数,以便及时回收内存; Netty 采用了引用计数法来控制 ByteBuf 对象的内存回收,在博文 「源码解析」ByteBuf 的引用计数机制 中将会通过解读源码的形式对 ByteBuf 的引用计数法进行深入理解; 每个 ByteBuf 对象被创建时,都会初始化为1,表示该对象的初始计数为1。 在使用 ByteBuf 对象过程中,如果当前 handler 已经使用完该对象,需要通过调用 release 方法将计数减1,当计数为0时,底层内存会被回收,该对象也就被销毁了。此时即使 ByteBuf 对象还在,其各个方法均无法正常使用。 但是,如果当前 handler 还需要继续使用该对象,可以通过调用 retain 方法将计数加1,这样即使其他 handler 已经调用了 release 方法,该对象的内存仍然不会被回收。这种机制可以有效地避免了内存泄漏和意外访问已经释放的内存的情况。 一般来说,应该尽可能地保证 retain 和 release 方法成对出现,以确保计数正确。