Skip to content

Optimize Linux implementation when no env vars were touched by the user #42

@adamsitnik

Description

@adamsitnik

The Linux implementation allocates an array of native utf8 strings that are null terminated when mapping managed env vars to native env vars:

UnixHelpers.AllocNullTerminatedArray(envp, ref envpPtr);

We should detect the case when ProcessStartOptions.HasEnvironmentBeenAccessed returns false and do the following:

  • don't access ProcessStartOptions.Environment to avoid allocations
  • don't allocate the native memory here:
    UnixHelpers.AllocNullTerminatedArray(envp, ref envpPtr);
  • just pass null to the native layer and make it pass environ directly to execve.

By doing that we are going to avoid needles utf8->unicode->utf8 converstion for all the env vars in case where user has not modified the env vars and the process should simply derive the env vars from parent.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions