Skip to content

perf T4-W1 (speculative): evaluate skipping the cached-session verify round trip — every authed invocation pays ~2.5 s (GET /chip/sync) before doing its actual work #12

Description

@JavaGT

Evidence

On a cached, unexpired session, authenticate always calls verify() (src/auth.mjs:60) = GET /chip/sync (src/auth.mjs:150-157). Measured share on this machine: libby archive (no flags — all bootstrap, no work) median 2596 ms vs libby help 26.1 ms; buildConfig + session load + JWT decode are single-digit ms, so the network verify is essentially the entire delta.

If verify() were skipped (trust the JWT exp locally, let the command's first real API call surface an invalid session), every authed invocation — list, archive --all, auth, borrow, … — would start ~2.5 s sooner on this network.

The tradeoff (why evaluate, not implement)

  • verify() gives the clean "Cached session no longer valid; re-bootstrapping" path (src/auth.mjs:62). Skipping it turns invalid-session detection into a mid-command failure (e.g. after partially archiving), with a messier recovery story.
  • An invalid session would also pay a failed call before re-bootstrap (one extra round trip in the bad case, to save one in the good case).
  • libby auth exists to verify authentication only — it presumably keeps an explicit verify regardless.

Question for evaluation

Measure the real invalid-session frequency and the failure UX both ways; decide whether verify should be dropped, deferred (verify only when the command's first API call fails), or kept. Implementation is explicitly NOT the todo until that call is made.

Related: #10, #11.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions