https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • w

    wesbos

    04/27/2023, 3:36 PM
    yeah I could not find any helpful guides on this
  • k

    kian

    04/27/2023, 3:37 PM
    there's a draft PR to update paid startup time to 400ms but I have no idea when that'll actually land (if ever)
  • j

    James

    04/27/2023, 3:37 PM
    Agreed. Wall time vs CPU time is extremely confusing, and only made worse when you introduce billing metrics like GB-s.
  • o

    Ottomated

    04/27/2023, 3:38 PM
    ping me if you figure this out :)
  • h

    HardAtWork

    04/27/2023, 3:42 PM
    Sounds about right
  • w

    wesbos

    04/27/2023, 3:45 PM
    Still getting the same error. This is doing it all on request, right?
    Copy code
    ts
    import { BskyAgent } from '@atproto/api';
    
    export interface Env {
      BSKY_USERNAME: string;
      BSKY_PASS: string;
    }
    
    async function login() {
      const agent = new BskyAgent({
        service: 'https://bsky.social'
      });
      await agent.login({
        identifier: process.env.BSKY_USERNAME as string,
        password: process.env.BSKY_PASS as string,
      })
      return agent;
    }
    
    
    export default {
        async fetch(
            request: Request,
            env: Env,
            ctx: ExecutionContext
        ): Promise<Response> {
        // 1. Login
        const agent = await login();
        return new Response("Hello World!");
        },
    };
  • j

    James

    04/27/2023, 3:47 PM
    Yep looks like it. I don't see anything obviously slow in the global scope there, unless
    @atproto/api
    is just so large that parsing it alone is taking that long 😦
  • w

    wesbos

    04/27/2023, 3:47 PM
    From my timing it's not the require, its the creation of BskyAgent() that is taking ~100ms on node.js
  • j

    James

    04/27/2023, 3:48 PM
    Does
    new BskyAgent()
    actually do any web reqs? Or are you seeing ~100ms of pure CPU time?
  • k

    kian

    04/27/2023, 3:48 PM
    Wrangler maps the
    Data
    type to
    buffer
    , which isn't anything to do with
    esbuild
    and is uploaded with your Worker as a
    application/octet-stream
    file
  • k

    kian

    04/27/2023, 3:48 PM
    Copy code
    js
    // This is a combination of an esbuild plugin and a mutable array
    // that we use to collect module references from source code.
    // There will be modules that _shouldn't_ be inlined directly into
    // the bundle. (eg. wasm modules, some text files, etc). We can include
    // those files as modules in the multi part worker form upload. This
    // plugin+array is used to collect references to these modules, reference
    // them correctly in the bundle, and add them to the form upload.
  • w

    wesbos

    04/27/2023, 3:48 PM
    no requests as far as I can see - I think it does lots of encoding/decoding
  • j

    James

    04/27/2023, 3:49 PM
    Oof, it may just be that it's taking that long to parse then 😦
  • w

    wesbos

    04/27/2023, 3:49 PM
    seems crazy long
  • j

    James

    04/27/2023, 3:50 PM
    I'd throw up a test and try and repro but I don't have bluesky access right now unfortunately
  • j

    James

    04/27/2023, 3:50 PM
    Your code above looks totally fine on the surface
  • w

    wesbos

    04/27/2023, 3:50 PM
    doesnt even need bluesky - its just a javascript class that is taking 100ms haha
  • w

    wesbos

    04/27/2023, 3:51 PM
    Copy code
    ts
    export default {
        async fetch(
            request: Request,
            env: Env,
            ctx: ExecutionContext
        ): Promise<Response> {
        // 1. Login
        const agent = new BskyAgent({
          service: 'https://bsky.social'
        });
        return new Response("Hello World!");
        },
    };
  • w

    wesbos

    04/27/2023, 3:52 PM
    this code - no await, just a variable that makes 100ms 😐
  • j

    James

    04/27/2023, 3:52 PM
    Yep I can reproduce
  • j

    James

    04/27/2023, 3:53 PM
    This library is just... slow to parse, dang. You could request an increase via https://forms.gle/ukpeZVLWLnKeixDu7 but no real timeline on that
  • j

    James

    04/27/2023, 3:53 PM
    Like @kian mentioned, there's an increase coming to 400ms soon, but no specific ETA there either
  • t

    Tom Sherman

    04/27/2023, 3:53 PM
    > This library is just... slow to parse have you inspected the build output? maybe some stuff could be treeshaken out
  • j

    James

    04/27/2023, 3:54 PM
    not specifically, no
  • t

    Tom Sherman

    04/27/2023, 3:54 PM
    poking around the code it doesn't look very big
  • w

    wesbos

    04/27/2023, 3:54 PM
    Good point. Maybe I can try treeshake it
  • t

    Tom Sherman

    04/27/2023, 3:55 PM
    ok i changed my mind, there's a lot of code haha https://github.com/bluesky-social/atproto/blob/main/packages/api/src/client/index.ts
  • k

    kian

    04/27/2023, 3:55 PM
    Add
    --minify
    to your publish
  • k

    kian

    04/27/2023, 3:55 PM
    That'll go from 469.45 KiB to 223.94 KiB (the gzip difference is only 67.82 KiB to 52.52 KiB)
  • k

    kian

    04/27/2023, 3:55 PM
    but esbuild will rip out some unused stuff
1...242124222423...2509Latest