bowman 发布的文章

There is a few problems with arch linux shiped docker.

  • only root user can access docker command
  • native overlay diff is off due to kernel settings

first question: only root user can access docker command

that`s duo to your current user is not belongs to docker group

fix:

sudo usermod -aG docker $USER

native overlay diff is off due to kernel settings

well, that`s a bit nasty, you need to turn off some kernel settings and recompile the kernel

you should turn the follow settings off in .config of your kernel source root folder

CONFIG_OVERLAY_FS_REDIRECT_DIR=n
CONFIG_OVERLAY_FS_METACOPY=n

if you are using arch linux, I recommand to use this modified linux-ck kernel

usage:

git clone --depth=1 https://github.com/bugparty/linux-ck-archlinux
cd linux-ck-archlinux
makepkg -s
makepkg -i

At present, gitlab officially does not release the arm64 version of gitlab-runner, so it can only compile itself.
However, I have compiled the arm64 version and wrote a one-click installation script, the usage is as follows

If you are the root user

Bash <(curl -s -L https://git.io/fjJEO)

if not

Sudo -E curl -s -L https://git.io/fjJEO | sudo -E bash -

Wait a moment after execution

project address
Https://github.com/bugparty/gitlab-runner-manager

通过相同思路实现一个判断回文数程序来比较几种语言之间的性能差异
实现只用到各自语言的数组实现,没有使用类似于vector的东西
回文函数会在leetcode上执行11000多次,执行结果为多次运行取最优值
rust 32 ms 2.1 MB
c 44 ms 7 MB
cpp 48 ms 8 MB
java 50 ms 37.3 MB
go 68 ms 5 MB
swift 88 ms 18.8 MB

所有代码的实现思路均为这段c代码的移植

bool isPalindrome(int x){
if (x < 0) return false;
        else if (x ==0) return true;
        else {
            int  arr[1000];
            int arrSize=0;
            int v = x;
            int digit;
            while(v > 0) {
                 digit = v % 10;
                arr[arrSize++]=(digit);
                v /= 10;
            }
            int i=0;
            int j=arrSize-1;
            bool ret = true;
            while(i<j){
               if(arr[i] == arr[j]) {
                   i++;j--;
               } else{
                   ret = false;
                   break;
               }
            }
            return ret;
        }
}

透过这个比较,可以看到结果其实和computer benchmark games差不多,cpp确实相对于c来说,相同的代码,损失了10%的性能(风云曾经这么说过),java这几年优化的确实已经相当不错了,csharp因为leetcode用的实现不明,性能差劲的不行,所以这里不进行对比,不过应该优于java
你也可以动手试试,不过我贴出的代码除了rust下,都不是最快的,因为要保证公平,不使用平台特性的功能. https://leetcode-cn.com/problems/palindrome-number
相关代码
https://github.com/bugparty/benchmark_of_some_popular_languages/tree/master

其实很简单,直接上rust语言

impl Solution {
    pub fn is_palindrome(x: i32) -> bool {
         let mut arr : [i32; 12] = [0;12];
         let mut arrSize = 0;
        if (x < 0 ) { return false;}
        else if (x == 0) { return true;}
        else {
           
            let mut v = x;
            while(v > 0) {
                let  digit = v % 10;
                arr[arrSize]=(digit);
                arrSize+=1;
                v /= 10;
            }
            let mut i=0;
            let mut j=arrSize-1;
            let mut  ret = true;
            while(i<j){
               if(arr[i] == arr[j]) {
                   i+=1;
                   j-=1;
               } else{
                   ret = false;
                   break;
               }
            }
        
            return ret;
        }
    }
}

题目在这里https://leetcode-cn.com/problems/palindrome-number