Skip to content

Commit 092cdd5

Browse files
committed
chore: test with max memory setting
1 parent a3d71ee commit 092cdd5

File tree

4 files changed

+9
-46
lines changed

4 files changed

+9
-46
lines changed

apps/insights/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const config = {
44
reactCompiler: true,
55
},
66

7+
cacheMaxMemorySize: 200 * 1024 * 1024, // 200MB
78
reactStrictMode: true,
89

910
pageExtensions: ["ts", "tsx", "mdx"],

apps/insights/src/components/Root/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ import {
1111
} from "../../config/server";
1212
import { LivePriceDataProvider } from "../../hooks/use-live-price-data";
1313
import { getPublishers } from "../../services/clickhouse";
14-
import { Cluster, getFeeds } from "../../services/pyth";
14+
import { Cluster } from "../../services/pyth";
1515
import { PriceFeedIcon } from "../PriceFeedIcon";
1616
import { PublisherIcon } from "../PublisherIcon";
1717
import { SearchButton as SearchButtonImpl } from "./search-button";
18+
import { getFeedsCached } from '../../server/pyth';
1819

1920
export const TABS = [
2021
{ segment: "", children: "Overview" },
@@ -76,7 +77,7 @@ const getPublishersForSearchDialog = async (cluster: Cluster) => {
7677

7778
const getFeedsForSearchDialog = async (cluster: Cluster) => {
7879
"use cache";
79-
const feeds = await getFeeds(cluster);
80+
const feeds = await getFeedsCached(cluster);
8081

8182
return feeds.map((feed) => ({
8283
symbol: feed.symbol,

apps/insights/src/server/pyth.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import superjson from "superjson";
22
import { z } from 'zod';
33

4-
import { Cluster, clients, getFeeds, priceFeedsSchema } from "../services/pyth";
4+
import { Cluster, clients, priceFeedsSchema } from "../services/pyth";
55

66
export const getPublishersForFeed = async (
77
cluster: Cluster,
@@ -16,7 +16,7 @@ export const getPublishersForFeed = async (
1616
return result;
1717
};
1818

19-
const getAllFeeds = async (cluster: Cluster) => {
19+
const getFeeds = async (cluster: Cluster) => {
2020
"use cache";
2121
const data = await clients[cluster].getData();
2222

@@ -39,7 +39,7 @@ export const getFeedsForPublisherCached = async (
3939
cluster: Cluster,
4040
publisher: string,
4141
) => {
42-
const rawFeeds = await getAllFeeds(cluster);
42+
const rawFeeds = await getFeeds(cluster);
4343
const feeds = superjson.parse<z.infer<typeof priceFeedsSchema>>(rawFeeds);
4444
return priceFeedsSchema.parse(feeds.filter(({ price }) =>
4545
price.priceComponents.some(
@@ -50,7 +50,8 @@ export const getFeedsForPublisherCached = async (
5050

5151
export const getFeedsCached = async (cluster: Cluster) => {
5252
"use cache";
53-
return getFeeds(cluster);
53+
const rawFeeds = await getFeeds(cluster);
54+
return superjson.parse<z.infer<typeof priceFeedsSchema>>(rawFeeds);
5455
};
5556

5657
export const getPublishersForFeedCached = async (cluster: Cluster, symbol: string) => {

apps/insights/src/services/pyth.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -61,46 +61,6 @@ export const clients = {
6161
[Cluster.PythtestConformance]: mkClient(Cluster.PythtestConformance),
6262
} as const;
6363

64-
export const getFeeds = async (cluster: Cluster) => {
65-
const data = await clients[cluster].getData();
66-
return priceFeedsSchema.parse(
67-
data.symbols.map((symbol) => ({
68-
symbol,
69-
product: data.productFromSymbol.get(symbol),
70-
price: {
71-
...data.productPrice.get(symbol),
72-
priceComponents: data.productPrice.get(symbol)?.priceComponents.map(({ publisher }) => ({
73-
publisher: publisher.toBase58(),
74-
})) ?? [],
75-
},
76-
})),
77-
);
78-
};
79-
80-
export const getFeedsForPublisher = async (
81-
cluster: Cluster,
82-
publisher: string,
83-
) => {
84-
const data = await clients[cluster].getData();
85-
return priceFeedsSchema.parse(
86-
data.symbols
87-
.filter(
88-
(symbol) =>
89-
data.productFromSymbol.get(symbol)?.display_symbol !== undefined,
90-
)
91-
.map((symbol) => ({
92-
symbol,
93-
product: data.productFromSymbol.get(symbol),
94-
price: data.productPrice.get(symbol),
95-
}))
96-
.filter(({ price }) =>
97-
price?.priceComponents.some(
98-
(component) => component.publisher.toBase58() === publisher,
99-
),
100-
),
101-
);
102-
};
103-
10464
export const priceFeedsSchema = z.array(
10565
z.object({
10666
symbol: z.string(),

0 commit comments

Comments
 (0)