balances, pageRes, err := k.mk.GetPaginatedBalances(ctx, req.Pagination, addr)
	"fmt"
	"time"
	"runtime"
func TestQueryAllBalancesWithExtremeLoad(t *testing.T) {
	ctx, input := createDefaultTestInput(t)
	_, _, addr := testdata.KeyTestPubAddr()

	// Create an account with an extremely large number of different token balances
	acc := input.AccountKeeper.NewAccountWithAddress(ctx, addr)
	input.AccountKeeper.SetAccount(ctx, acc)

	// Create 100,000 different token balances with large amounts
	totalCoins := sdk.NewCoins()
	for i := 0; i < 100000; i++ {
		// Use large amounts to increase memory usage
		amount := math.NewInt(1000000000000) // 1 trillion units per token
		coin := sdk.NewCoin(fmt.Sprintf("token%d", i), amount)
		totalCoins = totalCoins.Add(coin)
	}
	input.Faucet.Fund(ctx, acc.GetAddress(), totalCoins...)

	// Test with extremely large page size
	pageReq := &query.PageRequest{
		Key:        nil,
		Limit:      1000000000, // 1 billion page size
		CountTotal: true,
	}
	req := types.NewQueryAllBalancesRequest(addr, pageReq, false)

	// Record memory stats before query
	var m runtime.MemStats
	runtime.ReadMemStats(&m)
	beforeAlloc := m.Alloc
	beforeSys := m.Sys

	// Record start time
	startTime := time.Now()

	// Execute query
	res, err := input.BankKeeper.AllBalances(ctx, req)

	// Calculate duration
	duration := time.Since(startTime)

	// Record memory stats after query
	runtime.ReadMemStats(&m)
	afterAlloc := m.Alloc
	afterSys := m.Sys

	// Log performance metrics
	t.Logf("Query execution time: %v", duration)
	t.Logf("Memory allocated before: %d MB", beforeAlloc/1024/1024)
	t.Logf("Memory allocated after: %d MB", afterAlloc/1024/1024)
	t.Logf("Memory increase: %d MB", (afterAlloc-beforeAlloc)/1024/1024)
	t.Logf("System memory before: %d MB", beforeSys/1024/1024)
	t.Logf("System memory after: %d MB", afterSys/1024/1024)
	t.Logf("System memory increase: %d MB", (afterSys-beforeSys)/1024/1024)

	// Test should still complete successfully despite the load
	require.NoError(t, err)
	require.NotNil(t, res)
	require.Equal(t, 100000, len(res.Balances))

	// Verify total amount (sample a few random coins)
	for i := 0; i < 10; i++ {
		randomIndex := i * 10000 // Check every 10000th coin
		denom := fmt.Sprintf("token%d", randomIndex)
		require.True(t, res.Balances.AmountOf(denom).Equal(math.NewInt(1000000000000)))
	}
}
=== RUN   TestQueryAllBalancesWithExtremeLoad
panic: test timed out after 10m0s
        running tests:
                TestQueryAllBalancesWithExtremeLoad (10m0s)

goroutine 52 [running]:
testing.(*M).startAlarm.func1()
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/testing/testing.go:2373 +0x385
created by time.goFunc
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/time/sleep.go:215 +0x2d

goroutine 1 [chan receive, 10 minutes]:
testing.(*T).Run(0xc00159a000, {0x1049a936a?, 0x300745d801307b50?}, 0x105a37388)
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/testing/testing.go:1751 +0x3ab
testing.runTests.func1(0xc00159a000)
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/testing/testing.go:2168 +0x37
testing.tRunner(0xc00159a000, 0xc001307c70)
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/testing/testing.go:1690 +0xf4
testing.runTests(0xc000013560, {0x1077e34c0, 0x1c, 0x1c}, {0x102252250?, 0x0?, 0x1078ee400?})
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/testing/testing.go:2166 +0x43d
testing.(*M).Run(0xc000e1f180)
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/testing/testing.go:2034 +0x64a
main.main()
        _testmain.go:101 +0x9b

goroutine 20 [select, 10 minutes]:
github.com/desertbit/timer.timerRoutine()
        /Users/rhaydden/go/pkg/mod/github.com/desertbit/timer@v0.0.0-20180107155436-c41aec40b27f/timers.go:119 +0x9e
created by github.com/desertbit/timer.init.0 in goroutine 1
        /Users/rhaydden/go/pkg/mod/github.com/desertbit/timer@v0.0.0-20180107155436-c41aec40b27f/timers.go:15 +0x1a

goroutine 37 [select]:
go.opencensus.io/stats/view.(*worker).start(0xc000679e00)
        /Users/rhaydden/go/pkg/mod/go.opencensus.io@v0.24.0/stats/view/worker.go:292 +0x9f
created by go.opencensus.io/stats/view.init.0 in goroutine 1
        /Users/rhaydden/go/pkg/mod/go.opencensus.io@v0.24.0/stats/view/worker.go:34 +0x8d

goroutine 66 [runnable]:
math/big.(*Int).Add(0xc001e52800, 0xc001e527c0?, 0xc001e238a0?)
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/math/big/int.go:141 +0x1c5
cosmossdk.io/math.add(...)
        /Users/rhaydden/go/pkg/mod/cosmossdk.io/math@v1.4.0/int.go:46
cosmossdk.io/math.Int.SafeAdd({0xc001262000?}, {0x11296e108?})
        /Users/rhaydden/go/pkg/mod/cosmossdk.io/math@v1.4.0/int.go:293 +0x34
cosmossdk.io/math.Int.Add(...)
        /Users/rhaydden/go/pkg/mod/cosmossdk.io/math@v1.4.0/int.go:279
github.com/cosmos/cosmos-sdk/types.Coin.Add({{0xc002228940?, 0xc002309a78?}, {0xc001e527c0?}}, {{0xc002228940?, 0x10598da00?}, {0xc001e238a0?}})
        /Users/rhaydden/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/types/coin.go:114 +0x85
github.com/cosmos/cosmos-sdk/types.Coins.safeAdd({0xc002f7e000, 0x9eea, 0xb2aa}, {0xc00230d1b8, 0x1, 0x1})
        /Users/rhaydden/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/types/coin.go:344 +0x4c9
github.com/cosmos/cosmos-sdk/types.Coins.Add(...)
        /Users/rhaydden/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/types/coin.go:314
github.com/initia-labs/initia/x/bank/keeper_test.TestQueryAllBalancesWithExtremeLoad(0xc00159a1a0)
        /Users/rhaydden/initia-2/x/bank/keeper/grpc_query_test.go:122 +0x437
testing.tRunner(0xc00159a1a0, 0x105a37388)
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/testing/testing.go:1690 +0xf4
created by testing.(*T).Run in goroutine 1
        /Users/rhaydden/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.6.darwin-amd64/src/testing/testing.go:1743 +0x390
FAIL    github.com/initia-labs/initia/x/bank/keeper     606.984s
FAIL
=== RUN   TestQueryAllBalancesWithExtremeLoad
    grpc_query_test.go:119: Creating 10000 token balances...
    grpc_query_test.go:140: Created 0 tokens...
    grpc_query_test.go:140: Created 1000 tokens...
    grpc_query_test.go:140: Created 2000 tokens...
    grpc_query_test.go:140: Created 3000 tokens...
    grpc_query_test.go:140: Created 4000 tokens...
    grpc_query_test.go:140: Created 5000 tokens...
    grpc_query_test.go:140: Created 6000 tokens...
    grpc_query_test.go:140: Created 7000 tokens...
    grpc_query_test.go:140: Created 8000 tokens...
    grpc_query_test.go:140: Created 9000 tokens...
    grpc_query_test.go:144: Finished creating tokens. Starting query test...
    grpc_query_test.go:175: Query execution time: 120.322792ms
    grpc_query_test.go:176: Memory allocated before: 228 MB
    grpc_query_test.go:177: Memory allocated after: 246 MB
    grpc_query_test.go:178: Memory increase: 17 MB
    grpc_query_test.go:179: System memory before: 344 MB
    grpc_query_test.go:180: System memory after: 344 MB
    grpc_query_test.go:181: System memory increase: 0 MB
--- PASS: TestQueryAllBalancesWithExtremeLoad (50.35s)
PASS
