Related to this https://www.drupal.org/project/eu_cookie_compliance/issues/3111617 (Call to a member function getEntityTypeId() on null) I found this big function eu_cookie_compliance_page_attachments() that has all the logic and resources how and when to show the popup. It seemed odd that although whatever the reason for the particular error might be, why was it executed if I haven't seen the popup for a very long time since I accepted it. Every single piece of code seems to be executed. I measured how long it takes on my local machine to load the function and while it was not much, still seemed pointless. In seconds:
0.019018888473511
0.018988847732544
0.015308856964111
0.016623020172119
0.016221046447754
0.016118049621582
0.017706155776978
Bigger issue I found was that at least on my local it seemed to break caching for anon users. When the function is canceled right in the beginning, it went from 400ms html load to 20ms.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | DeepinScreenshot_select-area_20200211091711.png | 26.98 KB | hkirsman |
| #2 | eu_cookie_compliance-skip_load_if_popup_has_been_agreed_or_withdrawn-3111868-2.patch | 1.43 KB | hkirsman |
Comments
Comment #2
hkirsman commentedI'm keeping this patch as minimal as possible, but probably needs more refactoring.
Comment #3
hkirsman commentedComment #4
svenryen commentedCan you give more information on how you measure the resource usage so I can reproduce?
Comment #5
hkirsman commentedIn the beginning of eu_cookie_compliance_page_attachments() I added
$begin = microtime(true);and to end of the same function:
Anonymous full html caching I broke myself with the above code. I guess Drupal is smart enough to see the content changes.
I did some more tests with same logic on AWS t3.medium and t3.small. Calculated the seconds to ms
type: t3.medium, RAM: 4.0 GiB, CPU: 2 vCPUs
6
20
7
7
12
21
type: t3.small, RAM: 2.0 GiB, CPU: 2 vCPUs
23
23
12
25
23
14
Doesn't seem much but 25ms and 100 000 requests make 42 minutes
We would also get win from not adding the resources:

Comment #6
hkirsman commentedComment #7
Pascal- commentedClosing this issue since this is already suggested here:
https://www.drupal.org/project/eu_cookie_compliance/issues/3015612