gitlab: MergeRequest、reset

Merge request

什么是Merge request,多人开发项目时,发起将一个远程分支merge到另一个分支(一般为主分支)的请求。

merge request步骤:

1.如果开发完了某个模块的功能,需要提交到线上。

2.首先,git fetch --all,仓库代码图拉下来,把线上的代码更新后合并到自己的本地分支上。

3.解决冲突

4.再次合并代码,没有问题后,git push origin 本地分支名。这样就会在远程仓库创建一个remotes/origin/本地分支名 的分支。

5.gitlab上,,进入mergeRequest页面,选择newMergeRequest(右上角绿色按钮)。merge

6.选择要merge的source分支,CONTINUE。

7.填写描述,添加reviwer(重要)。

8.等待结果,如果有冲突,需要从头再来。

Reset

bg2014061202

 

git reset 撤销命令

reset有三种模式

git reset --soft HEAD 本地文件不变,撤销掉commit,不撤销index

git reset --hard HEAD 本地文件改为HEAD,所有commit/index都修改掉

git reset HEAD     本地文件不变,撤销掉commit/index

 

如果只想恢复某一个文件,只需要

git checkout filename

恢复所有文件到当前HEAD

git checkout .

 

Ubuntu 14.04系统Apache 2.4.7版本使用mod_headers过滤HTTP响应头中的WP-Super-Cache字段

服务器上面安装了WP-Super-Cache后,服务器的响应报文中会自动增加一个WP-Super-Cache字段,这个字段会暴露服务器的一些细节,而WP-Super-Cache的设置中又没有找到去掉这个字段的设置选项。

如下图:

WP-Super-Cache-Http-Response

比较简单的解决方法就是,使用Apache2自带的mod_headers模块,通过修改.htacess配置文件的方式来去掉这个响应信息。

1.在网站目录下的.htacess文件中增加如下语句

2.启用mod_headers模块

3.重启Apache2服务

Ubuntu 14.04主机优化加速mod_pagespeed安装使用

背景介绍


谷歌优化加速mod_pagespeed作为Apache HTTP Server的module,它能在服务网页请求的即时做出超过15种的优化调整,包括优化缓存,最小化客户端—服务器往返路程,压缩有效传输体积。
经过实验观察,mod_pagespeed最高能使页面加载时间压缩50%。
项目已经被迁移到了GitHub,链接地址为:https://github.com/pagespeed/mod_pagespeed

Apache mod_pagespeed安装方法


1.下载安装包

32位系统

64位系统

鉴于国内被和谐的情况,可以本站下载 64位Ubuntu点击这里 32位Ubuntu点击这里

2.安装

3.重启Apache2

4.检查是否安装成功

5.潜在问题

安装这个插件之后,可能会导致页面在不同操作系统之间的显示错乱问题,目前WordPress上会出现这种问题,应该是缓存导致的问题,因为WordPress会根据系统,浏览器的不同来进行页面兼容处理,如果直接返回缓存数据,反而会出问题。目前暂时只能是禁用这个插件了。

另外,当主机的CPU,内存有限的情况下,这个模块反而增加了系统开销,导致系统响应缓慢。有些Javascript代码被优化后,会工作不正常,目前看来,对小网站来说副作用大于正面作用。

参考链接


主机优化加速mod_pagespeed和ngx_pagespeed安装使用

Ubuntu 14.04使用OpCache提升PHP5.5+程序性能

概述


PHP 5.5以后内建了OpCache,OpCache的加速原理是把编译后的bytecode存储在内存里面, 避免重复编译 PHP 所造成的资源浪费.Ubuntu 14.04默认自带 PHP 5.5.9,已经集成了这个功能。但是默认是不启用的。

启用


修改 php.ini 文件

在文件最后面加入:

重启服务器

效果


加速效果极端明显,强烈建议启用这个功能。

Ubuntu14.04升级到Ubuntu16.04出现错误

Ubuntu14.04升级到Ubuntu16.04出现错误,如下图所示:
from_ubuntu_14_upgrade_ubuntu_16_error
如果机器上安装了postgresql,则是由于postgresql处于升级黑名单中,因此无法升级。
一般建议手工卸载postgresql

卸载完成后继续执行升级命令

具体参考这个BUG的链接:
postgresql packages in the removal blacklist making it hard to upgrade

Ubuntu 14.04编译安装Apache 2.4.20

1.安装开发工具包

2.下载Apache 2.4.20的源代码

3.安装apr依赖库

4.安装pcre

5.解压缩代码

6.配置并编译

参考链接


Ubuntu 14.04系统WordPress 4.5升级到PHP7之后执行插件升级报错“无法定位WordPress内容目录(wp-content)”

Ubuntu 14.04系统上WordPress 4.5升级到PHP7之后执行插件升级报错,

如下图所示:WordPres_wp-content

这个是由于PHP升级之后,有些函数的支持出现了变化,导致调用失败。

目前已知的修复方法是修改wp-admin/includes/class-wp-filesystem-ssh2.php中的如下的几个函数:

修改为:

参考链接


Work around PHP7 php-ssh2 breakage

Ubuntu 14.04(64位)编译安装PHP7.0.5后编译安装libssh2-php

在使用Ubuntu 14.04(64位)源码编译安装PHP7并配置Apache2支持之后,无法直接通过命令安装libssh2-php,因此需要手工编译安装。

1.安装编译libssh2-php需要的依赖库

2.下载libssh2-php的源代码

3.解压缩文件

4.切换到目录

5.使用phpize配置插件编译环境

6.配置编译环境

7.编译并安装

执行之后,文件被安装到了/opt/php-7.0.5/lib/php/extensions/no-debug-zts-20151012目录下面。

8.配置php.ini加载插件

找到如下内容

在最下面增加

9.重启Apache2加载动态模块

gl接口耗时?

调用glclear接口,发现它耗时比较长,翻了翻stackoverflow。

Measuring the elapsed time of an OpenGL API call is mostly meaningless.

研究OpenGL接口的耗时是无意义的。

Asynchronicity

The key aspect to understand is that OpenGL is an API to pass work to a GPU.

The easiest mental model (which largely corresponds to reality) is that when you make OpenGL API calls, you queue up work that will later be submitted to the GPU. For example, if you make a glDraw*() call, picture the call building a work item that gets queued up, and at some point later will be submitted to the GPU for execution.

In other words, the API is highly asynchronous. The work you request by making API calls is not completed by the time the call returns. In most cases, it's not even submitted to the GPU for execution yet. It is only queued up, and will be submitted at some point later, mostly outside your control.

A consequence of this general approach is that the time you measure to make a glClear() call has pretty much nothing to do with how long it takes to clear the framebuffer.

Synchronization

Now that we established how the OpenGL API is asynchronous, the next concept to understand is that a certain level of synchronization is necessary.

Let's look at a workload where the overall throughput is limited by the GPU (either by GPU performance, or because the frame rate is capped by the display refresh). If we kept the whole system entirely asynchronous, and the CPU can produce GPU commands faster than the GPU can process them, we would be queuing up a gradually increasing amount of work. This is undesirable for a couple of reasons:

  • In the extreme case, the amount of queued up work would grow towards infinity, and we would run out of memory just from storing the queued up GPU commands.
  • In apps that need to respond to user input, like games, we would get increasing latency between user input and rendering.

To avoid this, drivers use throttling mechanisms to prevent the CPU from getting too far ahead. The details of how exactly this is handled can be fairly complex. But as a simple model, it might be something like blocking the CPU when it gets more than 1-2 frames ahead of what the GPU has finished rendering. Ideally, you always want some work queued up so that the GPU never goes idle for graphics limited apps, but you want to keep the amount of queued up work as small as possible to minimize memory usage and latency.

Meaning of Your Measurement

With all this background information explained, your measurements should be much less surprising. By far the most likely scenario is that your glClear() call triggers a synchronization, and the time you measure is the time it takes the GPU to catch up sufficiently, until it makes sense to submit more work.

Note that this does not mean that all the previously submitted work needs to complete. Let's look at a sequence that is somewhat hypothetical, but realistic enough to illustrate what can happen:

  • Let's say you make the glClear() call that forms the start of rendering frame n.
  • At this time, frame n - 3 is on the display, and the GPU is busy processing rendering commands for frame n - 2.
  • The driver decides that you really should not be getting more than 2 frames ahead. Therefore, it blocks in your glClear() call until the GPU finished the rendering commands for frame n - 2.
  • It might also decide that it needs to wait until frame n - 2 is shown on the display, which means waiting for the next beam sync.
  • Now that frame n - 2 is on the display, the buffer that previously contained frame n - 3 is not used anymore. It is now ready to be used for frame n, which means that the glClear()command for frame n can now be submitted.

Note that while your glClear() call did all kinds of waiting in this scenario, which you measure as part of the elapsed time spent in the API call, none of this time was used for actually clearing the framebuffer for your frame. You were probably just sitting on some kind of semaphore (or similar synchronization mechanism), waiting for the GPU to complete previously submitted work.

Conclusion

Considering that your measurement is not directly helpful after all, what can you learn from it? Unfortunately not a whole lot.

If you do observe that your frame rate does not meet your target, e.g. because you observe stuttering, or even better because you measure the framerate over a certain time period, the only thing you know for sure is that your rendering is too slow. Going into the details of performance analysis is a topic that is much too big for this format. Just to give you a rough overview of steps you could take:

  • Measure/profile your CPU usage to verify that you are really GPU limited.
  • Use GPU profiling tools that are often available from GPU vendors.
  • Simplify your rendering, or skip parts of it, and see how the performance changes. For example, does it get faster if you simplify the geometry? You might be limited by vertex processing. Does it get faster if you reduce the framebuffer size? Or if you simplify your fragment shaders? You're probably limited by fragment processing.

 

OpenGL是GPU的API

API call是以eventloop的形式工作

但需要一定的同步工作,任务数量太多,延迟会变大,开发者又需要尽快响应用户,GPU需要跟CPU保持一定过得同步。简单的来说,如果CPU发出的绘制指令超出GPU太多(1-2帧),GPU会锁住CPU。

在这个背景下,就可以解释为什么glClear耗时了,因为它触发了一次同步。

已3个缓冲区为例,n-3在绘制,n-2在合成,The driver decides that you really should not be getting more than 2 frames ahead。glClear就会block住,直到GPU工作完。

GPU工作渲染完n-2,glClear就会提交n。

最终结论,绘制太慢导致的。

可以看看CPU消耗,看看是不是CPU被锁住了。

Ubuntu 14.04(64位)源码编译安装PHP7并配置Apache2支持

下载PHP7源代码


解压缩到当前目录


安装编译需要的依赖


安装libxml2-dev

安装gcc

安装依赖的库

安装apache2-dev,否则无法指定--with-apxs2=/usr/bin/apxs来生成libphp7.so

切换到编译目录

配置并编译


配置开启php-fpm支持,开启多线程支持--enable-maintainer-zts,否则无法使用Apache2Event MPM功能。

配置并安装PHP7


拷贝PHP7的配置文件


设置PHP7的配置文件php.ini


PHP7已经默认加载opcache.so了,因此不需要声明zend_extension=opcache.so.

启用Apache2PHP7模块


启用Apache2Event模块


参考链接


ubuntu 14.04上源码编译安装php7
How to install PHP 7 as PHP-FPM & FastCGI for ISPConfig 3 on Debian 8 (Jessie)