[pve-devel] [PATCH installer v2 3/3] proxinstall: expose arc size setting for zfs bootdisks for all products

Maximiliano Sandoval m.sandoval at proxmox.com
Fri Feb 23 16:37:16 CET 2024


Some comments bellow.

Christoph Heiss <c.heiss at proxmox.com> writes:

> For non-PVE products, simply use the ZFS defaults (aka. 50%) and leave
> unset, if the user never touches that setting.
>
> Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
> ---
> ...
> ...
> +
> +    # GTKs SpinButton does not support a placeholder value, unfortunaly. That means we also

There is a typo on unfortunately. What exactly do you mean by a
placeholder value? Like the initial value? If so see comment bellow.

> +    # have to set the value normally for non-PVE products, where the ZFS default should be used,
> +    # in case the user does not explicitly set a value.
> +    # But due to the signal-based nature of GTK, as long as the user never touches the spinbutton,
> +    # `Proxmox::Install::Config::set_zfs_opt('arc_max', ..)` never gets called, thus the default
> +    # value (which is 0 for non-PVE) won't get overwritten and no modprobe file is written.
> +    if ($arc_max > 0) {
>  	$spinbutton_arc_max->set_value($arc_max);
> -	push @$labeled_widgets, ['ARC max size', $spinbutton_arc_max, 'MiB'];
> +    } else {
> +	# .. but we need to display the "real" value to the user
> +	$spinbutton_arc_max->set_value($total_memory * 0.5);
>      }
>
> +    # We need to connect the signal afterwards, to avoid triggering it using ->set_value() above.
>

Alternatively one could init the spin button with the correct values
e.g.

    my $total_memory = Proxmox::Install::RunEnv::get('total_memory');
    my $arc_max = Proxmox::Install::Config::get_zfs_opt('arc_max');
    my $arc_max_value = $total_memory * 0.5;
    $arc_max_value = $arc_max if $arc_max > 0;
    my $arc_max_adjusment = Gtk3::Adjustment->new($arc_max_value, $Proxmox::Install::RunEnv::ZFS_ARC_MIN_SIZE_MIB, $total_memory, 1, 10, 0);
    my $spinbutton_arc_max = Gtk3::SpinButton->new($arc_max_adjusment, 1, 0);
    $spinbutton_arc_max->set_tooltip_text('Maximum ARC size in megabytes');
    $spinbutton_arc_max->signal_connect('value-changed' => sub {
        my $w = shift;
        Proxmox::Install::Config::set_zfs_opt('arc_max', $w->get_value_as_int());
    });

Here the numerical values 1, 10, 0, and 1, 0 come from a quick
inspection of the source for gtk_spin_button_new_with_range and
gtk_spin_button_new (in the docs [1, 2] there is a [src] link next to
the Description header).

[1] https://docs.gtk.org/gtk3/ctor.SpinButton.new.html
[2] https://docs.gtk.org/gtk3/ctor.SpinButton.new_with_range.html

> +    $spinbutton_arc_max->signal_connect('value-changed' => sub {
> +	my $w = shift;
> +	Proxmox::Install::Config::set_zfs_opt('arc_max', $w->get_value_as_int());
> +    });
> +
> +    push @$labeled_widgets, ['ARC max size', $spinbutton_arc_max, 'MiB'];
> +
>      push @$labeled_widgets, ['hdsize', $hdsize_btn, 'GB'];
>      return $create_label_widget_grid->($labeled_widgets);;
>  };


--
Maximiliano




More information about the pve-devel mailing list