Skip to content

Performance and scaling issue #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
eshubin opened this issue Apr 16, 2025 · 12 comments
Open

Performance and scaling issue #498

eshubin opened this issue Apr 16, 2025 · 12 comments

Comments

@eshubin
Copy link

eshubin commented Apr 16, 2025

Hello Stefan,
I created a timoni manifest for a project with pretty big number of services (in terms of Service Oriented Architecture) and reached some limitations of timoni. As I can not disclose the real source code, a simple demo project is opensourced.
In order to reduce a boilerplate code I extracted common pieces of Deployments, ConfigMaps and service configuration.
Services (1,2,3 ...) configuration have some repeatable parts such as MongoDB, S3, MySQL, etc. Each of these parts has global and per service configuration, merged in common code.
I noticed that with a growth of the manifest a simple command timoni mod vet started taking more and more time and memory. Metrics of memory usage and time were taken from the output of the command /usr/bin/time -v timoni mod vet on Ubuntu 22.04 and timoni 0.24.0 (the same behaviour on older versions), fields Maximum resident set size and Elapsed (wall clock) time correspondingly.
As you can see from README on each git tag memory usage grows exponentially for each new service.
So for 4 services timoni mod vet used 275MB of memory and took 3 seconds.
For 5 it was 400MB and 8 seconds.
For 6 it is already 580MB and 10 seconds.
On real project with more services and bigger configs I reached 7GB of memory usage and 7 minutes of execution time.

Could you, please, assist with resolving that issue?
Best,
Eugene

@stefanprodan
Copy link
Owner

@eshubin can you please build the module using the cue binary as showed here, this will help determine if the issue is in Timoni or in CUE itself.

@eshubin
Copy link
Author

eshubin commented Apr 17, 2025

cue cmd -t debug -t name=test -t namespace=test -t mv=1.0.0 -t kv=1.28.0 build produces many errors like

timoni.instance.objects.cm6.#config.image: field not allowed:
./templates/service6.cue:9:28
./debug_values.cue:8:2
./templates/common.cue:121:17
./templates/config.cue:9:10
./templates/config.cue:94:10
./templates/config.cue:112:14
./templates/config.cue:112:45
./templates/service6.cue:3:21
./templates/service6.cue:4:14
./timoni.cue:14:9
./timoni.cue:24:12
./timoni.cue:27:11
./timoni.cue:29:11
timoni.instance.objects.cm6.#config.resources: field not allowed:
./templates/service6.cue:9:28
./debug_values.cue:21:2
./templates/common.cue:121:17
./templates/config.cue:9:10
./templates/config.cue:94:10
./templates/config.cue:112:14
./templates/config.cue:112:45
./templates/service6.cue:3:21
./templates/service6.cue:4:14
./timoni.cue:14:9
./timoni.cue:24:12
./timoni.cue:27:11
./timoni.cue:29:11

cue version

cue version v0.12.0

go version go1.23.5
-buildmode exe
-compiler gc
-trimpath true
CGO_ENABLED 0
GOARCH amd64
GOOS linux
GOAMD64 v1
cue.lang.version v0.12.0

Cue version is the same as is used in timoni.

@stefanprodan
Copy link
Owner

You need to set all the required values in the debug values file

@eshubin
Copy link
Author

eshubin commented Apr 17, 2025

Thanks, fixed that. cue command uses even more resources
Command being timed: "cue cmd -t debug -t name=test -t namespace=test -t mv=1.0.0 -t kv=1.28.0 build"
User time (seconds): 53.65
System time (seconds): 0.59
Percent of CPU this job got: 152%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:35.55
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 1037592
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 263022
Voluntary context switches: 8109
Involuntary context switches: 1704
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0

@stefanprodan
Copy link
Owner

Yeah I was expecting this, please open an issue in the cue lang repo here https://github.com/cue-lang/cue

@eshubin
Copy link
Author

eshubin commented Apr 17, 2025

Do you think I can use the repo with timoni declaration for this bug report or better to extract something smaller?

@stefanprodan
Copy link
Owner

As long as they can reproduce it with just the cue command I think it’s fine to point them to the repo with the Timoni module, in the end a Timoni module is just a CUE module.

@eshubin
Copy link
Author

eshubin commented Apr 18, 2025

CUE's master branch is rocket faster and uses 3 times less memory for my example eshubin/timoni-bug@d405e41.

@eshubin
Copy link
Author

eshubin commented Apr 18, 2025

Do you plan to integrate the newer version of CUE? CUE v0.12.1 does not have that optimization eshubin/timoni-bug@23726cd

@stefanprodan
Copy link
Owner

stefanprodan commented Apr 18, 2025

If the optimization is in the latest stable CUE release we can update Timoni deps and make a release. I can do that next week.

@eshubin
Copy link
Author

eshubin commented Apr 18, 2025

only in the master branch for now.

@stefanprodan
Copy link
Owner

@eshubin can you please run the tests with Timoni v0.25.0. I've updated CUE to v0.13 which should come with major performance improvements compared to the previous versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants