remix-run / grunge-stack

The Remix Stack for deploying to AWS with DynamoDB, authentication, testing, linting, formatting, etc.
https://remix.run/stacks
MIT License
438 stars 95 forks source link

notes example app is slow #173

Open danielbush opened 1 year ago

danielbush commented 1 year ago

Have you experienced this bug with the latest version of the template?

yes

Steps to Reproduce

(1) Run npx create-remix@latest --template remix-run/grunge-stack today

Screenshot 2023-10-12 at 4 40 35 pm

(2) npm run dev (which runs remix dev --manual -c "arc sandbox -e testing")

(3) Sign up with an email and password from the home page.

(4) view and add notes using the notes app

(5) observe the speed of page loads for the notes app and generally

Expected Behavior

All routes should be "fast" especially since it is using a local sandbox and is a demo app to get people started.

Actual Behavior

The notes routes and the sign up route feel sluggish, here's my network tab:

Screenshot 2023-10-12 at 4 31 45 pm

I added some console timings around some things, one thing I'm seeing is in app/models/note.server.ts

export async function getNoteListItems({
  userId,
}: Pick<Note, "userId">): Promise<Array<Pick<Note, "id" | "title">>> {
  console.time("all");
  console.time("arc.tables");
  const db = await arc.tables();
  console.timeEnd("arc.tables");

  console.time("db.note.query");
  const result = await db.note.query({
    KeyConditionExpression: "pk = :pk",
    ExpressionAttributeValues: { ":pk": userId },
  });
  console.timeEnd("db.note.query");
  console.timeEnd("all");

  return result.Items.map((n: any) => ({
    title: n.title,
    id: skToId(n.sk),
  }));
}

arc.tables timing is about 1.3s db.note.query timing is about 0.9s all timing is about 2.23s

Curious if anyone else can replicate it. I guess I can't rule out something weird with my network. I do have a vpn for work but I tried with it turned off as well.