This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (1)
- # babashka (6)
- # beginners (31)
- # calva (23)
- # cider (38)
- # clj-kondo (98)
- # clj-new (4)
- # cljs-dev (3)
- # clojure (56)
- # clojure-australia (2)
- # clojure-europe (14)
- # clojure-italy (1)
- # clojure-nl (2)
- # clojure-spec (17)
- # clojure-uk (27)
- # clojurescript (45)
- # code-reviews (1)
- # core-async (26)
- # core-logic (10)
- # cursive (11)
- # data-science (9)
- # datomic (7)
- # devcards (1)
- # emacs (4)
- # etaoin (2)
- # fulcro (14)
- # jobs (1)
- # kaocha (1)
- # leiningen (50)
- # malli (3)
- # parinfer (1)
- # pathom (7)
- # reitit (4)
- # remote-jobs (1)
- # reveal (45)
- # shadow-cljs (59)
- # sql (97)
- # tools-deps (1)
- # uncomplicate (4)
- # vim (18)
I'm playing around with performance tuning and I don't know how to move forward. I'm load testing a script and it has a sensible min and mean. I don't really mind a high max because accidents happen. What I don't know how to deal with is a very high standard deviation. I'm seeing SD two to three times the mean, which considering these numbers are representing the script run time, doesn't sound good. How do I find out what part(s) of the code are prone to underperform in statistically significant ways like that? Clojure/JVM.
You can use a profiler, and/or appropriate Java APIs, to determine whether some of that variation is due to GC being run in some executions but not others.
The YourKit Java profiler can show you in real time when GCs are occurring. I'm not sure what you mean by "victims".
There are Java API calls you can make to query how much total GC time has been spent up to that point in time. You could call that at times in your program's execution that you care to know whether GC occurred between those two times, and subtract the results.
This is a namespace I created for a personal project that contains a macro
time that collects elapsed time and elapsed GC time before and after evaluating some expression: https://github.com/jafingerhut/cljol/blob/master/src/clj/cljol/performance.clj
I'm trying to figure out if the variation I see is because of GC or thread competition. Is there a way to see what calls get "paused" for GC?
Depending upon which GC algorithm you are using, it might be no calls, e.g. some GCs run in separate threads, without pausing any of your computation threads.
is there a syntax for explicitly prefixing a symbol with the current ns?
for example. I have a ns named
genus and I alias it to
gns when I require it elsewhere. So outside of
genus the symbols get prefixed as
gns/foo. However, I would love sometimes to also use
gns/foo INSIDE the file which defines the
genus namespace. especially in rare cases when the project has two different functions of the same name but different namespaces.
That would help when i'm navigating with
M-. to avoid confusion.
clj Clojure 1.10.1 user=> (require '[clojure.set :as set]) nil user=> [`set/bob `bob] [clojure.set/bob user/bob] user=>
but then you talked about aliases so not sure which you want but this seems to be both
You can use something like
(alias 'alias-for-myself 'the.current.full.ns.name) after the
ns form. At least that seemed to work with a quick REPL test -- I did not try it within a multi-file project. The doc string for
alias does not say that it supports creating an alias to the current namespace, but it seems to work.
Regarding the case when the current namespace has a function named
foo, and another namespace has a function named
foo, I think one workable solution used by some is never to use
(:use ...), only
(:require [full.ns :as alias]), so that whenever you want to call
foo in another namespace, it must have either the full namespace or an alias qualifying it.
if there is a low level function like
*, such as when doing low level with with spec. then there are 3
* 's floating around. the normal
spec/** , and
my-local/* ... I'd really like to prefix all three of them within my code. That way when I popping around the different files with the editor, every time i see
*, I know exactly which one it is. And this is especially true in the file which defines
I'll try out the alias trick. is what you're claiming, @U0CMVHBL2, than whenever the ns is required elsewhere, then the alias will have no effect in the other ns?
One small problem I've discovered with this approach is that the alias doesn't allow me to define a function using the / syntax.
the syntax checker with defn demands that the name be a simple symbol.
(defn rte/match "docstring" [a b c] ...)
Syntax error macroexpanding clojure.core/defn at (rte_construct.clj:401:1). rte/expand - failed: simple-symbol? at: [:fn-name] spec: :clojure.core.specs.alpha/defn-args
I wonder whether this is an over-ambitious syntax check, or wether it is really fundamentally important to prevent defn from working on qualified symbols. I've noticed that
def doesn't have any such restriction. So I suppose I could use
(def prefix/name ... (fn [a b c] ...)).
I can live with the restriction, but just wondering whether there's really a good reason?
If you allow the alias or namespace qualifier for
defn, but only allow it to be used for the current namespace, that is a strange thing to allow. If you allow it for other namespaces, then the idea of the "current namespace" is practically moot.
@U0CMVHBL2 i really think it is just an overzealous syntax check. that's my gut feel.
What is the behavior you would expect if a namespace qualifier were permitted?
One implementation detail: defn is a macro in Clojure, and thus can have specs implemented for it do implement these kinds of checks. def is not a macro, and so I believe cannot have Clojure specs implemented for this kind of checking, only checks implemented in the Java implementation of the Clojure compiler. The spec restrictions were added in Clojure 1.9, I believe, about 2 years ago, and were I suspect pretty carefully reviewed by the three main Clojure core developers (Rich, Stu, Alex) before release. (That is my guess -- I wasn't there writing specs with them).
But best way to find out if defn's check is more restrictive than intended is probably to ask in #clojure-dev or #clojure-spec
Hello 🙂 I have a web page I wish to download, but it has a DOM-manipulating button for “give me all of the page” I need to “click” via code (clojure, not clojurescript), and I’m not sure how to do that best. Any suggestions?