Commit ce32cfe
committed
prometheus_text_format: Eliminate
Building on the work in the parent commit, now that the data being
passed to the `ram_file` is a binary, we can instead build the entire
output gradually within the process. We pay in terms of I/O overhead
from writing and then reading from the `ram_file` since `ram_file` is a
port - all data is passed between the VM and the port driver. The memory
consumed by a port driver is also invisible to the VM's allocator, so
large port driver resource usage should be avoided where possible.
Instead this change refactors the `registry_collect_callback` to fold
over collectors and build an accumulator. The `create_mf` callback's
return of `ok` forces us to store this rather than pass and return it.
So it's a little less hygienic but is more efficient than passing data
in/out of a port.
This also introduces a function `format_into/3` which can use this
folding function directly. This can be used to avoid collecting the
entire response in one binary. Instead the response can be streamed
with `cowboy_req:stream_body/3` for example.ram_file, add format_into/3
1 parent dc65494 commit ce32cfe
1 file changed
Lines changed: 41 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
70 | 100 | | |
71 | 101 | | |
72 | 102 | | |
| |||
84 | 114 | | |
85 | 115 | | |
86 | 116 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 117 | | |
111 | 118 | | |
112 | 119 | | |
| |||
0 commit comments