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

'IdleNotificationDeadline' is deprecated: Use MemoryPressureNotification() #953

Open
cbratschi opened this issue May 11, 2023 · 3 comments

Comments

@cbratschi
Copy link

Getting the following warning with Node.js 20.x:

../node_modules/nan/nan.h:686:39: warning: 'IdleNotificationDeadline' is deprecated: Use MemoryPressureNotification() to influence the GC schedule. [-Wdeprecated-declarations]
    return v8::Isolate::GetCurrent()->IdleNotificationDeadline(
...

This method will be deprecated soon.

https://chromium.googlesource.com/v8/v8/+/refs/heads/main/include/v8-isolate.h#1295

lbeschastny added a commit to lbeschastny/splunk-otel-js that referenced this issue Aug 1, 2023
@vrza
Copy link

vrza commented Nov 2, 2023

While nan's IdleNotification could be changed to use MemoryPressureNotification with newer versions of v8, e.g.

#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 11 ||                      \
  (V8_MAJOR_VERSION == 11 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
  inline bool IdleNotification(int idle_time_in_ms) {
    v8::Isolate::GetCurrent()->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate);
    return true;
  }

It seems to make more sense to deprecate nan's IdleNotification, and perhaps introduce a new shim for MemoryPressureNotification to the nan API.

@kkoopa
Copy link
Collaborator

kkoopa commented Nov 2, 2023 via email

@vrza
Copy link

vrza commented Nov 2, 2023

From reading the v8 API docs, while both IdleNotificationDeadline and MemoryPressureNotification boil down to embedder asking v8 to run GC, the semantics are different.

Concretely the idea behind IdleNotification was for the embedder to notify the engine when they are idle, in order to minimize the chance of GC cycles interrupting actual work. And they would pass an amount of time, a "deadline" for the engine to try and do as much work as possible, and engine would return true if no more GC can be done at that point in time.

On the other hand, the idea behind MemoryPressureNotification is for the embedder to notify the engine that they are running out of memory. Not necessarily when the embedder is idle, this can be called from a separate thread while the isolate is running JS code. The signature is also different, there is no deadline parameter, and no value is returned.

So, while similar, the end user of the API (developer) would likely not just simply replace calls to IdleNotificationDeadline with calls to MemoryPressureNotification without making other changes to their code.

Bartel-C8 added a commit to Bartel-C8/node_pcap that referenced this issue Nov 10, 2023
alphaprinz added a commit to alphaprinz/noobaa-core that referenced this issue Dec 13, 2023
The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
alphaprinz added a commit to alphaprinz/noobaa-core that referenced this issue Dec 19, 2023
The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
alphaprinz added a commit to alphaprinz/noobaa-core that referenced this issue Dec 19, 2023
The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
alphaprinz added a commit to noobaa/noobaa-core that referenced this issue Dec 19, 2023
…e. (#7660)

upgrade to node20. ignore deprecated warnings to make nan compile.

The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
dannyzaken pushed a commit to dannyzaken/noobaa-core that referenced this issue Dec 20, 2023
…e. (noobaa#7660)

upgrade to node20. ignore deprecated warnings to make nan compile.

The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
(cherry picked from commit bafd976)
dannyzaken pushed a commit to dannyzaken/noobaa-core that referenced this issue Dec 20, 2023
…e. (noobaa#7660)

upgrade to node20. ignore deprecated warnings to make nan compile.

The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
(cherry picked from commit bafd976)
Signed-off-by: Danny Zaken <dannyzaken@gmail.com>
liranmauda pushed a commit to liranmauda/noobaa-core that referenced this issue Apr 9, 2024
…e. (noobaa#7660)

upgrade to node20. ignore deprecated warnings to make nan compile.

The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
(cherry picked from commit bafd976)
liranmauda pushed a commit to liranmauda/noobaa-core that referenced this issue Apr 9, 2024
…e. (noobaa#7660)

upgrade to node20. ignore deprecated warnings to make nan compile.

The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
(cherry picked from commit bafd976)
Signed-off-by: liranmauda <liran.mauda@gmail.com>
liranmauda pushed a commit to liranmauda/noobaa-core that referenced this issue Apr 16, 2024
…e. (noobaa#7660)

upgrade to node20. ignore deprecated warnings to make nan compile.

The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
(cherry picked from commit bafd976)
Signed-off-by: liranmauda <liran.mauda@gmail.com>
liranmauda pushed a commit to liranmauda/noobaa-core that referenced this issue Apr 16, 2024
…e. (noobaa#7660)

upgrade to node20. ignore deprecated warnings to make nan compile.

The -Wno-error=deprecated-declarations flag can be removed when
nodejs/nan#953
is resolved

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
(cherry picked from commit bafd976)
Signed-off-by: liranmauda <liran.mauda@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants