Commit e3092fe
committed
Performance updates.
Benchmarking originally showed fairly high memory usage and a slow garbage
collection schedule when creating 1000 contexts. To avoid this, a garbage
collection cycle was put into place after each function execution. This
solved the memory bloat, but slowed down function calls.
I decided to revisit that decision.
Memory limits were an arbitrary 256MB when the concept was put into place
in plv8 in 2019, and 512MB is a decent default with modern hardware. It
can still be changed to 256MB with a GUC if desired.
The benchmark was able to trigger an out of memory issue, but under very
artificial conditions:
* 1000 roles, and thus quickjs contexts were being created
* Each context carries an allocation of 190kb on MacOS (untested on Linux)
Even though the roles are deleted, there is no mechanism for postgres to tell
pljs this, and those contexts essentially become zombies in the cache.
Since the benchmark is an extremely artifical (and meant specifically to
test the startup time of pljs contexts), it is unlikely that this behavior
will be able to be triggered in production. At worst case, a memory limit
is hit, and the limit needs to be increased via the GUC.
Thus garbage collection is left to run when memory pressure exists, rather
with every function execution, and more memory can be allocated to slow
memory pressure by default.
This speeds up contex creation and function calls slightly, and speeds up
the artificial context creation significantly.1 parent d87dcf4 commit e3092fe
3 files changed
+10
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
| 107 | + | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
1043 | 1043 | | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | | - | |
| 1046 | + | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | 1049 | | |
| |||
0 commit comments