This is an archive of the discontinued LLVM Phabricator instance.

Introduce `EnvArray` data structure.
AbandonedPublic

Authored by delcypher on Apr 13 2020, 1:22 PM.

Details

Summary

It is a convenient data structure for operating on environment-variable
like arrays. The type takes template parameters that control the amount
of statically allocated storage the type has. The type uses this storage
in preference to performing heap allocations and has options to avoid
performing heap allocations altogether when performing insertions.

This design was chosen because it will be used in an environment that
may be memory constrained (just before launching a symbolizer process
where a out-of-memory situation may have ocurred).

Several unit tests are included but the type is not currently used
in any runtimes.

Diff Detail

Event Timeline

delcypher created this revision.Apr 13 2020, 1:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2020, 1:22 PM
Herald added subscribers: Restricted Project, dexonsmith, mgorny. · View Herald Transcript

Can we see patches where it's going to be used?
Can you show how this with D78050 simplify sanitizer?

Can we see patches where it's going to be used?
Can you show how this with D78050 simplify sanitizer?

Oh, I see some in the stack.

delcypher updated this revision to Diff 257567.Apr 14 2020, 5:21 PM

Adapt to ArrayRef<> -> MutableArrayRef<> change.

To my taste it's too complicated for task it's going to solve.

compiler-rt/lib/sanitizer_common/sanitizer_env_array.h
53

I would prefer if we avoid parameters which can be avoided.
How user should decide which size to use?

106

It can be much simpler without
"bool shallow_copy, bool allow_heap_allocations, bool overwrite"

144

As I understand the goal of the class to manage copy of env variables.
However public interface expose to much details about internal storage.
Could you please limit public interface as much as possible?

I would recommend to keep the bare minimum you need right now, and remove all stuff added for hypothetical future.

I would recommend to keep the bare minimum you need right now, and remove all stuff added for hypothetical future.

Thanks for the initial feedback. Yes it probably is too complicated.

I've actually come with a much simpler solution to the problem I'm trying to solve so for now I am going to abandon these changes. I'll resurrect them if my solution turns out to be insufficient.

delcypher abandoned this revision.Apr 15 2020, 11:52 AM