feat: thread autoscaling #1266
Decouple workers.
fe1158fb
Moves code to separate file.
ad341400
Cleans up the exponential backoff.
89b211d6
Initial working implementation.
7d2ab8cc
Refactors php threads to take callbacks.
f7e7d41f
Cleanup.
c03c59bd
Cleanup.
a9857dc8
Cleanup.
bac9555d
Cleanup.
a2f8d59d
Merge branch 'main' into refactor/start-worker-threads-directly
279924ca
Adjusts watcher logic.
08254531
Adjusts the watcher logic.
17d5cbe5
Fix opcache_reset race condition.
09e0ca67
Merge branch 'main' into refactor/start-worker-threads-directly
a726a2c3
Fixing merge conflicts and formatting.
7f13ada3
Prevents overlapping of TSRM reservation and script execution.
13fb4bb7
Adjustments as suggested by @dunglas.
a8a00c83
Adds error assertions.
b4dd1382
Adds comments.
03f98fad
Removes logs and explicitly compares to C.false.
e52dd0fe
Resets check.
cd98e33e
Adds cast for safety.
4e2a2c61
Fixes waitgroup overflow.
c51eb931
Resolves waitgroup race condition on startup.
89d8e267
Moves worker request logic to worker.go.
3587243f
Removes defer.
ec32f0cc
Removes call from go to c.
4e356989
Merge branch 'main' into refactor/start-worker-threads-directly
740fac79
Fixes merge conflict.
8a272cba
Adds fibers test back in.
ecce5d52
Refactors new thread loop approach.
06ebd67c
Removes redundant check.
c811f4a1
Adds compareAndSwap.
6bd047a4
Refactor: removes global waitgroups and uses a 'thread state' abstrac…
55ad8ba8
Merge branch 'main' into refactor/start-worker-threads-directly
3ffbe063
Removes unnecessary method.
01ed92bc
Updates comment.
790cccc1
Removes unnecessary booleans.
0dd26051
test
60a66b41
First state machine steps.
4719fa8e
Splits threads.
f72e8cbb
Minimal working implementation with broken tests.
d20e7067
Fixes tests.
6747d156
Refactoring.
54dc2675
Merge branch 'main' into refactor/start-worker-threads-directly
660efcd4
Fixes merge conflicts.
62147546
Formatting
00eb8340
C formatting.
02b73b16
More cleanup.
421904e8
Allows for clean state transitions.
cca2a00a
Adds state tests.
ec8aeb7b
Adds support for thread transitioning.
b598bd34
Fixes the testdata path.
66cedbdb
Formatting.
06af5d58
Allows transitioning back to inactive state.
71c16bc1
Fixes go linting.
5095342a
Formatting.
4b180593
Removes duplication.
15429d99
Applies suggestions by @dunglas
c0806086
Removes redundant check.
a166b876
Locks the handler on restart.
9491e6b2
Removes unnecessary log.
e795c869
Adds frankenphp admin api.
68fa1240
Allows booting threads at runtime.
b6cbfae3
Adds proper admin status codes and tests.
f1852792
Makes config smaller.
ea0a4fe3
Adds max threads option and debug status.
fcb5f8c1
Adds test with debug message.
a43ecbe3
Formatting and comments.
b117bff4
Changes Unpin() logic as suggested by @withinboredom
ef1bd0d9
Allows scaling regular threads.
8cd90615
Only allows POST requests.
9e8d8f03
Adds suggestions by @dunglas and resolves TODO.
a8a45450
Makes restarts fully safe.
23a63622
Merge branch 'refactor/start-worker-threads-directly' into feat/worke…
62224bf9
Will make the initial startup fail even if the watcher is enabled (as…
18e3e587
Also adds compareAndSwap to the test.
3672c60f
Adds comment.
38f87b7b
Merge branch 'refactor/start-worker-threads-directly' into feat/worke…
96265d3c
Prevents panic on initial watcher startup.
d97ebfe1
Merge branch 'refactor/start-worker-threads-directly' into feat/worke…
950a5092
Cleans up admin endpoints.
5f1ec1f0
Fixes admin test.
7c61dfac
Boots a thread in a test.
2af993e0
Sets more explicit max_threads.
547139f1
Adjusts naming.
c8bf1ecc
Adds docs.
7f2b94e4
Changes logic to actually terminate the thread.
df782541
Removes the test's randomness.
ec0bc0f4
Adds comments.
8f104070
Adds comments.
91c324de
Scaling v1.
ff06bd77
Scaling v2.
50ba1061
Allows regular thread scaling.
bfe3de1c
Refactors wait-time.
e9f62b93
Explicitly requires setting max_threads.
21949ddb
Removes redundant check.
39a7fc9d
Removes unnecessary import.
442a558e
Records clock time.
c213fc9e
Saves CPU metrics of last 100 requests.
58daaa55
Integrates CPU tracking.
14925f6b
Replaces clock with probing.
d408bdd2
fmt.
8fc3293c
Adds autoscale tests.
03142478
Merge branch 'main' into feat/auto-scale-clock-time
bd4af113
Merges main.
dc10546b
Fixes alpine (probably)
3b9f5774
Fixes alpine (definitely)
790ce4ed
go fmt
29de62af
Removes unnecessary 'isProtected'
b4474126
dunglas
marked this pull request as ready for review 1 year ago
Adds perf tests.
6fa90d65
Adds request status message to thread debug status.
3bd7c76b
Adjusts performance tests.
45cd915c
Adds an exponential backoff on request overflow.
af404706
Merge branch 'main' into feat/auto-scale-clock-time
d5e8f86a
changes dir.
c7acb255
Linting and formatting.
8c22cbf1
Linting and formatting.
745b29bc
Adds explicit scaling tests.
68ae2e4d
Adjusts perf tests.
09a5caf8
Uses different worker in removal test.
3cfcb117
More formatting fixes.
cbe45fc4
Replaces inline errors and adjusts comments.
1d8e9735
Formatting.
bf48b145
Formatting.
4f0cc8a9
Formatting.
d483baff
Merge branch 'main' into feat/auto-scale-clock-time
d222520f
Merge branch 'main' into feat/auto-scale-clock-time
48079470
Implements suggestions by @dunglas.
eef7815d
Adds note.
601a43a0
Formatting.
971e1dcf
suggestion: Refactor scaling strategy (#1289)
f4f95762
Merge branch 'feat/auto-scale-clock-time' of https://github.com/dungl…
6ec9ad9d
Resets strategy and fixes tests.
5282e320
Adds scaling strategies.
83d8c11f
Fixes test reloading.
c0946800
Prevents threads from respawning after shutdown.
3ba080ab
Adjusts transition tests.
7934b50a
Simplifies scaling.
eb5e76d5
Merge branch 'main' into feat/auto-scale-clock-time
f33aaad6
Shows the original request path in debug status.
5f70afb7
Adds automatic thread limit calculation.
9dcc2cda
Properly forwards automatic max threads.
ed90b754
Adds ini overrides.
d047149b
Adds Caddy php ini directive (for testing)
5bdd50c1
Adds explicit nil check
936556b4
Adds php.ini override test.
67589034
Fixes linting and conversions.
548d095c
Fixes fuzzing tests.
2761d9cc
clang-format
36d3f54e
Checks for original request existence on debug status.
cd5c905b
Changes the memory calculation implementation
98f22795
Renames var.
a16de66e
Reduces the stall-time.
6a6d040d
Adjusts scaling logic and comments.
83e0c080
Swaps to unix sys package.
79447b84
Only supports CPU probing on unix and SysMemory on Linux.
0545e1b3
Adjusts timers and passes the main thread directly to scaling.
615662e1
Properly overrides ini settings on startup.
618345b6
clang-format
a8b2c7c9
Adds php_ini error.
9e4a9ca1
Adds ini config.
ca20704c
Moves ini overrides to #else.
3e20e8f6
Adds some max_threads docs.
7ce4c09c
Shows special debug message if in-between worker requests.
2b1427b8
Refactors ini overrides.
d3df9f99
formatting.
1df0c9b5
Changes TODO.
e51c07d5
trigger
d43f6f08
linting
9c1c8a8c
Resets Caddyfile.
825735a8
phpIniOverrides -> phpIni
7de09724
Removes admin endpoints to PUT and DELETE threads.
54b28ac5
Puts MaxThreads for tests back in.
0bba5f69
Uses gomaxprocs instead.
bace48ca
Adjusts docs.
a43d2c04
Uses go's monotonic clock instead.
76144353
Removes unused func.
32a3129a
Removes old notations.
d1890105
Locks the thread handler on debug status.
32517fec
Locks the thread handler on debug status.
1d899dba
Merge branch 'main' into feat/auto-scale-clock-time
9a83ab1c
Merge branch 'main' into feat/auto-scale-clock-time
b3fd7568
go fmt
e3d38b5e
Makes scale chan nil if scaling is not active.
755551a9
locks before modification.
21353547
Fixes race condition on restarts in tests.
69597ef5
Merge branch 'main' into feat/auto-scale-clock-time
57a13439
Resets the opcache more safely.
16e8169b
trigger build
c038273f
Starts all threads as inactive.
064a3684
Properly removes autoscaled threads.
60b437f3
Fix.
4a5cfd1e
Marks a single thread to call opcache_reset.
954ac9e7
Marks a single thread to call opcache_reset.
3085a65f
Resets opcache_reset logic.
a1f89e3c
Downloads specific watcher version.
6544a73d
Merge branch 'main' into feat/auto-scale-clock-time
7a4aab2b
Fixes linting.
46681127
Fixes linting.
1b945f7c
dunglas
requested changes
on 2025-02-05
Adds suggestions by @dunglas.
deec7eed
Removes linux tag.
a9b1f44e
Fixes linting.
a8ea845a
Turns the debug state into json.
4e03be1d
Adds php.ini block notation.
8325a4af
Adds loglevel check.
9801f24f
Removes sleep.
7adc4659
Adjusts test to work without opcache.
9560e9f6
Removes unnecessary bool.
aaceaa88
Adds more experimental warnings.
96c34b44
Removes request locking.
319f61c4
Merge branch 'main' into feat/auto-scale-clock-time
b72df136
dunglas
approved these changes
on 2025-02-18
Merge branch 'main' into feat/auto-scale-clock-time
7ff63228
Merge branch 'main' into feat/auto-scale-clock-time
4bf5b9bc
AlliBalliBaba
deleted the feat/auto-scale-clock-time branch 1 year ago
Assignees
No one assigned
Login to write a write a comment.
Login via GitHub