Skip to content

Instantly share code, notes, and snippets.

@kapilreddy
Last active November 11, 2024 09:05
Show Gist options
  • Save kapilreddy/4280d20ed3be75a919333f2411b174f5 to your computer and use it in GitHub Desktop.
Save kapilreddy/4280d20ed3be75a919333f2411b174f5 to your computer and use it in GitHub Desktop.
RFC - Clojure library opengraph list
{:lib/name "reitit"
:composes-with {"ring" {:purpose "HTTP server"}
"muuntaja" {:purpose "Content negotiation"}}
:supports {:metrics ["prometheus" "dropwizard"]
:logging ["timbre" "log4j"]
:tracing ["opentelemetry" "brave"]}
:performance {:blocking? false ;; Non-blocking by default
:thread-safety :immutable ;; Thread-safe due to immutability
:memory-footprint :medium ;; Route compilation uses memory
:startup-impact :medium ;; Route compilation at start
:hot-path? true ;; In request processing path
:gc-pressure :low}} ;; No temporary objects in hot path
{:lib/name "next.jdbc"
:composes-with {"hikari-cp" {:purpose "Connection pooling"}
"honeysql" {:purpose "SQL generation"}}
:supports {:metrics ["prometheus" "micrometer"]
:logging ["timbre" "log4j" "slf4j"]
:health-checks ["hikari-health"]}
:performance {:blocking? true ;; JDBC is blocking
:thread-safety :connection-based ;; Safe with proper connection handling
:memory-footprint :medium ;; Connection pool memory
:startup-impact :high ;; Pool initialization
:hot-path? true ;; In data access path
:gc-pressure :medium ;; Result set object creation
:pooling {:min-pool 10
:max-pool 100
:timeout "30s"}}}
{:lib/name "muuntaja"
:composes-with {"ring" {:purpose "Content negotiation"}
"jsonista" {:purpose "Fast JSON"}}
:supports {:formats ["json" "transit" "edn"]}
:performance {:blocking? false
:thread-safety :immutable
:memory-footprint :low
:startup-impact :low
:hot-path? true
:gc-pressure :medium ;; Object creation during parsing
:caching? true}} ;; Caches format negotiation
{:lib/name "hikari-cp"
:composes-with {"next.jdbc" {:purpose "Connection pooling"}}
:supports {:metrics ["prometheus" "micrometer"]
:health-checks ["connection-valid"]}
:performance {:blocking? true
:thread-safety :pool-managed
:memory-footprint :high ;; Connection pool memory
:startup-impact :high ;; Pool initialization
:hot-path? true
:gc-pressure :low
:pooling {:min-pool 10
:max-pool 100
:idle-timeout "600s"}}}
{:lib/name "jsonista"
:composes-with {"muuntaja" {:purpose "JSON format"}
"ring" {:purpose "JSON responses"}}
:supports {:formats ["json" "smile"]}
:performance {:blocking? false
:thread-safety :immutable
:memory-footprint :low
:startup-impact :low
:hot-path? true
:gc-pressure :medium ;; Object allocation during parsing
:features {:stream-support true ;; Can handle large streams
:cached-parsers true}}} ;; Uses parser caching
{:lib/name "buddy-auth"
:composes-with {"ring" {:purpose "Authentication"}
"buddy-hashers" {:purpose "Password hashing"}}
:supports {:logging ["timbre" "log4j"]}
:performance {:blocking? false ;; Auth checks are in-memory
:thread-safety :immutable
:memory-footprint :low
:startup-impact :low
:hot-path? true ;; On every authenticated request
:gc-pressure :low}}
{:lib/name "malli"
:composes-with {"reitit" {:purpose "Request validation"}
"next.jdbc" {:purpose "Result validation"}}
:supports {:metrics ["prometheus"]}
:performance {:blocking? false
:thread-safety :immutable
:memory-footprint :medium ;; Schema compilation memory
:startup-impact :medium ;; Schema compilation
:hot-path? true
:gc-pressure :medium ;; Validation object creation
:features {:schema-caching true}}}
{:lib/name "honeysql"
:composes-with {"next.jdbc" {:purpose "SQL generation"}}
:supports {:logging ["timbre" "log4j"]}
:performance {:blocking? false
:thread-safety :immutable
:memory-footprint :low
:startup-impact :low
:hot-path? true
:gc-pressure :low ;; Minimal object creation
:features {:query-caching false}}}
{:lib/name "timbre"
:composes-with {"jsonista" {:purpose "JSON formatting"}}
:supports {:outputs ["console" "file" "syslog"]
:formats ["json" "logfmt" "edn"]}
:performance {:blocking? false ;; Async logging by default
:thread-safety :thread-safe
:memory-footprint :low
:startup-impact :low
:hot-path? false ;; Async processing
:gc-pressure :low
:features {:async true
:buffered true}}}
{:lib/name "hiccup"
:composes-with {"ring" {:purpose "HTML generation"}}
:supports {:logging ["timbre"]}
:performance {:blocking? false
:thread-safety :immutable
:memory-footprint :low
:startup-impact :low
:hot-path? true
:gc-pressure :medium ;; String concatenation
:features {:caching false}}}
;; Performance impact categories
{:blocking? #{:true :false} ;; Does it block threads?
:thread-safety #{:immutable ;; Completely thread-safe
:thread-safe ;; Safe with concurrent access
:connection-based ;; Safe with connection handling
:pool-managed ;; Managed by a pool
:unsafe} ;; Needs external synchronization
:memory-footprint #{:low ;; Minimal heap usage
:medium ;; Moderate heap usage
:high} ;; Significant heap usage
:startup-impact #{:low ;; Quick startup
:medium ;; Some initialization
:high} ;; Significant startup time
:hot-path? #{:true :false} ;; Is it in critical path?
:gc-pressure #{:low ;; Minimal object creation
:medium ;; Some temporary objects
:high} ;; Significant allocation
:features #{:caching ;; Uses caching
:async ;; Async processing
:buffered ;; Buffered operations
:pooling}} ;; Uses resource pooling
;; Examples of performance implications:
;; 1. Request Path:
;;```clojure
;; Ring -> Reitit -> Muuntaja -> Handler -> next.jdbc
;; Key considerations:
;; - Reitit: Non-blocking, low GC
;; - Muuntaja: Some GC pressure during parsing
;; - next.jdbc: Blocking, needs connection pool
;; 2. Template Rendering:
;; ```clojure
;; Handler -> Hiccup -> Ring Response
;; Key considerations:
;; - Hiccup: GC pressure from string concat
;; - All non-blocking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment