Skip to content

Fix performance issue by changingthe key format of the id cache in posix fs - #602

Merged
aduffeck merged 5 commits into
opencloud-eu:mainfrom
aduffeck:fix-idcache
Apr 23, 2026
Merged

aduffeck merged 5 commits into
opencloud-eu:mainfrom
aduffeck:fix-idcache

Conversation

@aduffeck

Copy link
Copy Markdown
Member

We currently keep a list of plain base32 encoded paths in the cache in order to map paths to file ids. That is a problem when a subtree is deleted or moved because we have to scan the whole list to find the relevant entries.

The new approach makes use of nats hierarchical keys instead. Paths are split at the path separator, then each of the segments is base32 encoded and finally a key is compiled by joining the segments with '.'s. The dot notation enables us to use a nats watcher and query for all entries that belong to a subtree using a wildcard much more efficiently.

We currently keep a list of plain base32 encoded paths in the cache in
order to map paths to file ids. That is a problem when a subtree is
deleted or moved because we have to scan the whole list to find the
relevant entries.

The new approach makes use of nats hierarchical keys instead. Paths are
split at the path separator, then each of the segments is base32 encoded
and finally a key is compiled by joining the segments with '.'s. The
dot notation enables us to use a nats watcher and query for all entries
that belong to a subtree using a wildcard much more efficiently.
@aduffeck
aduffeck force-pushed the fix-idcache branch 8 times, most recently from 89b5ebe to 2ce0596 Compare April 23, 2026 08:51
@rhafer

rhafer commented Apr 23, 2026 •

Copy link
Copy Markdown
Member

Now the woodpecker linter doesn't the yaml anymore.

api-integration-test-on-posixfs: services.nats
Additional property entrypoint is not allowed

See: https://ci.opencloud.rocks/repos/4/pipeline/989/errors

The tests are green though 🤔

@aduffeck

Copy link
Copy Markdown
Member Author

Yes, the linter complains but it still works.. nats comes up properly now despite the linter warning:

[1] 2026/04/23 08:55:43.749209 [INF] Starting nats-server
[1] 2026/04/23 08:55:43.749279 [INF]   Version:  2.12.7
[1] 2026/04/23 08:55:43.749283 [INF]   Git:      [b4ce0f9]
[1] 2026/04/23 08:55:43.749286 [INF]   Name:     NDISQHHAYGD2CMHMZYWGASJXXZNZET6BTDL2UGSEEVCYMFSM36AE7OLQ
[1] 2026/04/23 08:55:43.749301 [INF]   Node:     VyYT7cKP
[1] 2026/04/23 08:55:43.749304 [INF]   ID:       NDISQHHAYGD2CMHMZYWGASJXXZNZET6BTDL2UGSEEVCYMFSM36AE7OLQ
[1] 2026/04/23 08:55:43.750252 [INF] Starting JetStream
[1] 2026/04/23 08:55:43.750272 [WRN] Temporary storage directory used, data could be lost on system reboot
[1] 2026/04/23 08:55:43.750569 [INF]     _ ___ _____ ___ _____ ___ ___   _   __  __
[1] 2026/04/23 08:55:43.750580 [INF]  _ | | __|_   _/ __|_   _| _ \ __| /_\ |  \/  |
[1] 2026/04/23 08:55:43.750583 [INF] | || | _|  | | \__ \ | | |   / _| / _ \| |\/| |
[1] 2026/04/23 08:55:43.750584 [INF]  \__/|___| |_| |___/ |_| |_|_\___/_/ \_\_|  |_|
[1] 2026/04/23 08:55:43.750586 [INF] 
[1] 2026/04/23 08:55:43.750588 [INF]          https://docs.nats.io/jetstream
[1] 2026/04/23 08:55:43.750590 [INF] 
[1] 2026/04/23 08:55:43.750592 [INF] ---------------- JETSTREAM ----------------
[1] 2026/04/23 08:55:43.750593 [INF]   Strict:          true
[1] 2026/04/23 08:55:43.750597 [INF]   Max Memory:      22.95 GB
[1] 2026/04/23 08:55:43.750600 [INF]   Max Storage:     152.31 GB
[1] 2026/04/23 08:55:43.750602 [INF]   Store Directory: "/tmp/nats/jetstream"
[1] 2026/04/23 08:55:43.750605 [INF]   API Level:       3
[1] 2026/04/23 08:55:43.750607 [INF] -------------------------------------------
[1] 2026/04/23 08:55:43.750987 [INF] Took 725.129µs to start JetStream
[1] 2026/04/23 08:55:43.751289 [INF] Listening for client connections on 0.0.0.0:4222
[1] 2026/04/23 08:55:43.758048 [INF] Server is ready

The tests are still failing with some timeouts, though. Looks like maybe the connection to nats doesn't work properly... 🙄

@rhafer

rhafer commented Apr 23, 2026

Copy link
Copy Markdown
Member

Yes, the linter complains but it still works.. nats comes up properly now despite the linter warning:

The entrypoint property is indeed not allowed on service by the woodpecker schema (https://github.com/woodpecker-ci/woodpecker/blob/main/pipeline/frontend/yaml/linter/schema/schema.json#L862) that looks like a bug in the schema though as the code itself is fine with it (https://github.com/woodpecker-ci/woodpecker/blob/main/pipeline/frontend/yaml/types/container.go#L30)

@rhafer

rhafer commented Apr 23, 2026

Copy link
Copy Markdown
Member

Yes, the linter complains but it still works.. nats comes up properly now despite the linter warning:

The entrypoint property is indeed not allowed on service by the woodpecker schema (https://github.com/woodpecker-ci/woodpecker/blob/main/pipeline/frontend/yaml/linter/schema/schema.json#L862) that looks like a bug in the schema though as the code itself is fine with it (https://github.com/woodpecker-ci/woodpecker/blob/main/pipeline/frontend/yaml/types/container.go#L30)

Fixed in woodpecker-ci/woodpecker#6487

@rhafer rhafer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants