Skip to content

Commit 9dea9cb

Browse files
authored
Optimize readme and python sdk (#22611)
Optimize readme and python sdk Approved by: @dengn
1 parent 5a61bb3 commit 9dea9cb

39 files changed

+1111
-449
lines changed

BUILD.md

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
# Building MatrixOne from Source
2+
3+
This guide provides detailed instructions for building and running MatrixOne from source code using Make.
4+
5+
## Prerequisites
6+
7+
Before building MatrixOne, ensure you have the following installed:
8+
9+
### Required Tools
10+
11+
1. **Go** (version 1.22)
12+
- [Installation Guide](https://go.dev/doc/install)
13+
- Verify: `go version`
14+
15+
2. **GCC/Clang**
16+
- [GCC Installation](https://gcc.gnu.org/install/)
17+
- Verify: `gcc --version`
18+
19+
3. **Git**
20+
- [Git Installation](https://git-scm.com/download)
21+
- Verify: `git --version`
22+
23+
4. **Make**
24+
- Usually pre-installed on Linux/MacOS
25+
- Verify: `make --version`
26+
27+
5. **MySQL Client** (version 8.0.30+)
28+
- [MySQL Downloads](https://dev.mysql.com/downloads/mysql)
29+
- Verify: `mysql --version`
30+
31+
---
32+
33+
## Building MatrixOne
34+
35+
### Step 1: Clone Repository
36+
37+
```bash
38+
git clone https://github.com/matrixorigin/matrixone.git
39+
cd matrixone
40+
```
41+
42+
### Step 2: Prepare Dependencies
43+
44+
```bash
45+
# Download and vendor dependencies
46+
go mod vendor
47+
```
48+
49+
### Step 3: Build
50+
51+
```bash
52+
# Build MatrixOne server
53+
make build
54+
55+
# The binary will be created at: ./mo-service
56+
```
57+
58+
### Step 4: Build Options
59+
60+
```bash
61+
# Clean build artifacts
62+
make clean
63+
64+
# Build with debug symbols
65+
make debug
66+
67+
# Build specific components
68+
make config # Build configuration
69+
make service # Build service only
70+
71+
# Run tests
72+
make test
73+
74+
# Run unit tests
75+
make ut
76+
77+
# Check code style
78+
make fmt-check
79+
```
80+
81+
---
82+
83+
## Running MatrixOne
84+
85+
### Launch Server
86+
87+
```bash
88+
# Default launch with local configuration
89+
./mo-service -launch ./etc/launch/launch.toml
90+
```
91+
92+
### Configuration
93+
94+
Edit `./etc/launch/launch.toml` to customize your MatrixOne deployment.
95+
96+
**⚠️ Important: Adjust Memory Cache for Better Performance**
97+
98+
The default cache size (512MB) is too small for production workloads. Update the configuration for optimal query performance:
99+
100+
```toml
101+
[fileservice.cache]
102+
memory-capacity = "8GB" # Adjust based on your available memory
103+
```
104+
105+
**Recommended memory-capacity settings:**
106+
- **Development/Testing:** 2-4GB
107+
- **Production:** 8-32GB (depending on workload and available RAM)
108+
- **High-performance:** 32GB+ for large-scale analytics
109+
110+
**Other important settings:**
111+
- `service-host` - Server listening address (default: 0.0.0.0)
112+
- `service-port` - MySQL protocol port (default: 6001)
113+
- `data-dir` - Data storage directory
114+
- `log-level` - Logging level (debug, info, warn, error)
115+
116+
📖 **[Complete Configuration Reference →](https://docs.matrixorigin.cn/en/latest/MatrixOne/Reference/System-Parameters/standalone-configuration-settings/)**
117+
118+
### Connect to Server
119+
120+
```bash
121+
mysql -h 127.0.0.1 -P 6001 -u root -p
122+
# Default password: 111
123+
```
124+
125+
---
126+
127+
## Development Workflow
128+
129+
### Quick Development Cycle
130+
131+
```bash
132+
# 1. Make changes to source code
133+
134+
# 2. Update dependencies (only if go.mod changed)
135+
go mod vendor
136+
137+
# 3. Rebuild
138+
make build
139+
140+
# 4. Restart server
141+
# Stop: Ctrl+C or kill process
142+
# Start: ./mo-service -launch ./etc/launch/launch.toml
143+
```
144+
145+
### Dependency Management
146+
147+
```bash
148+
# Download dependencies
149+
go mod download
150+
151+
# Vendor dependencies (required before build)
152+
go mod vendor
153+
154+
# Clean up unused dependencies
155+
go mod tidy
156+
157+
# Update specific dependency
158+
go get -u github.com/package/name
159+
go mod vendor
160+
```
161+
162+
### Running Tests
163+
164+
```bash
165+
# Run all tests
166+
make test
167+
168+
# Run unit tests only
169+
make ut
170+
171+
# Run integration tests
172+
make bvt
173+
174+
# Run specific test package
175+
go test ./pkg/your-package/...
176+
```
177+
178+
---
179+
180+
## Build Targets
181+
182+
Common Make targets:
183+
184+
| Target | Description |
185+
|--------|-------------|
186+
| `make build` | Build MatrixOne server |
187+
| `make clean` | Clean build artifacts |
188+
| `make config` | Generate configuration |
189+
| `make test` | Run all tests |
190+
| `make ut` | Run unit tests |
191+
| `make bvt` | Run BVT tests |
192+
| `make fmt` | Format code |
193+
| `make lint` | Run linters |
194+
195+
---
196+
197+
## Troubleshooting
198+
199+
### Build Failures
200+
201+
**Go version mismatch:**
202+
```bash
203+
go version # Must be 1.22
204+
```
205+
206+
**Missing dependencies:**
207+
```bash
208+
go mod download
209+
go mod vendor # Required before build
210+
go mod tidy
211+
```
212+
213+
**Vendor directory issues:**
214+
```bash
215+
# Remove vendor directory and re-vendor
216+
rm -rf vendor/
217+
go mod vendor
218+
```
219+
220+
**Clean rebuild:**
221+
```bash
222+
make clean
223+
go mod vendor # Re-vendor dependencies
224+
make build
225+
```
226+
227+
### Runtime Issues
228+
229+
**Slow query performance:**
230+
231+
The default cache size (512MB) is too small. Increase memory cache in `./etc/launch/launch.toml`:
232+
233+
```toml
234+
[fileservice.cache]
235+
memory-capacity = "8GB" # Adjust based on available memory
236+
```
237+
238+
**Recommended:** 2-4GB for dev, 8-32GB for production.
239+
240+
📖 **[Configuration Guide →](https://docs.matrixorigin.cn/en/latest/MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#default-parameters)**
241+
242+
**Port already in use:**
243+
```bash
244+
# Check what's using port 6001
245+
lsof -i :6001
246+
247+
# Kill process if needed
248+
kill -9 <PID>
249+
```
250+
251+
**Permission issues:**
252+
```bash
253+
# Ensure proper permissions for data directories
254+
chmod -R 755 ./data
255+
```
256+
257+
---
258+
259+
## Advanced Build Options
260+
261+
_This section will be expanded with advanced build configurations, cross-compilation, optimization flags, etc._
262+
263+
---
264+
265+
## Contributing
266+
267+
For development and contribution guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
268+

0 commit comments

Comments
 (0)