Skip to content

Conversation

@uhm0311
Copy link
Collaborator

@uhm0311 uhm0311 commented Apr 1, 2024

🔗 Related Issue

⌨️ What I did

  • stats 명령어에 TCP 재전송 수치를 함께 출력하도록 합니다.
  • prometehus의 node_exporter와 같은 방법으로 retrans 수치를 확인합니다.
  • /proc/net/snmp file에서 Tcp: RetransSegs에 해당하는 값을 int64_t로 변환합니다.
  • /proc/net/snmp 파일 내용 예시는 아래와 같습니다.
$ cat /proc/net/snmp
Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
Ip: 1 64 1157539 0 2 0 0 0 1157535 1017212 0 0 0 0 0 0 0 0 0
Icmp: InMsgs InErrors InCsumErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps
Icmp: 151318 127 0 131 7 0 0 1 151158 21 0 0 0 0 151158 0 0 0 0 0 0 0 151158 0 0 0 0
IcmpMsg: InType0 InType3 InType5 InType8 InType11 OutType0
IcmpMsg: 21 131 1 151158 7 151158
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts InCsumErrors
Tcp: 1 200 120000 -1 6210 26425 2397 3871 6 1000039 866909 14396 0 8094 0
Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
Udp: 6190 0 0 6190 0 0 0 0 0
UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors InCsumErrors IgnoredMulti MemErrors
UdpLite: 0 0 0 0 0 0 0 0 0
  • 아래는 실제 명령어 사용 시 출력 예시입니다.
$ echo stats | nc localhost 11211
...
STAT tcp_retrans 9815302
...
END

@namsic

This comment was marked as resolved.

@ing-eoking
Copy link
Collaborator

이전에 Offline에서 말씀드린 데로 현재 이전 PR과 충돌이 난 관계로
stats 모듈이 아닌 다른 위치로 이동 부탁드립니다.

@namsic

prometehus의 node_exporter와 같은 방법으로 retrans 수치를 확인합니다.

저희 쪽에서 만든 로직인 건가요? 아니면 prometheus 의 로직인가요?

@uhm0311

@jhpark816 님께서 말씀하신 대로 stats lock을 잡고 들어가기에
다른 connection의 성능에 영향을 끼칠 수 있을 것 같습니다.
이 부분에 대하여 stats를 날린 connection 뿐만 아니라 다른 connection의
명령어 수행에 영향을 주는 지 성능 검사가 필요할 것 같습니다.

그리고 /proc/net/snmp 내 내용을 보면 크기가 크지 않은 것으로 보이므로
stats 호출마다 파일을 불러와 parsing하는 것이 아닌
memcached 구동 초기에 해당 파일을 memory mapping 하는 방식은 어떤가요?

@uhm0311 uhm0311 force-pushed the uhm0311/develop branch 2 times, most recently from a0815b2 to f161e22 Compare May 2, 2024 07:57
@uhm0311
Copy link
Collaborator Author

uhm0311 commented May 2, 2024

저희 쪽에서 만든 로직인 건가요? 아니면 prometheus 의 로직인가요?

prometheus에서 만든 로직입니다.


memcached 구동 초기에 해당 파일을 memory mapping 하는 방식은 어떤가요?

/proc/net/snmp 파일은 pseudo 파일로, Disk IO가 필요하지 않기 때문에 매핑하지 않아도 될 것 같습니다.

https://unix.stackexchange.com/questions/8274/what-happens-when-i-open-and-read-from-proc


명령어 수행에 영향을 주는 지 성능 검사가 필요할 것 같습니다.

vCore 4개 기준 다음과 같은 성능을 보입니다.

149.169391 seconds for call function 1000003 times.
0.000149 seconds per function call.

테스트 코드는 다음과 같으며, stats_tcp_retrans() 함수의 구현은 PR 형태와 동일합니다.

uint64_t loop = 1000003;

void with_gettimeofday(void) {
    uint64_t i = 0;
    struct timeval start, end;

    gettimeofday(&start, NULL);
    for (i = 0; i < loop; i++) {
        stats_tcp_retrans();
    }
    gettimeofday(&end, NULL);

    double elapsed = (end.tv_sec - start.tv_sec) + ((end.tv_usec - start.tv_usec)/1000000.0);

    printf("%lf seconds for call function %lld times.\n", elapsed, loop);
    printf("%lf seconds per function call.\n", elapsed / loop);
}

int main() {
    with_gettimeofday();

    return 0;
}

@uhm0311 uhm0311 force-pushed the uhm0311/develop branch 2 times, most recently from 58cd6be to 3c6329e Compare May 2, 2024 09:19
ing-eoking

This comment was marked as resolved.

@uhm0311 uhm0311 force-pushed the uhm0311/develop branch from 3c6329e to 624d1f3 Compare May 3, 2024 02:48
@uhm0311

This comment was marked as resolved.

@uhm0311 uhm0311 self-assigned this May 20, 2024
@uhm0311
Copy link
Collaborator Author

uhm0311 commented Feb 12, 2025

@jhpark816

본 PR에서 Conflict 외에 더 확인해야할 부분이 있을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants