okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

Aly Raffauftest(stream): cover active output recovery and spill lifetimesb0282b1

main
1.0 KiB24 linesraw
1-module(albedo_active_output_probe).
2-export([stats/1, expire/2, sweep/1]).
3
4stats(Id) ->
5    {some, Subject} = 'albedo@daemon@session':live(Id),
6    {ok, Owner} = 'gleam@erlang@process':subject_owner(Subject),
7    erlang:garbage_collect(Owner),
8    Info = process_info(Owner, [memory, binary, reductions, message_queue_len]),
9    Binaries = maps:from_list([{Ref, Size} || {Ref, Size, _} <- proplists:get_value(binary, Info)]),
10    json:encode(#{actor_heap_bytes => proplists:get_value(memory, Info),
11        actor_binary_bytes => lists:sum(maps:values(Binaries)),
12        actor_reductions => proplists:get_value(reductions, Info),
13        mailbox => proplists:get_value(message_queue_len, Info)}).
14
15expire(Home, Id) ->
16    Path = filename:join([Home, <<"active-output">>, <<Id/binary, ".meta">>]),
17    {ok, Binary} = file:read_file(Path),
18    Meta = binary_to_term(Binary),
19    ok = file:write_file(Path, term_to_binary(Meta#{expires => 0})),
20    <<"true">>.
21
22sweep(Home) ->
23    albedo_active_output:maintenance(Home),
24    <<"true">>.