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

Speed up initialization #143

Closed
JacobEvelyn opened this issue Jun 5, 2016 · 1 comment · Fixed by #144
Closed

Speed up initialization #143

JacobEvelyn opened this issue Jun 5, 2016 · 1 comment · Fixed by #144
Assignees
Milestone

Comments

@JacobEvelyn
Copy link
Owner

It would be nice if we could make friends perform better, as there is a noticeable lag when the friends.md file is large.

@JacobEvelyn JacobEvelyn added this to the 1.0 milestone Jun 5, 2016
@JacobEvelyn JacobEvelyn self-assigned this Jun 5, 2016
@JacobEvelyn JacobEvelyn changed the title Speed up initialization? Speed up initialization Jun 5, 2016
@JacobEvelyn
Copy link
Owner Author

Some profiling revealed that a lot of time was being spent on Chronic.parse while reading activities from the file, when the file format allows us to use Time.parse (which Chronic uses under the hood) in this case.

For ~500 activities, this reduces the time of bundle exec bin/friends list activities from ~2.4 seconds to ~0.7 seconds.

As a note for future optimizations, it seems that processing unnecessary file data is not a significant source of slowdown, as commenting out all file reading and all set_n_activities! calls only brings us down from ~0.7 seconds to ~0.6 seconds (for ~500 activities, ~200 friends, ~5 locations).

JacobEvelyn added a commit that referenced this issue Jun 5, 2016
This commit simplifies and removes redundant and unnecessary
code from `introvert.rb`. Some methods have been removed
entirely, and others have been changed so they're used more
simply (we now call `set_n_activities!` only while reading
the file, instead of as-needed, which adds negligible
overhead for some commands but simplifies the calling and
reduces error).

This change also adds an optimization: in deserializing
Activities we now call `Time.parse` if possible, removing
the need for slower `Chronic.parse` calls when reading the
file (`Chronic` uses `Time.parse` under the hood in these
cases anyway). This reduced the runtime of
`friends list activities` with ~500 activities (and ~200
friends) from ~2.4 seconds down to ~0.7 seconds. (This
optimization resolves #143.)

Lastly, this commit adds a slight change in behavior:
when commands match friend or location names, they now use
those classes' regex methods for matching rather than
matching any substring (so a `--with John` command will
match a "John Deere" as before, but will a `--with oh` will
no longer match "John Deere").
JacobEvelyn added a commit that referenced this issue Jun 5, 2016
This commit simplifies and removes redundant and unnecessary
code from `introvert.rb`. Some methods have been removed
entirely, and others have been changed so they're used more
simply (we now call `set_n_activities!` only while reading
the file, instead of as-needed, which adds negligible
overhead for some commands but simplifies the calling and
reduces error).

This change also adds an optimization: in deserializing
Activities we now call `Time.parse` if possible, removing
the need for slower `Chronic.parse` calls when reading the
file (`Chronic` uses `Time.parse` under the hood in these
cases anyway). This reduced the runtime of
`friends list activities` with ~500 activities (and ~200
friends) from ~2.4 seconds down to ~0.7 seconds. (This
optimization resolves #143.)

Lastly, this commit adds a slight change in behavior:
when commands match friend or location names, they now use
those classes' regex methods for matching rather than
matching any substring (so a `--with John` command will
match a "John Deere" as before, but will a `--with oh` will
no longer match "John Deere").
JacobEvelyn added a commit that referenced this issue Jun 5, 2016
This commit simplifies and removes redundant and unnecessary
code from `introvert.rb`. Some methods have been removed
entirely, and others have been changed so they're used more
simply (we now call `set_n_activities!` only while reading
the file, instead of as-needed, which adds negligible
overhead for some commands but simplifies the calling and
reduces error).

This change also adds an optimization: in deserializing
Activities we now call `Time.parse` if possible, removing
the need for slower `Chronic.parse` calls when reading the
file (`Chronic` uses `Time.parse` under the hood in these
cases anyway). This reduced the runtime of
`friends list activities` with ~500 activities (and ~200
friends) from ~2.4 seconds down to ~0.7 seconds. (This
optimization resolves #143.)

Lastly, this commit adds a slight change in behavior:
when commands match friend or location names, they now use
those classes' regex methods for matching rather than
matching any substring (so a `--with John` command will
match a "John Deere" as before, but will a `--with oh` will
no longer match "John Deere").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant