You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
../src/renderer/tvgRender.h: warning: padding size of 'tvg::RenderDirtyRegion::Partition' with 7 bytes to alignment boundary [-Wpadded]
../src/renderer/tvgRender.h: warning: padding size of 'tvg::RenderStroke::Dash' with 4 bytes to alignment boundary [-Wpadded]
../src/renderer/tvgRender.h: warning: padding struct 'tvg::RenderEffectGaussianBlur' with 2 bytes to align 'sigma' [-Wpadded]
../src/renderer/tvgPaint.h: warning: padding size of 'tvg::Paint::Impl' with 63 bits to alignment boundary [-Wpadded]
3. 경고 종류
멤버 간 정렬 패딩(우선순위): 큰 타입(8바이트 포인터 등) 앞에 작은 타입(1~2바이트)이 위치하여 발생
구조체 끝 정렬 패딩: 구조체 전체 크기가 최대 멤버 정렬 단위의 배수가 되도록 끝에 패딩 삽입
jerryscript_jerry / rapidjson: 관련된 내용도 경고에 포함되어 있어 관련된 내용은 좀 더 파악해보기
작업전 내용 공유 + 파일 수정 범위
로그파일을 토대로 AI 에게 단계별로 분석했습니다.
해당 관련된 내용의 범위가 어느정도인지 정도로 보시면 좋을 것 같고, 작업전 파일을 정해 실제 경고로그에 파일이 있는 지 확인 후 진행하면 될 것 같습니다.
권장 작업 순서
1단계 독립 구조체부터 시작하여 멤버 변수를 정렬 크기 내림차순으로 재배치
2단계 리프 노드는 부모의 끝 패딩과 자식 첫 멤버의 관계를 확인 후 수정
3단계 부모 구조체는 전체 빌드 + 테스트로 자식 레이아웃 무결성 검증 필수
C++에서 구조체 멤버를 재배치할 때 상속 관계가 있는 구조체를 수정할 때는 주의가 필요합니다.
부모 구조체의 멤버 순서를 바꾸면, 이를 상속받는 모든 자식 구조체의 메모리 레이아웃이 변경.
++ 작업후에는 꼭 테스트코드를 실행해서 문제없는 지 확인!!
ninja -C builddir test // builddir == 빌드한폴더명
meson test -C builddir -v
분류 기준
단계
설명
수정 위험도
1단계 🟢
상속받지 않은 독립적인 구조체
낮음
2단계 🟡
다른 구조체를 상속받지만, 자신은 더 이상 상속되지 않는 리프(Leaf) 노드
중간
3단계 🔴
부모이면서 자식들에 의해 상속되는 구조체 (복잡한 상속 계층)
높음
총 2,001건의 경고가 발생했으며, ThorVG 자체 소스에서만 1,445건(고유 ~231건)이 확인.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
안녕하세요. ThorVG 멘티 박성준 입니다.
구조체 패딩(Struct Padding) 최적화 작업에 대해 히스토리를 남기고자 글을 적게되었습니다.
앞으로 관련된 내용을 꾸준하게 올릴 수 있도록 하겠습니다.
이슈: thorvg/thorvg#4618
PR: thorvg/thorvg#4620
로그파일
build_wpadded_log.txt
패딩 경고를 보는 방법으로는 아래와 같이 진행했습니다.
1. -Wpadded 옵션을 포함하여 빌드 디렉터리 구성
2. 컴파일 경고를 포함하여 전체 빌드 로그를 텍스트 파일로 저장
예시: 발생한 패딩 경고 로그 일부
3. 경고 종류
작업전 내용 공유 + 파일 수정 범위
로그파일을 토대로 AI 에게 단계별로 분석했습니다.
해당 관련된 내용의 범위가 어느정도인지 정도로 보시면 좋을 것 같고, 작업전 파일을 정해 실제 경고로그에 파일이 있는 지 확인 후 진행하면 될 것 같습니다.
권장 작업 순서
++ 작업후에는 꼭 테스트코드를 실행해서 문제없는 지 확인!!
분류 기준
총 2,001건의 경고가 발생했으며, ThorVG 자체 소스에서만 1,445건(고유 ~231건)이 확인.
주요 상속 계층 다이어그램
Renderer 계층
Lottie Loader 계층
Font / Raw Loader 계층
단계별 상세 목록
🟢 1단계: 독립 구조체 (상속 없음) — ~80개+
Renderer (
src/renderer/)RenderDirtyRegiontvgRender.h:162RenderDirtyRegion::PartitiontvgRender.h:198RenderTrimPathtvgRender.h:332RenderStroketvgRender.h:347RenderStroke::DashtvgRender.h:352RenderShapetvgRender.h:394MasktvgPaint.h:37Paint::ImpltvgPaint.h:44Canvas::ImpltvgCanvas.h:30Fill::ImpltvgFill.h:35PictureOpstvgLoader.h:47FontMetricstvgLoader.h:191AccessorEntitytvgAccessor.h:34TaskQueuetvgTaskScheduler.cpp:36TaskSchedulerImpltvgTaskScheduler.cpp:95CPU Engine (
src/renderer/cpu_engine/)SwOutlinetvgSwCommon.h:101SwSpantvgSwCommon.h:111SwFilltvgSwCommon.h:169SwStrokeBordertvgSwCommon.h:196SwStroketvgSwCommon.h:209SwDashStroketvgSwCommon.h:228SwShapetvgSwCommon.h:241SwImagetvgSwCommon.h:252SwCellPooltvgSwCommon.h:319RleWorkertvgSwRle.cpp:206SVG Loader (
src/loaders/svg/)SvgDocNodetvgSvgCommon.h:305SvgSymbolNodetvgSvgCommon.h:325SvgUseNodetvgSvgCommon.h:337SvgRectNodetvgSvgCommon.h:355SvgMaskNodetvgSvgCommon.h:387SvgTextNodetvgSvgCommon.h:400SvgCompositetvgSvgCommon.h:458SvgPainttvgSvgCommon.h:465SvgDashtvgSvgCommon.h:475SvgStyleGradienttvgSvgCommon.h:481SvgStyleFilltvgSvgCommon.h:505SvgStyleStroketvgSvgCommon.h:513SvgStylePropertytvgSvgCommon.h:542SvgNodetvgSvgCommon.h:552SvgParsertvgSvgCommon.h:586SvgParserContexttvgSvgCommon.h:623tvgSvgLoader.cppLottie Loader (
src/loaders/lottie/) — 독립 구조체만LottieStroketvgLottieModel.h:37LottieStroke::DashAttrtvgLottieModel.h:39LottieMasktvgLottieModel.h:243LottieGlyphtvgLottieModel.h:300LottieFonttvgLottieModel.h:449LottieSlottvgLottieModel.h:1187LottieCompositiontvgLottieModel.h:1223LottieExpressiontvgLottieProperty.h:127LottieScalarFrame<T>(9종)tvgLottieProperty.h:46LottieVectorFrame<Point>tvgLottieProperty.h:77LottieInterpolatortvgLottieInterpolator.h:28LottieTweentvgLottieTween.h:33RenderRepeatertvgLottieBuilder.h:36RenderTexttvgLottieBuilder.h:55RenderContexttvgLottieBuilder.h:76PathSettvgLottieCommon.h:32TextDocumenttvgLottieCommon.h:71Common / Font / Public Header
Inlist<T>(7종)tvgInlist.h:37Map<uint,SfntGlyphMetrics>::ItemtvgMap.h:39Paint(공개 API)thorvg.h:784pImpl🟡 2단계: 단순 상속 리프 노드 — ~55개
부모 구조체를 상속받지만, 자신은 더 이상 상속되지 않는다.
수정 시 부모의 끝 패딩이 자식 첫 멤버에 재활용되는지 확인필요.
Renderer 계층
RenderEffectGaussianBlurRenderEffecttvgRender.h:482RenderEffectDropShadowRenderEffecttvgRender.h:501RenderEffectFillRenderEffecttvgRender.h:525RenderEffectTintRenderEffecttvgRender.h:541RenderEffectTritoneRenderEffecttvgRender.h:562SwSurfaceRenderSurfacetvgSwCommon.h:279SwCompositorRenderCompositortvgSwCommon.h:310SwShapeTaskSwTasktvgSwRenderer.cpp:92SwImageTaskSwTasktvgSwRenderer.cpp:183SwRendererRenderMethodtvgSwRenderer.h:36ShapeImplShapetvgShape.h:33PictureImplPicturetvgPicture.h:34SceneImplScenetvgScene.h:31TextImplTexttvgText.h:35AccessorImplAccessortvgAccessor.cpp:35Lottie —
LottieObject자식LottieTextRangeLottieObjectLottieTrimpathLottieObjectLottieRoundedCornerLottieObjectLottieTransformLottieObjectLottieImageLottieObjectLottieAudioLottieObjectLottieRepeaterLottieObjectLottieOffsetPathLottieObjectLottiePuckerBloatLottieObjectLottieZigZagLottieObjectLottie —
LottieSolid/Gradient/Shape리프LottieSolidFillLottieSolidLottieSolidStrokeLottieSolid+LottieStrokeLottieGradientFillLottieGradientLottieGradientStrokeLottieGradient+LottieStrokeLottiePathLottieShapeLottieRectLottieShapeLottiePolyStarLottieShapeLottieEllipseLottieShapeLottieLayerLottieGroupLottie —
LottieEffect/Modifier/Property리프LottieFxCustomLottieEffectLottieFxFill~GaussianBlur(6종)LottieEffectLottieRoundnessModifierLottieModifierLottieOffsetModifierLottieModifierLottiePuckerBloatModifierLottieModifierLottieZigZagModifierLottieModifierLottieGenericProperty<T>(5종)LottiePropertyLottieColorStopLottiePropertyLottieBitmapLottiePropertyFont / Raw / SVG Loader 리프
SfntGlyphMetricsSfntGlyphTtfReaderSfntReaderSfntLoaderFontLoaderRawLoaderImageLoaderSvgLoaderImageLoader+TaskLottieLoaderAnimLoader🔴 3단계: 복잡한 상속 부모 — ~15개
Renderer 핵심 부모
RenderEffecttvgRender.h:472RenderMethodtvgRender.h:587keyTasktvgTaskScheduler.h:52prevSwTasktvgSwRenderer.cpp:38Picturethorvg.h:1610Lottie 핵심 부모
LottieObjecttvgLottieModel.h:253LottieShapetvgLottieModel.h:591LottieSolidtvgLottieModel.h:798LottieGradienttvgLottieModel.h:857LottieGrouptvgLottieModel.h:1052LottieEffecttvgLottieModel.h:85LottieModifiertvgLottieModifier.h:31LottiePropertytvgLottieProperty.h:156Font Loader 부모
SfntGlyphtvgSfntReader.h:35SfntReadertvgSfntReader.h:48결론 - 진짜 해당 작업으로 크기가 줄어드는가??
All reactions