Skip to content

Delayed loading for lesser-used Core features #387

Open
@chrisrink10

Description

@chrisrink10

As of this writing, startup Basilisp up locally takes just over 4 seconds without a locally cached copy:

$ BASILISP_USE_DEV_LOGGER=true BASILISP_LOGGING_LEVEL=DEBUG BASILISP_DO_NOT_CACHE_NAMESPACES=true basilisp repl
2019-05-06 08:33:46,726 DEBUG [basilisp.lang.runtime.init_ns_var:1269] - Created namespace variable basilisp.core/*ns*
2019-05-06 08:33:46,727 DEBUG [basilisp.importer.find_spec:128] - Found potential Basilisp module 'basilisp.core' in file '/Users/christopher/Projects/basilisp/src/basilisp/core/__init__.lpy'
2019-05-06 08:33:46,727 DEBUG [basilisp.importer.create_module:166] - Creating Basilisp module 'basilisp.core''
2019-05-06 08:33:46,727 DEBUG [basilisp.lang.runtime.set_current_ns:1289] - Setting basilisp.core/*ns* to basilisp.core
2019-05-06 08:33:46,727 DEBUG [basilisp.importer._exec_module:227] - Reading and compiling Basilisp module 'basilisp.core'
2019-05-06 08:33:51,098 DEBUG [basilisp.importer.<lambda>:216] - Loaded Basilisp module 'basilisp.core' in 4370.760615ms
2019-05-06 08:33:51,109 DEBUG [basilisp.importer.find_spec:128] - Found potential Basilisp module 'basilisp.repl' in file '/Users/christopher/Projects/basilisp/src/basilisp/repl.lpy'
2019-05-06 08:33:51,109 DEBUG [basilisp.importer.create_module:166] - Creating Basilisp module 'basilisp.repl''
2019-05-06 08:33:51,110 DEBUG [basilisp.lang.runtime.set_current_ns:1289] - Setting basilisp.core/*ns* to basilisp.repl
2019-05-06 08:33:51,110 DEBUG [basilisp.importer._exec_module:227] - Reading and compiling Basilisp module 'basilisp.repl'
2019-05-06 08:33:51,190 DEBUG [basilisp.importer.<lambda>:216] - Loaded Basilisp module 'basilisp.repl' in 80.048895ms
2019-05-06 08:33:51,191 DEBUG [basilisp.lang.compiler.generator.__init__:200] - Compiler option warn_on_shadowed_name=False
2019-05-06 08:33:51,191 DEBUG [basilisp.lang.compiler.generator.__init__:200] - Compiler option warn_on_var_indirection=True
2019-05-06 08:33:51,191 DEBUG [basilisp.lang.compiler.generator.__init__:200] - Compiler option warn_on_shadowed_var=False
2019-05-06 08:33:51,191 DEBUG [basilisp.lang.compiler.generator.__init__:200] - Compiler option use_var_indirection=False
2019-05-06 08:33:51,191 DEBUG [basilisp.lang.runtime.set_current_ns:1289] - Setting basilisp.core/*ns* to user

I was thinking about some options to help reduce that load time for the average use case. For a lot of users, they may not use some of the more esoteric bits of basilisp.core, so it may make sense to potentially JIT load them.

We could potentially def all the Vars with a JIT-loader that will fetch and load the contents of a separate file only when that def is called and then swap out the Vars with the "real" version. I think this would probably be doable on the first use of a few of these features, but obviously we will need to make sure that they are features which exist largely in isolation in basilisp.core, because if they are called later from within core they will reintroduce the loading time (and add to it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    component:compilerIssue pertaining to compilerissue-type:enhancementNew feature or requestlangIssue pertaining to Basilisp language modulesperformanceIssue pertaining to performance

    Type

    No type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions