Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve require-time latency #50

Closed
countvajhula opened this issue Jul 9, 2022 · 1 comment
Closed

Improve require-time latency #50

countvajhula opened this issue Jul 9, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@countvajhula
Copy link
Collaborator

countvajhula commented Jul 9, 2022

@sarna reported on Discord that startup time is on the order of hundreds of milliseconds. They suggested this way to test it:

base.rkt:

#lang racket/base

(displayln "hey!")

qi.rkt:

#lang racket/base

(require qi)

(displayln "hey!")

After running raco setup to ensure that Qi is compiled, the results are:

$ time racket base.rkt
hey!

real	0m0.270s
user	0m0.134s
sys	0m0.085s

$ time racket qi.rkt
hey!

real	0m0.812s
user	0m0.661s
sys	0m0.141s

Ways in which users could improve it

Suggestions from @Bogdanp:
"[There's not much you can do] apart from ensuring those [...] are compiled (by running raco setup). lazy-require may help if some of the work can be deferred, and raco demod might help, too, depending on how often you run the code (raco demod takes a while to run and it doesn't work in all cases)."

"If this is for a CLI tool, then I'd recommend raco demod + raco exe
raco demod foo.rkt && raco exe -o foo foo_rkt_merged.zo"

Ways in which the library could improve it

@jackfirth suggests:
"using #lang racket/base instead of #lang racket helps
but options are limited
it's a problem that really needs some VM work to solve"

Qi already does use #lang racket/base in all modules (except in test modules, but I don't think that would matter here) but worth double checking. Also, once the core language is available (#49 ), Qi should be able to provide something analogous to racket/base, like qi/base, with the option to include additional functionality via separate requires just like in Racket.

Bogdan suggests:
"I think the best library authors can do is depend on less code and write macros that generate minimal amounts of code (i.e. write helper functions and have macros expand to calls to those functions instead of generating the same code over and over). Depending on a subset of a module won't help, but restructuring modules such that less code is loaded overall can."

This can definitely be explored. I didn't really consider this kind of thing before so it's likely there can be some quick gains here.

@countvajhula countvajhula added the enhancement New feature or request label Jul 9, 2022
benknoble added a commit to benknoble/qi that referenced this issue Jul 10, 2022
The adjutor and mischief libraries are large (subjectively), and may
contribute to long loading times as in drym-org#50. They are each only used for
a single form, each of which has an obvious implementation.

By providing the implementation ourselves, we avoid loading the whole
library (and depending on it).
@benknoble benknoble mentioned this issue Jul 10, 2022
1 task
benknoble added a commit that referenced this issue Jul 12, 2022
The adjutor and mischief libraries are large (subjectively), and may
contribute to long loading times as in #50. They are each only used for
a single form, each of which has an obvious implementation.

By providing the implementation ourselves, we avoid loading the whole
library (and depending on it).
@countvajhula
Copy link
Collaborator Author

Fixed by #51 , which resulted in a significant improvement in require-time latency. There are still other things to try in the suggestions above which could be explored down the line, but for now I think this issue can be considered solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant