Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
49e85525
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
49e85525
编写于
6月 16, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add trace base func
上级
418be575
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
116 addition
and
8 deletion
+116
-8
include/util/ttrace.h
include/util/ttrace.h
+40
-0
source/util/src/thash.c
source/util/src/thash.c
+7
-7
source/util/src/ttrace.c
source/util/src/ttrace.c
+68
-0
source/util/src/tuuid.c
source/util/src/tuuid.c
+1
-1
未找到文件。
include/util/ttrace.h
0 → 100644
浏览文件 @
49e85525
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_TRACE_H_
#define _TD_TRACE_H_
#include <stdlib.h>
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
int64_t
STraceId
;
typedef
int32_t
STraceSubId
;
STraceId
traceInitId
(
STraceSubId
*
h
,
STraceSubId
*
l
);
void
traceId2Str
(
STraceId
*
id
,
char
*
buf
);
void
traceSetSubId
(
STraceId
*
id
,
int32_t
*
subId
);
STraceSubId
traceGetParentId
(
STraceId
*
id
);
STraceSubId
traceGenSubId
();
#ifdef __cplusplus
}
#endif
#endif
source/util/src/thash.c
浏览文件 @
49e85525
...
...
@@ -56,7 +56,7 @@ typedef struct SHashEntry {
}
SHashEntry
;
struct
SHashObj
{
SHashEntry
**
hashList
;
SHashEntry
**
hashList
;
size_t
capacity
;
// number of slots
int64_t
size
;
// number of elements in hash table
_hash_fn_t
hashFp
;
// hash function
...
...
@@ -65,7 +65,7 @@ struct SHashObj {
SRWLatch
lock
;
// read-write spin lock
SHashLockTypeE
type
;
// lock type
bool
enableUpdate
;
// enable update
SArray
*
pMemBlock
;
// memory block allocated for SHashEntry
SArray
*
pMemBlock
;
// memory block allocated for SHashEntry
_hash_before_fn_t
callbackFp
;
// function invoked before return the value to caller
};
...
...
@@ -633,7 +633,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
}
int64_t
st
=
taosGetTimestampUs
();
void
*
pNewEntryList
=
taosMemoryRealloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newCapacity
);
void
*
pNewEntryList
=
taosMemoryRealloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newCapacity
);
if
(
pNewEntryList
==
NULL
)
{
// uDebug("cache resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity);
return
;
...
...
@@ -642,7 +642,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
pHashObj
->
hashList
=
pNewEntryList
;
size_t
inc
=
newCapacity
-
pHashObj
->
capacity
;
void
*
p
=
taosMemoryCalloc
(
inc
,
sizeof
(
SHashEntry
));
void
*
p
=
taosMemoryCalloc
(
inc
,
sizeof
(
SHashEntry
));
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
pHashObj
->
hashList
[
i
+
pHashObj
->
capacity
]
=
(
void
*
)((
char
*
)
p
+
i
*
sizeof
(
SHashEntry
));
...
...
@@ -653,9 +653,9 @@ void taosHashTableResize(SHashObj *pHashObj) {
pHashObj
->
capacity
=
newCapacity
;
for
(
int32_t
idx
=
0
;
idx
<
pHashObj
->
capacity
;
++
idx
)
{
SHashEntry
*
pe
=
pHashObj
->
hashList
[
idx
];
SHashNode
*
pNode
;
SHashNode
*
pNext
;
SHashNode
*
pPrev
=
NULL
;
SHashNode
*
pNode
;
SHashNode
*
pNext
;
SHashNode
*
pPrev
=
NULL
;
if
(
pe
->
num
==
0
)
{
assert
(
pe
->
next
==
NULL
);
...
...
source/util/src/ttrace.c
0 → 100644
浏览文件 @
49e85525
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ttrace.h"
#include "taos.h"
#include "thash.h"
#include "tuuid.h"
// clang-format off
static
TdThreadOnce
init
=
PTHREAD_ONCE_INIT
;
static
void
*
ids
=
NULL
;
static
TdThreadMutex
mtx
;
void
traceInit
()
{
ids
=
taosHashInit
(
4096
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
taosThreadMutexInit
(
&
mtx
,
NULL
);
}
void
traceCreateEnv
()
{
taosThreadOnce
(
&
init
,
traceInit
);
}
void
traceDestroyEnv
()
{
taosThreadMutexDestroy
(
&
mtx
);
taosHashCleanup
(
ids
);
}
STraceId
traceInitId
(
STraceSubId
*
h
,
STraceSubId
*
l
)
{
STraceId
id
=
*
h
;
id
=
((
id
<<
32
)
&
0xFFFFFFFF
)
|
((
*
l
)
&
0xFFFFFFFF
);
return
id
;
}
void
traceId2Str
(
STraceId
*
id
,
char
*
buf
)
{
int32_t
f
=
(
*
id
>>
32
)
&
0xFFFFFFFF
;
int32_t
s
=
(
*
id
)
&
0xFFFFFFFF
;
sprintf
(
buf
,
"%d:%d"
,
f
,
s
);
}
void
traceSetSubId
(
STraceId
*
id
,
STraceSubId
*
subId
)
{
int32_t
parent
=
((
*
id
>>
32
)
&
0xFFFFFFFF
);
taosThreadMutexLock
(
&
mtx
);
taosHashPut
(
ids
,
subId
,
sizeof
(
*
subId
),
&
parent
,
sizeof
(
parent
));
taosThreadMutexUnlock
(
&
mtx
);
}
STraceSubId
traceGetParentId
(
STraceId
*
id
)
{
int32_t
parent
=
((
*
id
>>
32
)
&
0xFFFFFFFF
);
taosThreadMutexLock
(
&
mtx
);
STraceSubId
*
p
=
taosHashGet
(
ids
,
(
void
*
)
&
parent
,
sizeof
(
parent
));
parent
=
*
p
;
taosThreadMutexUnlock
(
&
mtx
);
return
parent
;
}
STraceSubId
traceGenSubId
()
{
return
tGenIdPI32
();
}
// clang-format on
source/util/src/tuuid.c
浏览文件 @
49e85525
...
...
@@ -49,7 +49,7 @@ int64_t tGenIdPI64(void) {
}
int64_t
id
;
while
(
true
)
{
int64_t
ts
=
taosGetTimestampMs
();
uint64_t
pid
=
taosGetPId
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录