-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
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
Use ciso8601 library to parse datetime faster #32128
Conversation
Oh that's a great speedup! What do you use to generate the call tree? |
I am 👍 on this PR. @pvizeli can you comment on if this pacakge can build on our Alpine images. |
That is just a simple C extension that handles automatically by our wheel infrastructure after this PR is merged. |
@balloob To generate calltree I use cProfile and wrap
Then I need to convert calltree to different format using
And it can be viewed with
|
bd9d4c9
to
8365e43
Compare
Fix lint warning and test. |
Codecov Report
@@ Coverage Diff @@
## dev #32128 +/- ##
==========================================
+ Coverage 94.65% 94.73% +0.07%
==========================================
Files 756 767 +11
Lines 54808 55509 +701
==========================================
+ Hits 51877 52584 +707
+ Misses 2931 2925 -6
Continue to review full report at Codecov.
|
@KapJI is it possible that this also needs to be added to |
Nope, that file is maintained. Re-run |
I already installed with |
that's because as part of the tests we run |
Proposed change
This is calltree of logbook query for all events for the last 7 days (numbers are nanoseconds):

hass is running on pretty fast machine with i7-6700K CPU @ 4.00GHz. And MariaDB is used for storing data.
But that request took insane 22 seconds!
State.from_dict()
took 9s.parse_datetime
took 3.08svalid_entity_id
took 4.6sThis change introduces https://github.com/closeio/ciso8601 which is library to parse datetime in ISO format written in C with very high performance. Exactly in format which is used by hass.
But just in case I left old code as a fallback option. I checked that it was never called on my setup. So it can be removed safely.
With this

parse_datetime
can do the same work in just 0.184s, 16.7x improvement!State.from_dict
now takes 5.45s, 40% improvement there.Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale: