### Godot version

Godot 4.1-beta2

### System information

Manjaro Gnome, Intel Core i7-11800H

### Issue description

On a relatively modern laptop (Intel Core i7-11800H), in a scene with many scripted nodes (total of 900+ with roughly half of them scripted), adding or duplicating a node freezes the editor for several seconds. Godot 4.0.2 handles such scenes much better!

Here is a flame graph captured while repeatedly duplicating simple Marker2D nodes with Ctrl+D in a complicated scene:
![Screenshot from 2023-06-15 23-54-38](https://github.com/godotengine/godot/assets/2766569/d0019f17-9b82-4a26-9b47-71fa7a3bef3a)

Performance data file to use with hotspot v1.4.1 (relevant data starts at the 75-second mark and lasts about 20+ seconds):
[perf.data.perfparser.zip](https://github.com/godotengine/godot/files/11763700/perf.data.perfparser.zip)



### Steps to reproduce

1) Add 1000 nodes with a script attached.
2) Duplicate a node and witness lags.

Also affects scrolling the scene tree dock.

### Minimal reproduction project

[add_node_lags_repro.zip](https://github.com/godotengine/godot/files/11763731/add_node_lags_repro.zip)

main_editor_buttons[EDITOR_SCRIPT]->set_visible(true);
		if (AssetLibraryEditorPlugin::is_available()) {
			main_editor_buttons[EDITOR_ASSETLIB]->set_visible(true);
		}
	}
	_update_dock_slots_visibility();
}
void EditorNode::_bind_methods() {
	ClassDB::bind_method("edit_current", &EditorNode::edit_current);
	ClassDB::bind_method("edit_node", &EditorNode::edit_node);
	ClassDB::bind_method(D_METHOD("push_item", "object", "property", "inspector_only"), &EditorNode::push_item, DEFVAL(""), DEFVAL(false));
	ClassDB::bind_method("set_edited_scene", &EditorNode::set_edited_scene);
	ClassDB::bind_method("open_request", &EditorNode::open_request);
	ClassDB::bind_method("edit_foreign_resource", &EditorNode::edit_foreign_resource);
	ClassDB::bind_method("is_resource_read_only", &EditorNode::is_resource_read_only);
	ClassDB::bind_method("stop_child_process", &EditorNode::stop_child_process);
	ClassDB::bind_method("set_current_scene", &EditorNode::set_current_scene);
	ClassDB::bind_method("_thumbnail_done", &EditorNode::_thumbnail_done);
	ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state);
	ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes);
	ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);
	ADD_SIGNAL(MethodInfo("request_help_search"));
	ADD_SIGNAL(MethodInfo("script_add_function_request", PropertyInfo(Variant::OBJECT, "obj"), PropertyInfo(Variant::STRING, "function"), PropertyInfo(Variant::PACKED_STRING_ARRAY, "args")));
	ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "obj")));
	ADD_SIGNAL(MethodInfo("scene_saved", PropertyInfo(Variant::STRING, "path")));
	ADD_SIGNAL(MethodInfo("project_settings_changed"));
	ADD_SIGNAL(MethodInfo("scene_changed"));
	ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "path")));
}
static Node *_resource_get_edited_scene() {