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

Rules are sometimes loaded two times on edit #671

Closed
cribskip opened this issue Mar 17, 2019 · 14 comments · Fixed by #3004
Closed

Rules are sometimes loaded two times on edit #671

cribskip opened this issue Mar 17, 2019 · 14 comments · Fixed by #3004
Labels
automation bug An unexpected problem or unintended behavior of the Core DSL rules Domain-Specific Language rules

Comments

@cribskip
Copy link

cribskip commented Mar 17, 2019

Hi,

when working with complex rules on the raspberry, rule files get compiled two times resulting in noticable performance issues:

2019-03-17 09:38:48.006 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model '99_complex.rules'
2019-03-17 09:39:02.194 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model '99_complex.rules'

As a workaround, I'm thinking of a delay when a model is reloaded. Proper place IMHO could be here:

public boolean addOrRefreshModel(String name, final InputStream originalInputStream) {

Is this correct?
Is this issue noticeable on faster platforms?

Thanks & best regards,
Sascha

@cribskip cribskip changed the title a [Raspberry PI 3] Rules get compiled two times on edit Mar 17, 2019
@wborn wborn added automation DSL rules Domain-Specific Language rules labels Mar 17, 2019
@lolodomo
Copy link
Contributor

lolodomo commented Aug 4, 2019

I see the same thing on my RPI2.
There is probably a configuration setting to increase the time between every check but I don't find it !
I have the feeling we get a second check while the first reloading of the rule file is not yet finished.

@lolodomo
Copy link
Contributor

lolodomo commented Aug 4, 2019

In fact it is not clear at all to me why the refresh is triggered twice.

@5iver
Copy link

5iver commented Aug 4, 2019

Is this possible the samba issue, where the samba server changes file permissions after the write, causing the file to load twice? Would be interesting if you still see the issue when using VS Code with the recently added ssh extension for accessing the files.

@lolodomo
Copy link
Contributor

lolodomo commented Aug 4, 2019

That is true, I am replacing the rule file from a samba share. I will try to copy the file first on the RPI outside the conf folder and then see if the replacement is triggering the two reloads.
Good hint.
Is it possible to setup the watched to ignore the change of file permissions ?

@5iver
Copy link

5iver commented Aug 5, 2019

Is it possible to setup the watched to ignore the change of file permissions ?

I don't know about that. But the samba issue was discussed a few times in the ESH repo.

@cribskip
Copy link
Author

cribskip commented Aug 5, 2019

Happens for me with local vi edit so samba is not the trigger. Somewhere in the code I think I saw a 10 second timeout but can't find it atm.

@lolodomo
Copy link
Contributor

lolodomo commented Aug 5, 2019

On my side I just tried with a command touch and I got only one refresh.
Will try with vi later today.

@lolodomo
Copy link
Contributor

lolodomo commented Aug 5, 2019

  1. If I edit my local rule file, only 1 refresh is triggered.
  2. If I overwrite my local rule file by moving from a file being in local, only 1 refresh is triggered.
  3. If I overwrite my local rule by moving from a file that is on a mounted Samba share, 2 refresh are triggered.
  4. If I overwrite my local rule by copying from a file that is on a mounted Samba share, only 1 refresh is triggered.

Clearly, for me, the problem is relative to the use of a Samba share but I don't understand why I don't have the same result in cases 3 and 4.

@lolodomo
Copy link
Contributor

lolodomo commented Aug 5, 2019

Note that on my RPI2, the observer takes a long time to detect a change.

@cribskip
Copy link
Author

cribskip commented Aug 11, 2019

@lolodomo Did you try with a complex rule file? I've noticed the complexity of the file (f.e. rule count, using persistence) does matter on the behavior.

In my test, using a rule file with 9 rules in 208 lines of code with local vi-edit results in double-refresh of the file.

Maybe your point for the slow observer is part of the problem.

@lolodomo
Copy link
Contributor

I have only one rule file with all my rules. 832 lines.

@J-N-K
Copy link
Member

J-N-K commented Feb 26, 2022

@lolodomo Is this still the case? There have been lots of improvements since 2019 to both, the script file handling and the watch service in general.

@lolodomo
Copy link
Contributor

@lolodomo Is this still the case? There have been lots of improvements since 2019 to both, the script file handling and the watch service in general.

I would be surprised if this is fixed. I will try again.

@J-N-K J-N-K added bug An unexpected problem or unintended behavior of the Core and removed awaiting feedback labels Jun 18, 2022
@J-N-K
Copy link
Member

J-N-K commented Jun 18, 2022

This has been reported again in #3006, so it's still present.

@J-N-K J-N-K changed the title [Raspberry PI 3] Rules get compiled two times on edit Rules are sometimes loaded two times on edit Jun 18, 2022
@wborn wborn linked a pull request Dec 22, 2022 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation bug An unexpected problem or unintended behavior of the Core DSL rules Domain-Specific Language rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants