# sudo parted /dev/sdb

(parted) mklabel

Warning: the existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?

Yes/No? yes

New disk label type? [gpt]? gpt

(parted) mkpart primary 0 -1s

....

혹시 mkpart를 위와 같이 했을때 최상의 성능을 낼 수 없도록 정렬된다는 경고가 나오면 취소하고 아래와 같이 해본다.

(parted) mkpart primary 0% 100%

....

(parted) print                                                            

Model: AMCC 9500S-12 DISK (scsi)

Disk /dev/sdb: 12.0TB

Sector size (logical/physical): 512B/512B

Partition Table: gpt


Number  Start   End     Size    File system  Name     Flags

 1      1049kB  12.0TB  12.0TB               primary


(parted) q


# sudo mkfs.ext4 /dev/sdb1



Posted by Jason Ryu
,

헷갈리는것이 아니라 모르고있는거라니까.


< const 키워드 >


1. 클래스 내부에 const 멤버 변수가 있는데 생성자를 만들지 않으면 컴파일 에러(C2512)가 난다. 

생성자에서 멤버 이니셜라이저(member initialize)를 이용해서 초기화를 해주지 않으면 어떤곳에서도 그 멤버를 변경 시킬수 없기 때문이다.


2. const int ntest = 10; // 변수 ntest를 상수화 시켜서 변화불가능하게 만든다.



3. const int* ptest;  // 포인터 ptest가 '가리키는' 데이타를 ptest를 통해서 변경하지 못하게 만든다.



4. int* const ptest;  // 포인터 ptest를 상수화 시켜서 변화 불가능하게 만든다. 한번 가리킨 곳은 변경하지 못한다.

 


5. int getdata() const;  // 이 멤버 함수 에서는 멤버 변수를 변경시킬수 없다.

    // 또한 멤버 변수의 포인터를 return 할수도 없다.( 리턴형이 포인터 일때 )


6. void setdata( const int data ); // 인자로 넘어가는 data를 함수 내부에서 변경 시킬수 없다.


7. void setdata( const int* data ); // 함수 내부에서 *data = 10; 이런식의 변경이 불가 하다.


8. void setdata( int* const data ); // 함수 내부에서 data = &data1; 이런식으로 포인터 변경이 불가하다.


9. void setdata( const int* const data ); // 6,7 의 속성을 모두 같게 된다.


10. 객체를 상수화 해서 선언할 경우 상수화 되지 않은 함수의 호출,

멤버변수의 포인터를 리턴 하는 행위를 허용하지 않는다.


11. 상수 함수냐 아니냐에 따라서 함수는 오버로딩이 가능하다.

오버로딩된 함수를 사용할때 특별한 지정이 없으면 비상수 함수가 우선순위가 높다.

둘다 호출이 가능한 상황에서는 비상수 함수가 호출 된다는 뜻이다.

  

12. const int getdata(); // 이건 의미 없다. 상수를 다시 상수화 시키는게 무슨 의미가 있단 말인가.


13. const int* getdata(); // 12번은 의미가 없지만 함수나 멤버 변수의 포인터를 리턴할때 함수를 이용해서 멤버 변수의 조작이 가능하기 때문에 함수를 통한 조작을 막을수 있다.



Posted by Jason Ryu
,



클래스 라이브러리를 프레임워크라 부르기도 하던데, 사실 차이점을 보고나면 구분을 하는것이 좀더 낫겠다싶다.


1. 클래스 라이브러리.

- 재사용 가능한 빌딩블럭(reusable building blocks)

- 도메인 독립적임(domain independent)

- 제한적인 영역(limited in scope)

- 수동적임(passive)


2. 프레임워크

- 재사용 가능하면서도, "거의 완성된(semi-complete)" 어플이다.

- 도메인 특화됨(domain-specific)

- 보다 광범위함.(broader in scope)

- 능동적임(active)


그림을 보면 좀더 차이를 볼 수 있는데,  프레임워크 다뤄봤다는 개발자라면 자신이 사용했던 프레임워크의 구성요소를 디자인화해서 설명할 수 있어야 하지 않을까싶다.



Posted by Jason Ryu
,

timespec start, end;

float diff_time;

clock_gettime(CLOCK_REALTIME, &start);


......(측정할 코드블럭).......


clock_gettime(CLOCK_REALTIME, &end);

diff_time = (end.tv_sec - start.tv_sec) + ((end.tv_nsec - start.tv_nsec)/1000000000);

logger("%.6f second(s) elapsed.\n", diff_time);


KLDP에서 나온 예제는 이러하지만, IBM document는 좀더 참고해서 보길..


Measuring time


To measure time reliably across processors, always use CLOCK_MONOTONIC.


CLOCK_MONOTONIC always increases linearly with time. CLOCK_REALTIME, however, can change depending on changes to system time, for example, on a system running a Network Time Protocol daemon (ntpd). The following example demonstrates how to measure time using CLOCK_MONOTONIC:clock_gettime(CLOCK_MONOTONIC, &start); do_work(); clock_gettime(CLOCK_MONOTONIC, &stop);


On a platform that has high-resolution timers (HRT) enabled, measure the resolution of the clock to verify the

accuracy. Use the clock_getres call to confirm this, as follows:clock_getres(CLOCK_MONOTONIC, &tp);


Important: HRTs require both hardware support and enablement within the operating system. SUSE SLES 11.* and Red Hat Enterprise Linux 6.* distributions contain operating system support for HRTs.


The TSC clocksource is not guaranteed to be synchronized across processors, and is not a good time source for relative time measurements (unless the measured time events are within a thread that is bound to a particular processor).


Avoid using sched_yield() as it rarely leads to deterministic behavior. In a scenario where sched_yield() is called

from a high priority SCHED_FIFO process, if all other runnable threads are of lower priority, the high priority thread immediately resumes on the processor, negating the intent of calling sched_yield().


For more information about the sched_yield command, see the sched_yield command man page.


Avoid making system calls that result in I/O during latency-sensitive paths. I/O devices are generally not considered

low-latency-safe, as they may be bound by circumstances entirely outside the control of the operating system. Sometimes it is not obvious whether a particular call can lead to disk I/O. For example, a call to getpwuid() (get

password file entry) can lead to opening files on the disk if the nscd daemon is not running.


Optimize the application's use of timers as they can incur kernel overhead and can increase jitter.


For more information about the clock_getres command, see the clock_getres man page.


Posted by Jason Ryu
,

AIX 머신에서 오라클 설치후 sqlplus나 proc와 같은 모듈을 실행시켰을때 다음과 같은 에러가 나올때가 있다.

exec(): 0509-036 Cannot load program proc because of the following errors:

        0509-130 Symbol resolution failed for /usr/lib/libc.a[aio_64.o] because:

        0509-136   Symbol kaio_rdwr64 (number 1) is not exported from

                   dependent module /unix.

        0509-136   Symbol listio64 (number 2) is not exported from

                   dependent module /unix.

        0509-136   Symbol acancel64 (number 3) is not exported from

                   dependent module /unix.

        0509-136   Symbol iosuspend64 (number 4) is not exported from

                   dependent module /unix.

        0509-136   Symbol aio_nwait (number 5) is not exported from

                   dependent module /unix.

        0509-136   Symbol aio_nwait64 (number 6) is not exported from

                   dependent module /unix.

        0509-136   Symbol aio_nwait_timeout (number 7) is not exported from

                   dependent module /unix.

        0509-136   Symbol aio_nwait_timeout64 (number 8) is not exported from

                   dependent module /unix.

        0509-026 System error: Error 0

        0509-192 Examine .loader section symbols with the

                 'dump -Tv' command.

이는 AIX의 AIO관련 설정에 문제가 있는것인데, root 계정으로 아래 명령을 실행시켜 확인해본다.

# ioo -a | grep aio

                    aio_active = 0

                   aio_maxreqs = 65536

                aio_maxservers = 30

                aio_minservers = 3

         aio_server_inactivity = 300

              posix_aio_active = 1

             posix_aio_maxreqs = 65536

          posix_aio_maxservers = 30

          posix_aio_minservers = 3

   posix_aio_server_inactivity = 300

여기서 aio_active값이 0이면 OFF상태를 나타낸다(1이면 ON)

따라서 활성화시킨후 다시 proc, sqlplus 등을 구동하면 정상동작하게 된다.

수정하려면 ioo를 이용하거나 smitty tuning --> Tuning IO Parameters에서 진행한다.

시스템 리부팅후에 적용된다.

-----------------------------------------------------------------------

 # ioo -h

Usage:  ioo -h [tunable] | {[-F] -L [tunable]} | {[-F] -x [tunable]}

        ioo [-p|-r] (-a [-F] | {-o tunable})

        ioo [-p|-r] [-y] (-D | ({-d tunable} {-o tunable=value}))

  -h                Display help about the command and its arguments

  -h tunable        Display help about a tunable

  -L [tunable]      List information about one or all tunables in a

                    table format

  -x [tunable]      List information about one or all tunables in a

                    comma-separated format

  -a                Display value for all tunables, one per line

  -F                Force display of restricted tunables when options

                    (-a/-L/-x) are specified alone on the command line,

                    else ignored

  -o tunable        Display current value of a tunable

  -D                Reset all tunables to their default values

  -d tunable        Reset tunable to its default value

  -o tunable=value  Set tunable to value

  -r                Make change(s) (-D/-d/-o) or display (-a/-o) apply to

                    nextboot value

  -p                Make change(s) (-D/-d/-o) or display (-a/-o) apply to

                    permanent (current and nextboot) value

  -y                Suppress confirmation prompt before executing bosboot

#

============================================================


비동기 I/O(AIO)



AIO는 AIX 소프트웨어 하위 시스템으로 프로세스가 I/O가 종료되기를 기다리지 않고 I/O 연산을 수행하도록 만든다. I/O 연산과 응용 프로그램 처리가 동시에 진행되므로 두 프로세스는 실제로 배경 작업으로 동작하며 성능 개선을 가져온다. AIO는 특히 데이터베이스 환경에서 중요하다. AIX 하위 시스템에는 두 가지 종류가 있는데, 전용 AIO와 POSIX AIO가 있다. 양쪽 차이점은 응용 프로그램 층에 전달하는 매개변수다. 바꿔 말하면 응용 프로그램이 사용하는 인터페이스에 맞춰 두 가지 구현 중 하나를 선택하면 된다. 어떤 하위 시스템을 선택하거나 상관없이 AIX에서 병렬로 동작한다. AIX 5L에서 응용 프로그램이 AIO를 사용할 경우 하위 시스템은 명시적으로 autoconfig 항목을 활성화해야 한다. 또한 시스템을 재시동해야 하는 이유는 커널 확장을 메모리에 올릴 필요가 있기 때문이다. 실제로 AIX 5.3 TL5 전에 나온 운영체제는 다음에 소개하는 조율값 중 하나라도 바꾸면 재시동이 필요했다.



maxreqs 

maxservers 

minservers 

AIX 5.3에서는 또한 aioo 명령을 사용해 재시동 없이 동적으로 변경이 가능하다. 이 명령은 ODM(Object Data Manager) 속성을 변경하지 않으므로 재시동을 하더라도 영속적으로 옵션을 설정하지 않음에 유의해야 한다.



AIX 6.1에서는 조율값 fastpath와 fsfastpath가 이제 제약이 가해진 조율값으로 바뀌었으며 기본값이 1로 설정되어 있다. 속성값에 대한 효과는 다음과 같다(Listing 9 참조).


fastpath: 가공되지 않은 논리 볼륨이 직접 디스크 층으로 전파되록 만드는 AIO 요청 

fsfastpath: JFS2에서 병렬 I/O로 열린 파일을 LVM이나 디스크로 전파되도록 AIO 요청 



Listing 9. JFS2에서 병렬 I/O로 열린 파일을 LVM이나 디스크로 전파되도록 AIO 요청


##Restricted tunables

                  aio_fastpath = 1

                aio_fsfastpath = 1


한걸음 더 나가, AIO 하위 시스템은 이제 기본으로 메모리에 올라오며 활성화되지는 않는다. AIO 하위 시스템은 응용 프로그램이 AIO I/O 요청을 시작할 때 자동으로 활성화된다. 더 이상 aioo 명령이 필요없으며(인생은 짧다), 이제 설정값만 ioo 명령으로 변경할 뿐이다(Listing 10 참조).



Listing 10. 예전 AIX 방법(AIX 5.3)


lpar9ml24f_pub[/] > # aioo -a


            minservers = 1

            maxservers = 1

             maxreqs= 4096

             fsfastpath = 0

 


Listing 11은 AIX 6.1에서 제공하는 새로운 방법을 보여준다.


Listing 11. 새로운 AIX 방법(AIX 6.1)


lpar9ml162f_pub[/] > ioo -a | grep active

                    aio_active = 0

              posix_aio_active = 

  


또한 더 이상 ODM에 AIO 디바이스가 존재하지 않음에 주의하기 바란다.



살펴보면 알겠지만, aio_active와 posix_aix_active라는 새로운 매개변수 두 개가 ioo에 추가되었다. 이 매개변수는 AIX가 변경하며 AIO 커널 확장을 사용하도록 고정된 상황에서만 1로 설정된다. grep을 좋아한다면 더 이상 AIO 서버를 찾아 해맬 필요가 없다. 이제 aioLpools와 aioPpools를 찾을 수 있는데, 이 둘은 전용 AIO 하위 시스템과 POSIX AIO 하위 시스템을 관리하는 커널 프로세스다. 이렇게 변경된 결과로 인해 고정된 메모리 사용이 줄어들고 시스템에서 돌아가는 프로세스도 줄어들었다. 둘 다 전반적인 시스템 성능에 긍정적인 효과를 가져온다(Listing 12 참조).



Listing 12. 새로운 AIO 커널 프로세스


lpar9ml162f_pub[/] > pstat -a | grep aio

 39 a   2704e      1  2704e     0     0     1  aioLpool

 40 a   28050      1  28050     0     0     1  aioPpool

lpar9ml162f_pub[/] >


AIO 서버와 밀접한 관련이 있는 minserver와 maxserver 매개변수는 이제 각 CPU 조율값으로 조율이 가능해졌다. 이런 조율값 변경은 시스템에 있는 가용 서버 숫자를 변경하지 않는다. 전체 변화량은 동시에 수행하는 I/O 요청 숫자와 관련이 있다(Listing 13 참조).



Listing 13. minservers와 maxservers를 위한 기본 매개변수 변화


lpar9ml162f_pub[/] > ioo -a | grep minservers

                aio_minservers = 3

          posix_aio_minservers = 3

lpar9ml162f_pub[/] > ioo -a | grep maxservers

                aio_maxservers = 30

          posix_aio_maxservers = 30

lpar9ml162f_pub[/] >



Posted by Jason Ryu
,