Skip to content

Commit 213535e

Browse files
committed
accounts: add new accounts page
1 parent 44f1f93 commit 213535e

14 files changed

Lines changed: 1502 additions & 95 deletions

File tree

src/api/atoms.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import type {
3939
ResetSlot,
4040
RepairSlot,
4141
LiveProgramCache,
42+
AccountsStats,
4243
} from "./types";
4344
import { rafAtom } from "../atomUtils";
4445
import type { ValuesWithHistory } from "./worker/types";
@@ -188,3 +189,5 @@ export const slotRankingsAtom = atom<SlotRankings | undefined>(undefined);
188189
export const liveProgramCacheAtom = atom<LiveProgramCache | undefined>(
189190
undefined,
190191
);
192+
193+
export const accountsStatsAtom = rafAtom<AccountsStats | undefined>(undefined);

src/api/entities.ts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const supermajorityTopicSchema = z.object({
3131
topic: z.literal("wait_for_supermajority"),
3232
});
3333

34+
const accountsTopicSchema = z.object({
35+
topic: z.literal("accounts"),
36+
});
37+
3438
export const topicSchema = z.discriminatedUnion("topic", [
3539
summaryTopicSchema,
3640
epochTopicSchema,
@@ -39,6 +43,7 @@ export const topicSchema = z.discriminatedUnion("topic", [
3943
slotTopicSchema,
4044
blockEngineTopicSchema,
4145
supermajorityTopicSchema,
46+
accountsTopicSchema,
4247
]);
4348

4449
export const versionSchema = z.string();
@@ -968,3 +973,109 @@ export const supermajoritySchema = z.discriminatedUnion("key", [
968973
value: supermajorityPeerRemoveSchema,
969974
}),
970975
]);
976+
977+
export const accountsDiskSchema = z.object({
978+
accounts_total: z.number(),
979+
accounts_capacity: z.number(),
980+
allocated_bytes: z.number(),
981+
current_bytes: z.number(),
982+
used_bytes: z.number(),
983+
});
984+
985+
export const accountsCompactionSchema = z.object({
986+
in_compaction: z.number(),
987+
compactions_requested: z.number(),
988+
compactions_completed: z.number(),
989+
accounts_relocated_bytes: z.number(),
990+
relocated_bytes_per_sec: z.number(),
991+
});
992+
993+
export const accountsCacheClassSchema = z.object({
994+
class: z.number(),
995+
used_slots: z.number(),
996+
max_slots: z.number(),
997+
reserved_slots: z.number(),
998+
target_used_slots: z.number(),
999+
low_water_used_slots: z.number(),
1000+
not_found: z.number(),
1001+
evicted: z.number(),
1002+
preevicted: z.number(),
1003+
committed_new: z.number(),
1004+
committed_overwrite: z.number(),
1005+
not_found_per_sec: z.number(),
1006+
evicted_per_sec: z.number(),
1007+
preevicted_per_sec: z.number(),
1008+
committed_new_per_sec: z.number(),
1009+
committed_overwrite_per_sec: z.number(),
1010+
reads_per_sec: z.number(),
1011+
writes_per_sec: z.number(),
1012+
hit_rate_ema: z.number(),
1013+
});
1014+
1015+
export const accountsCacheSchema = z.object({
1016+
hit_rate_ema: z.number(),
1017+
size_bytes: z.number(),
1018+
classes: accountsCacheClassSchema.array(),
1019+
});
1020+
1021+
export const accountsIoSchema = z.object({
1022+
acquired: z.number(),
1023+
acquired_writable: z.number(),
1024+
bytes_read: z.number(),
1025+
bytes_copied: z.number(),
1026+
bytes_written: z.number(),
1027+
bytes_written_accdb: z.number(),
1028+
read_ops: z.number(),
1029+
write_ops: z.number(),
1030+
acquired_per_sec: z.number(),
1031+
acquired_writable_per_sec: z.number(),
1032+
bytes_read_per_sec: z.number(),
1033+
bytes_copied_per_sec: z.number(),
1034+
bytes_written_per_sec: z.number(),
1035+
read_ops_per_sec: z.number(),
1036+
write_ops_per_sec: z.number(),
1037+
prewrite_ratio: z.number(),
1038+
});
1039+
1040+
export const accountsPartitionSchema = z.object({
1041+
partition_idx: z.number(),
1042+
file_offset: z.number(),
1043+
tier: z.number(),
1044+
write_offset: z.number(),
1045+
bytes_freed: z.number(),
1046+
read_ops: z.number(),
1047+
bytes_read: z.number(),
1048+
write_ops: z.number(),
1049+
bytes_written: z.number(),
1050+
read_ops_per_sec: z.number(),
1051+
bytes_read_per_sec: z.number(),
1052+
write_ops_per_sec: z.number(),
1053+
bytes_written_per_sec: z.number(),
1054+
utilization: z.number(),
1055+
fragmentation: z.number(),
1056+
used_frac: z.number(),
1057+
fragmented_frac: z.number(),
1058+
compaction_trigger_frac: z.number(),
1059+
age_seconds: z.number(),
1060+
filled_seconds: z.number(),
1061+
/* 0 = idle, 1 = queued, 2 = compacting */
1062+
compaction_state: z.number(),
1063+
compaction_frac: z.number(),
1064+
is_write_head: z.boolean(),
1065+
});
1066+
1067+
export const accountsStatsSchema = z.object({
1068+
sample_time_nanos: z.number(),
1069+
disk: accountsDiskSchema,
1070+
compaction: accountsCompactionSchema,
1071+
cache: accountsCacheSchema,
1072+
io: accountsIoSchema,
1073+
partitions: accountsPartitionSchema.array(),
1074+
});
1075+
1076+
export const accountsSchema = z.discriminatedUnion("key", [
1077+
accountsTopicSchema.extend({
1078+
key: z.literal("stats"),
1079+
value: accountsStatsSchema,
1080+
}),
1081+
]);

src/api/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ import type {
6666
supermajorityEpochSchema,
6767
peerUpdateInfoSchema,
6868
liveProgramCacheSchema,
69+
accountsStatsSchema,
70+
accountsPartitionSchema,
6971
} from "./entities";
7072

7173
export type Client = z.infer<typeof clientSchema>;
@@ -187,3 +189,7 @@ export type SlotRankings = z.infer<typeof slotRankingsSchema>;
187189
export type LiveShreds = z.infer<typeof liveShredsSchema>;
188190

189191
export type LiveProgramCache = z.infer<typeof liveProgramCacheSchema>;
192+
193+
export type AccountsStats = z.infer<typeof accountsStatsSchema>;
194+
195+
export type AccountsPartition = z.infer<typeof accountsPartitionSchema>;

src/api/useSetAtomWsData.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import {
8686
rootSlotAtom,
8787
optimisticallyConfirmedSlotAtom,
8888
liveProgramCacheAtom,
89+
accountsStatsAtom,
8990
} from "./atoms";
9091
import {
9192
estimatedTpsDebounceMs,
@@ -425,6 +426,7 @@ function useUpdateAtoms() {
425426
const addLiveShreds = useSetAtom(shredsAtoms.addShredEvents);
426427

427428
const setLiveProgramCache = useSetAtom(liveProgramCacheAtom);
429+
const setAccountsStats = useSetAtom(accountsStatsAtom);
428430

429431
const peersBuffer = useRef(new Map<string, Peer>());
430432
const removePeersBuffer = useRef(new Map<string, PeerRemove>());
@@ -742,6 +744,15 @@ function useUpdateAtoms() {
742744
}
743745
break;
744746
}
747+
case "accounts": {
748+
switch (key) {
749+
case "stats": {
750+
setAccountsStats(value);
751+
break;
752+
}
753+
}
754+
break;
755+
}
745756
}
746757
},
747758
[
@@ -774,6 +785,7 @@ function useUpdateAtoms() {
774785
setIdentityBalance,
775786
setIdentityKey,
776787
setLateVoteHistory,
788+
setAccountsStats,
777789
setLiveProgramCache,
778790
setOptimisticallyConfirmedSlot,
779791
setResetSlot,

src/api/worker/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import z from "zod";
22
import {
3+
accountsSchema,
34
blockEngineSchema,
45
epochSchema,
56
gossipSchema,
@@ -18,6 +19,7 @@ export const WsMessageSchema = z.discriminatedUnion("topic", [
1819
slotSchema,
1920
blockEngineSchema,
2021
supermajoritySchema,
22+
accountsSchema,
2123
]);
2224

2325
export type WsMessage = z.infer<typeof WsMessageSchema>;
@@ -41,7 +43,8 @@ export type WsEntity =
4143
| KvFrom<typeof peersSchema, "peers">
4244
| KvFrom<typeof slotSchema, "slot">
4345
| KvFrom<typeof blockEngineSchema, "block_engine">
44-
| KvFrom<typeof supermajoritySchema, "wait_for_supermajority">;
46+
| KvFrom<typeof supermajoritySchema, "wait_for_supermajority">
47+
| KvFrom<typeof accountsSchema, "accounts">;
4548

4649
export type FromWorkerMessage =
4750
| { type: "connecting" }

0 commit comments

Comments
 (0)