This repository was archived by the owner on Jun 5, 2025. It is now read-only.
Commit 3b3b945
committed
Load RAG database in memory on use.
This change uses a trick to force the RAG database into memory by
dumping the SQLite database from file to a temporary in-memory version
of it using SQLite's `backup` function.
Based on `percall` statistic, this almost halves execution times.
With on-disk database.
```
ncalls tottime percall cumtime percall filename:lineno(function)
911 0.017 0.000 47.983 0.053 .../src/codegate/storage/storage_engine.py:149(search)
911 41.336 0.045 41.336 0.045 {method 'execute' of 'sqlite3.Cursor' objects}
911 0.007 0.000 6.489 0.007 .../src/codegate/inference/inference_engine.py:90(embed)
```
With in-memory database.
```
ncalls tottime percall cumtime percall filename:lineno(function)
658 0.009 0.000 21.198 0.032 .../src/codegate/storage/storage_engine.py:147(search)
658 16.458 0.025 16.458 0.025 {method 'execute' of 'sqlite3.Cursor' objects}
658 0.004 0.000 4.638 0.007 .../src/codegate/inference/inference_engine.py:90(embed)
```
Also, added profiling to providers and search. Profiling can be
activated exporting `CODEGATE_PROFILE_<key>` where `<key>` is the
string passed to `@profiled` annotations. Profiling points are
statically defined throughout the codebase.1 parent 9b4806e commit 3b3b945
File tree
8 files changed
+60
-2
lines changed- src/codegate
- profiling
- providers
- anthropic
- ollama
- openai
- openrouter
- storage
- updates
8 files changed
+60
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| |||
136 | 144 | | |
137 | 145 | | |
138 | 146 | | |
| 147 | + | |
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | | - | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
0 commit comments