Merge branch 'pr_1629'

This commit is contained in:
ob-robot 2023-11-10 07:11:03 +00:00
commit 9d9cdc2cd9
2 changed files with 10 additions and 10 deletions

View File

@ -202,7 +202,7 @@ C++ allows the use of using, which can be divided into two categories:
2. Using declaration: For example, using `common::ObSchemaManager`, which makes `ObSchemaManager` equivalent to `common::ObSchemaManager` from now on.
Because using directive is likely to pollute the scope, **it is prohibited to use it in header files**, but using declaration is allowed. In .cpp files, using directive is allowed, for example, when implementing `ObChunkServer`, it may need to use classes from the common namespace. However, it is important to note that only other namespaces can be introduced using using directives in .cpp files. The code in the .cpp file itself still needs to be put in its own namespace. For example:
Because using directive is likely to pollute the scope, **it is prohibited to use it in header files**, but using declaration is allowed. In .cpp files, using directive is allowed, for example, when implementing `ObChunkServer`, it may need to use classes from the common namespace. However, it is important to note that only other namespaces can be introduced using directives in .cpp files. The code in the .cpp file itself still needs to be put in its own namespace. For example:
```cpp
// incorrect ways of using
@ -406,18 +406,18 @@ class ObBar
const int ObBar::CONST_V = 1;
```
Before C\+\+11, the C\+\+98 standard only allowed static const variables of intergral type to be initialized with definitions included in the class declaration. In C++11, constexpr is introduced, and static constexpr member variables (including types such as double) can also be initialized in the declaration. This kind of variable will not generate static area storage after compilation.
Before C\+\+11, the C\+\+98 standard only allowed static const variables of integral type to be initialized with definitions included in the class declaration. In C++11, constexpr is introduced, and static constexpr member variables (including types such as double) can also be initialized in the declaration. This kind of variable will not generate static area storage after compilation.
> Before C++11, the values of variables could be used in constant expressions only if the variables are declared const, have an initializer which is a constant expression, and are of integral or enumeration type. C++11 removes the restriction that the variables must be of integral or enumeration type if they are defined with the constexpr keyword:
>
> constexpr double earth_gravitational_acceleration = 9.8;
> constexpr double moon_gravitational_acceleration = earth_gravitational_acceleration / 6.0;
> Such data variables are implicitly const, and must have an initializer whichmust be a constant expression.
> Such data variables are implicitly const, and must have an initializer which must be a constant expression.
**Case 1**
According to the current code style of OceanBase, we will define static variables (such as `ob_define.h`) in the header file, so that each cpp file will generate a declaration and definition of this variable when including this header file. In particular, some large objects (latch, wait event, etc.) generate a static definition in the header file, resulting in the generation of binany and memory expansion.
According to the current code style of OceanBase, we will define static variables (such as `ob_define.h`) in the header file, so that each cpp file will generate a declaration and definition of this variable when including this header file. In particular, some large objects (latch, wait event, etc.) generate a static definition in the header file, resulting in the generation of binary and memory expansion.
Simply move the definition of several static variables from the header file to the cpp file, and change the header file to extern definition, the effect is quite obvious:
binary size: 2.6G->2.4G, reduce 200M.

View File

@ -5,11 +5,11 @@ This document describes some methods to debug OceanBase. We have many ways to de
We suggest you build OceanBase with debug mode as it is easy to debug.
# GDB
GDB is a powerful debugging tool, but it is difficult to debug OceanBase by gdb and the scenarios is limited.
GDB is a powerful debugging tool, but it is difficult to debug OceanBase by gdb and the scenarios are limited.
If you want to debug a single oceanbase process and single thread, you can use gdb, otherwise it is more recommended to use logging.
I suppose that you have already deploy the oceanbase built by source code.
I suppose that you have already deployed the oceanbase built by source code.
Debugging oceanbase is similar to debugging other C++ programs, you can use gdb as the following:
@ -145,9 +145,9 @@ Reading symbols from clusters/local/bin/observer...
Attaching to program: clusters/local/bin/observer, process 57296
```
This means that there is no debugging symbols.
This means that there are no debugging symbols.
If we run some debug command in gdb, such as `bt`, we could got this.
If we run some debug command in gdb, such as `bt`, we could get this.
```bash
(gdb) bt
@ -170,7 +170,7 @@ Reading symbols from usr/lib/debug/home/admin/oceanbase/bin/observer.debug...
> It's better to use the full path of the debug info file.
Let's run the debug command again and we can get detail information.
Let's run the debug command again and we can get detailed information.
```bash
(gdb) bt
@ -226,7 +226,7 @@ set ob_log_level=debug;
```
**Log Traffic Control**
If you can not find your log, it may be limited because of the log traffic control, you can use the SQL command below to change the behavous of the log traffic control.
If you can not find your log, it may be limited because of the log traffic control, you can use the SQL command below to change the behavior of the log traffic control.
```sql
alter system set syslog_io_bandwidth_limit='1G';
alter system set diag_syslog_per_error_limit=1000;