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

The problem with std.@ #51

Open
ConorOBrien-Foxx opened this issue Sep 15, 2018 · 4 comments
Open

The problem with std.@ #51

ConorOBrien-Foxx opened this issue Sep 15, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@ConorOBrien-Foxx
Copy link
Owner

After trying to identify why the empty program takes ~0.7s to run on my computer, I identified that the initialization of a state instance is the problem:

    def initialize(program, input=STDIN, output=STDOUT)
        @trees = ast(program)
        if @trees.nil?
            exit
        end
        @variables = @@default_variables.dup
        @abstract_references = []
        @locals = [{}]
        @saved = []
        @position = nil
        @in = input
        @out = output
        load_lib "std"
    end

Specifically, the last line load_lib "std". This loads the almost 800 line file std.@, which has a lot of useful functions in it. Most of the file is composed of comments.

I don't know what the particular problem is. Is it tokenizing? Is it node traversal?

This issue serves as a note for myself.

A potential solution is to design a way to compile Attache files....

@ConorOBrien-Foxx ConorOBrien-Foxx added the enhancement New feature or request label Sep 15, 2018
@ConorOBrien-Foxx ConorOBrien-Foxx self-assigned this Sep 15, 2018
@somebody1234
Copy link
Contributor

Compilation is definitely a good idea. re: the performance problem, what does a profiler say

@ConorOBrien-Foxx
Copy link
Owner Author

@somebody1234 I haven't done any formal profiling. any suggestions?

@somebody1234
Copy link
Contributor

somebody1234 commented Nov 16, 2018

Apparently the normal way to do it is ruby-prof (taken directly from repo):

RubyProf.start
# ... code to profile ...
result = RubyProf.stop

# print a flat profile to text
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT)

@somebody1234
Copy link
Contributor

Reduced to ~0.25 seconds, can't reduce any further without significant changes to the lexer (which is still the bottleneck)

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

2 participants