memory indexing differences

for 구문 사용시, 인덱싱하는 order 에 따라, 실행시간에 차이가 발생한다는 글을 보았다(참조: http://process3.blog.me/20030421397)

정말로 그럴까? 한번 확인해 보았다. 결론은? 확실한 차이가 있었다.

이유를 확인해보니, 메모리 캐시와 관련된 내용이었다.

 

— Program 1
#include <stdio.h>
#define MAX_CNT 100
int main(int argc, char** argv)
{
    int i, j, k;
    int test_data[MAX_CNT][MAX_CNT][MAX_CNT];
    for(i = 0; i < MAX_CNT; i++)
    {
        for(j = 0; j < MAX_CNT; j++)
        {
            for(k = 0; k < MAX_CNT; k++)
            {
                test_data[i][j][k] = 100;
            }
        }
    }
    return 0;
}
Result
$ time ./main
real    0m0.008s
user    0m0.004s
sys     0m0.004s
— Program 2
#include <stdio.h>
#define MAX_CNT 100
int main(int argc, char** argv)
{
    int i, j, k;
    int test_data[MAX_CNT][MAX_CNT][MAX_CNT];
    for(i = 0; i < MAX_CNT; i++)
    {
        for(j = 0; j < MAX_CNT; j++)
        {
            for(k = 0; k < MAX_CNT; k++)
            {
                test_data[k][j][i] = 100;
            }
        }
    }
    return 0;
}
$ time ./main
real    0m0.017s
user    0m0.013s

sys     0m0.004s

 

힙 영역 사용시, 보다 더 큰 차이를 확인할 수 있다.

— Program 1
#include <stdio.h>
#include <stdlib.h>
#define MAX_CNT 500
int main(int argc, char** argv)
{
    int i, j, k;
//    int test_data[MAX_CNT][MAX_CNT][MAX_CNT];
    int*** test_data;
    test_data = calloc(MAX_CNT, sizeof(int**));
    for(i = 0; i < MAX_CNT; i++)
    {
        test_data[i] = calloc(MAX_CNT, sizeof(int*));
        for(j = 0; j < MAX_CNT; j++)
        {
            test_data[i][j] = calloc(MAX_CNT, sizeof(int));
        }
    }
    for(i = 0; i < MAX_CNT; i++)
    {
        for(j = 0; j < MAX_CNT; j++)
        {
            for(k = 0; k < MAX_CNT; k++)
            {
                test_data[i][j][k] = 100;
            }
        }
    }
    return 0;
}
Result
$ time ./main
real    0m0.539s
user    0m0.367s
sys     0m0.172s
— Program 2
#include <stdio.h>
#include <stdlib.h>
#define MAX_CNT 500
int main(int argc, char** argv)
{
    int i, j, k;
//    int test_data[MAX_CNT][MAX_CNT][MAX_CNT];
    int*** test_data;
    test_data = calloc(MAX_CNT, sizeof(int**));
    for(i = 0; i < MAX_CNT; i++)
    {
        test_data[i] = calloc(MAX_CNT, sizeof(int*));
        for(j = 0; j < MAX_CNT; j++)
        {
            test_data[i][j] = calloc(MAX_CNT, sizeof(int));
        }
    }
    for(i = 0; i < MAX_CNT; i++)
    {
        for(j = 0; j < MAX_CNT; j++)
        {
            for(k = 0; k < MAX_CNT; k++)
            {
                test_data[k][j][i] = 100;
            }
        }
    }
    return 0;
}
Result
$ time ./main
real    0m5.344s
user    0m5.202s
sys     0m0.147s

SMTP geek test…

담당하고 있는 음성 사서함 서비스 에서 사용중인 메일 서버를 변경했다.
당연히 잘 메일 서버에 잘 접속이 되고 동작이 되는지 테스트가 필요했다.
 
담당 엔지니어에게 부탁을 해서 테스트를 하는데… 헐, 텔넷으로 붙어서 메일을 전송 테스트를 했다….
알고는 있었지만, 실무에서 직접 보기는 처음.. -_-;;;;
 
자세한 SMTP 명령어는 아래를 참조..

apache ssl enable problem

아파치에 ssl 설정을 하고 https 접속을 하려는데 다음의 오류가 나왔다.

Secure Connection Failed

An error occurred during a connection to pchero21.com. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)

The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.

구글링을 해봐도 ssl 모듈을 활성화 시키라는 이야기만 나오고…. 단지 설정값을 이리저리 바꿔보고 테스트하는 삽질만 하고 있었다.

 

그러다가, 짚히는 부분이 있어서, ssl 인증서를 다시 만들고 테스트를 해봤더니 잘 되었다.

처음 SSL 인증서를 만들 때, 다음의 명령어를 사용했었다.

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout ./postfix.key -out ./postfix.crt

문제가 되었던 부분은 rsa:2048 부분이었다.

다음의 명령어로 다시 ssl 인증서를 만들고 설정하니 잘 되었다.

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -keyout ./postfix.key -out ./postfix.crt