close
Skip to content

Startup performance suggestions #65

@borkdude

Description

@borkdude

It currenly takes around 120ms on my Macbook Pro 2019 to load-pod bootleg. Which is pretty good, but maybe there are some ways to improve on it.

(ns mybbscript
  (:require [babashka.pods :as pods]))

(println "loading pod")
(time (pods/load-pod "bootleg")) ;;=> 120ms
(require '[pod.retrogradeorbit.bootleg.enlive :as enlive])

(enlive/at "<p>{{here comes foo}}</p>" [:p]
           (enlive/content "foo")) ;;=> 16ms

These are some possible optimizations:

  • Move describe message to top-level form, making it a compile time constant. The id is not necessary in the reply.
  • Pre-serialize the describe message to bencode at compile time and simply use print + flush to write it to stdout.

The above two strategies only seemed to help a little bit.

  • Since the describe message contains lots of client side code, all of this code is evaluated on startup which likely contributes to a performance penalty. The user doesn't use all of these macros all the time. Maybe it's possible to find a way to keep the describe message lean and only send macro and function code on demand.

Maybe we could defer loading of pod namespace code to the require of that namespace. This would work for sci, but not for Clojure. Maybe that's an OK trade-off to make, since Clojure startup is usually around 1.5 or more anyway?

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