Skip to content

Commit 8b2efe8

Browse files
committed
adjust to v0.23.0 changes
1 parent 54140be commit 8b2efe8

22 files changed

+3620
-6241
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ pb_data/
1313

1414
# binaries, deployment tools and configs
1515
app
16-
hop
17-
hop.yml
1816
fly
1917
fly.toml

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@ pb_data/
1313

1414
# binaries, deployment tools and configs
1515
app
16-
hop
17-
hop.yml
1816
fly
1917
fly.toml

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.20-alpine
1+
FROM golang:1.23-alpine
22

33
WORKDIR /pb
44

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,30 @@ without extra performance tuning or deployment on expensive server.
1212

1313
## Results
1414

15-
- **Hetzner CAX11 (2vCPU ARM64, 4GB RAM, €3.79)**
15+
- **Hetzner CAX11 (2vCPU ARM64, 4GB RAM, €3.95)**
1616
- [Pure Go results (default)](results/hetzner_cax11.md)
1717
- [CGO results](results/hetzner_cax11_cgo.md)
1818

19-
- **Hetzner CAX41 (16vCPU ARM64, 32GB RAM, €24.49)**
19+
- **Hetzner CAX41 (16vCPU ARM64, 32GB RAM, €28.78)**
2020
- [Pure Go results (default)](results/hetzner_cax41.md)
2121
- [CGO results](results/hetzner_cax41_cgo.md)
2222

23-
- **Hop.io (1vCPU, 512MB RAM, _free tier_)**
24-
- [Pure Go results (default)](results/hop_free_tier.md)
25-
_(fails the mixed `posts50k` tests most likely a result of some resources abuse protection)_
26-
2723
- **Fly.io (1vCPU, 256MB RAM, _free tier_)**
2824
- [Pure Go results (default)](results/fly_free_tier.md)
2925
_(it requires swap to be configured to prevent OOM errors and restarts; fails the heavier `posts100k` tests most likely a result of some resources abuse protection)_
3026

31-
_Keep in mind that the tests are performed on the same machine where the PocketBase instance is deployed so the app performance can be slightly affected by the benchmarks execution itself (most hosts providers have several protections in place and at the moment I don't have the time to create proper setup to run the tests from more than one IP)._
27+
_Keep in mind that the benchmark runs together with the PocketBase instance on a single VPS with shared vCPU so the app performance can be slightly affected by the tests execution itself._
3228

3329
_There are several optimizations that can be done and the benchmarks will change in the future so that the tests can run as part of the development workflow to track regressions, but for now improving the overall PocketBase dev experience remains with higher priority._
3430

3531

3632
#### Takeaways and things we'll have to improve
3733

38-
- The Go and JS (_will be available with v0.17.0+_) custom routes and app hooks perform almost the same for low and medium concurrency (with 100 prewarmed goja runtimes).
34+
- The Go and JS custom routes and app hooks perform almost the same for low and medium concurrency (with 50 prewarmed goja runtimes).
3935

4036
- At the moment there is no much difference in terms of query execution between the lower and higher spec Hetzner VMs (_probably because most of the operations are I/O bound_).
4137

42-
- The default data DB connections limit (max:120, idle:20) could be changed to be dynamic based on the running hardware to improve the overall performance and reduce the memory usage.
38+
- The default data DB connections limit (max:120, idle:15) could be changed to be dynamic based on the running hardware to improve the overall performance and reduce the memory usage.
4339

4440
- With higher concurrency individual query performance degrades (_probably because the runtime has to do more work, there is context switching involved, locks, etc._) but still the overall requests completion is better for most of the times.
4541

@@ -50,12 +46,13 @@ _There are several optimizations that can be done and the benchmarks will change
5046
executed by default with the request (for first page results this could drastically drop the query execution from ~3.5s to ~9ms).
5147
Creating appropriate indexes can also help speeding up the execution.
5248

53-
- To prevent unnecessary `JOIN` statements we can implement internally a special condition that will treat single `relation` field statements like `rel.id = @request.auth.id` the same as `rel = @request.auth.id`.
49+
- ~To prevent unnecessary `JOIN` statements we can implement internally a special condition that will treat single `relation` field statements like `rel.id = @request.auth.id` the same as `rel = @request.auth.id`.~
50+
_Done._
5451

5552
- The existing json column normalizations (eg. `CASE WHEN json_valid ...`) have some impact on the performance (~10%) and can be further optimized by removing them entirely and ensuring that the field values are always stored in the correct format before create/update persistence (either on app level or triggers).
5653

57-
- The CGO driver for some queries in _large datasets_ can be ~1.5x-4x times faster.
58-
Building with `CGO_ENABLED=1` is the easiest way to boost the query performance without changing your db structure or hardware but keep in mind that it complicates the cross-compilation.
54+
- The CGO `mattn/go-sqlite3` driver for some `SELECT` queries in _large datasets_ can be ~1.5x-4x times faster.
55+
_Building with a CGO driver is the easiest way to boost the query performance without changing your db structure or hardware but keep in mind that it complicates cross-compilation._
5956

6057

6158
## About the benchmarks
@@ -84,7 +81,7 @@ In order to emulate real usage scenarios as close as possible, the tests are gro
8481

8582
To run the benchmarks locally or on your server, you can:
8683

87-
0. _[Install Go 1.18+](https://go.dev/doc/install) (if you haven't already)_
84+
0. _[Install Go 1.23+](https://go.dev/doc/install) (if you haven't already)_
8885
1. Clone/download the repo
8986
2. Run `GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build` (_https://go.dev/doc/install/source#environment_)
9087
3. Start the created executable by running `./app serve`.

benchmarks/bench.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
)
1010

1111
type BenchResult struct {
12+
Errors []error
1213
Best time.Duration
1314
Worst time.Duration
1415
Completed time.Duration
15-
Errors []error
1616
}
1717

1818
func (r BenchResult) String() string {

benchmarks/request.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
)
1212

1313
type Request struct {
14+
Body io.Reader
15+
Context context.Context
16+
Headers map[string]string
1417
Method string
1518
Url string
16-
Headers map[string]string
17-
Body io.Reader
18-
Context context.Context // default to context.Background()
1919
}
2020

2121
// If destBody is non-nil, it will read and unmarshal the request
@@ -49,7 +49,7 @@ func (c *Request) Send(destBody any) error {
4949
Proxy: http.ProxyFromEnvironment,
5050
DialContext: dialer.DialContext,
5151
MaxIdleConns: 0,
52-
IdleConnTimeout: 90 * time.Second,
52+
IdleConnTimeout: 120 * time.Second,
5353
TLSHandshakeTimeout: 10 * time.Second,
5454
ExpectContinueTimeout: 1 * time.Second,
5555
},

0 commit comments

Comments
 (0)