Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: 优化分词渲染逻辑减少性能消耗 --story=121654998 #4942

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
36f3fb1
fix: konva替换fabric进行渲染优化
xintaoLi Jan 15, 2025
53dbb00
fix: konva替换fabric进行渲染优化
xintaoLi Jan 15, 2025
19ffce3
feat: konva实现画布绘制交互操作
xintaoLi Jan 16, 2025
5c8ccf2
fix: 修复konva渲染背景计算逻辑
xintaoLi Jan 16, 2025
8b79f13
fix: 多层处理分词功能实现
xintaoLi Jan 17, 2025
33aa194
perf: 优化Canvas渲染性能
xintaoLi Jan 21, 2025
24b6c7e
perf: 优化Canvas渲染性能
xintaoLi Jan 21, 2025
dbc3d2c
fix: 同步远程代码冲突处理
xintaoLi Jan 21, 2025
fb8ad12
feat: 支持webgl高性能渲染和konva 2d渲染兼容
xintaoLi Jan 23, 2025
80ce3a4
fix: 修复点击弹出位置计算
xintaoLi Jan 23, 2025
b237042
fix: 修复换行位置回溯算法 & 修复切换样式问题
xintaoLi Feb 6, 2025
e358635
fix: 同步master代码冲突
xintaoLi Feb 7, 2025
c88bca4
fix: 修复原始日志和日志聚类切换导致的样式问题
xintaoLi Feb 7, 2025
a07c842
fix: 修复换行计算位置算法不准问题 & 滚动计算容器位置问题
xintaoLi Feb 7, 2025
7d32f6b
Merge branch 'master' of https://github.com/TencentBlueKing/bk-monito…
xintaoLi Feb 8, 2025
d19b2c7
fix: 修复极限换行算法问题
xintaoLi Feb 8, 2025
e6ccd19
fix: 修复click事件触发条件
xintaoLi Feb 8, 2025
06c42e9
fix: 修复换行回溯算法边界问题
xintaoLi Feb 8, 2025
a049eee
fix: 修复边界分词位置计算逻辑
xintaoLi Feb 10, 2025
d2afb09
Merge branch 'master' of https://github.com/TencentBlueKing/bk-monito…
xintaoLi Feb 10, 2025
20933c8
fix: 修复占位符\t宽度计算逻辑
xintaoLi Feb 10, 2025
ca0bc8d
fix: 修复占位符\t宽度计算逻辑
xintaoLi Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 81 additions & 2 deletions bklog/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion bklog/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@
"dayjs": "1.11.10",
"deepmerge": "4.3.1",
"echarts": "^5.5.1",
"fabric": "^5.5.1",
"html-to-image": "1.11.11",
"interactjs": "1.10.27",
"js-cookie": "3.0.5",
"json-bignumber": "1.1.1",
"konva": "^9.3.18",
"lodash": "4.17.21",
"monaco-editor": "0.33.0",
"monaco-editor-webpack-plugin": "7.0.1",
"monaco-yaml": "4.0.0-alpha.3",
"pixi.js": "^8.6.6",
"postcss-loader": "8.1.1",
"qs": "6.11.2",
"resize-detector": "0.3.0",
Expand Down
23 changes: 19 additions & 4 deletions bklog/web/src/hooks/use-text-segmentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ export type FormatterConfig = {
};
};

export type WordListItem = {
text: string;
isMark: boolean;
isCursorText: boolean;
startIndex?: number;
endIndex?: number;
left?: number;
top?: number;
width?: number;
renderWidth?: number;
split?: WordListItem[];
line?: number;
};

export type SegmentAppendText = { text: string; onClick?: (...args) => void; attributes?: Record<string, string> };
export default class UseTextSegmentation {
getSegmentContent: (keyRef: object, fn: (...args) => void) => Ref<HTMLElement>;
Expand All @@ -56,7 +70,7 @@ export default class UseTextSegmentation {
Object.assign(this.options, cfg.options ?? {});
}

getCellClickHandler(e: MouseEvent, value) {
getCellClickHandler(e: MouseEvent, value, { offsetY = 0, offsetX = 0 }) {
const x = e.clientX;
const y = e.clientY;
let virtualTarget = document.body.querySelector('.bklog-virtual-target') as HTMLElement;
Expand All @@ -69,8 +83,8 @@ export default class UseTextSegmentation {
document.body.appendChild(virtualTarget);
}

virtualTarget.style.setProperty('left', `${x}px`);
virtualTarget.style.setProperty('top', `${y}px`);
virtualTarget.style.setProperty('left', `${x + offsetX}px`);
virtualTarget.style.setProperty('top', `${y + offsetY}px`);

this.handleSegmentClick(virtualTarget, value);
}
Expand Down Expand Up @@ -212,10 +226,11 @@ export default class UseTextSegmentation {
'&gt;': '>',
'&quot;': '"',
'&#x27;': "'",
' ': '\u2002',
};

return typeof val !== 'string'
? val
? `${val}`
: val.replace(RegExp(`(${Object.keys(map).join('|')})`, 'g'), match => map[match]);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Tencent is pleased to support the open source community by making
* 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
*
* License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
*
* ---------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
export default class CanvasText {
fontSize;
fontFamily;
canvasInstance: HTMLCanvasElement;
canvasContext: CanvasRenderingContext2D;
constructor({ fontSize, fontFamily }) {
this.canvasInstance = document.createElement('canvas');
this.canvasContext = this.canvasInstance.getContext('2d');
this.fontSize = fontSize;
this.fontFamily = fontFamily;
this.canvasContext.font = `${this.fontSize}px ${this.fontFamily}`;
}

width(txt: string) {
return this.canvasContext.measureText(txt ?? '').width;
}

destroy() {
this.canvasInstance = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const ROW_EXPAND = '__component_row_expand';
export const ROW_F_ORIGIN_TIME = '__component_origin_time';
export const ROW_F_ORIGIN_CTX = '__component_origin_content';
export const ROW_F_ORIGIN_OPT = '__component_table_operator';
export const ROW_F_JSON = '__component_format_json';

// 滚动条查询条件
export const GLOBAL_SCROLL_SELECTOR = '.retrieve-v2-index.scroll-y';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: relative;
display: inline-flex;
flex-direction: column;
width: fit-content;
// width: fit-content;
width: 100%;
min-width: 100%;
min-height: 400px;
Expand Down Expand Up @@ -41,7 +41,6 @@
width: fit-content;
min-width: 100%;
transform: translate3d(var(--scroll-left), 0, 0);
// will-change: scroll-position;

&::before {
position: absolute;
Expand All @@ -57,7 +56,7 @@
background-size:
100% 100%,
50% 100%;
animation: loading-animation 1.5s infinite;
// animation: loading-animation 1.5s infinite;
}
}

Expand All @@ -82,19 +81,14 @@
min-height: 40px;
background-color: #fff;
border-bottom: 1px solid #dfe0e5;
content-visibility: auto;
will-change: auto;

.bklog-row-observe {
width: fit-content;
min-width: 100%;
height: fit-content;
visibility: visible;
height: 100%;

&.is-pending {
position: relative;
visibility: hidden;
will-change: auto;
}
}

Expand All @@ -104,6 +98,7 @@
display: inline-flex;
align-items: flex-start;
width: var(--scroll-width);
min-width: fit-content;
min-height: 40px;
font-family: var(--table-fount-family);
font-size: var(--table-fount-size);
Expand Down Expand Up @@ -449,16 +444,16 @@
}
}
}
@keyframes loading-animation {
0% {
background-position:
0% 0,
-50% 0;
}

100% {
background-position:
0% 0,
150% 0;
}
}
// @keyframes loading-animation {
// 0% {
// background-position:
// 0% 0,
// -50% 0;
// }

// 100% {
// background-position:
// 0% 0,
// 150% 0;
// }
// }
Loading
Loading