Commit Graph

350 Commits (60adc098da2d3026280bd0caa10915d6c8e6e14f)

Author SHA1 Message Date
lumberyard-employee-dm 60adc098da
Fixed implicit conversion to bool in AZStd::to_string. (#7755)
This specifically implies to the value returning to_string overloads

Added a range based StringFunc::Join overload.

Reduced the number of AZStd::to_string calls in the TranslationKey
operator<< function.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
Tommy Walton 7de6bc5b23
Add RoundUpToMultiple and DivideAndRoundUp functions to MathUtils.h (#6989)
* Add RoundUpToMultiple and DivideAndRoundUp functions to MathUtils.h

Signed-off-by: Tommy Walton <waltont@amazon.com>

* Rename DivideByMultiple2 back to DivideByMultiple, now that I've confirmed it's not in use in the codebase. RHI::DivideByMultiple can be fully deprecated in favor of AZ::DivideAndRoundUp at a later date, once the deprecation strategy has been finalized.

Signed-off-by: Tommy Walton <waltont@amazon.com>

* Update based on PR feedback

Signed-off-by: Tommy Walton <waltont@amazon.com>

* Switched from std::numeric_limits to AZStd::numeric_limits and updated the header to indicate it works for non-power of two alignments, but that SizeAlignUp is more efficient if the alignment is a power of 2

Signed-off-by: Tommy Walton <waltont@amazon.com>

* Added missing arguments to the assert, and a missing namespace and include that failed to compile on non-unity builds

Signed-off-by: Tommy Walton <waltont@amazon.com>
4 years ago
puvvadar 7dccb15fb7
Merge pull request #7609 from aws-lumberyard-dev/math_string_converters
[Impactful Change] Consolidate to_string implementations for math classes and add bool to_string
4 years ago
Nicholas Van Sickle 26566a06d2
Merge pull request #7565 from aws-lumberyard-dev/nvsickle/DomPrefixTree
Add DomPrefixTree, a DOM path => value lookup structure
4 years ago
Nicholas Van Sickle de8b1496f0 Update DomPrefixTree range ctor with better validation
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle f60a24e07d Add support for Range-based DomPrefixTree construction, fix initializer_list
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Ronald Koppers f2378fc8d8
Merge pull request #7561 from aws-lumberyard-dev/ConfigurableStack
Improved the way the Settings Registry can handle stacks/arrays.
4 years ago
puvvadar a2d86a9fa4
Merge branch 'development' into math_string_converters 4 years ago
Nicholas Van Sickle f934984ffe Address review feedback:
- Use `unordred_map` (speed is about the same but providing a hash is slightly nicer than operator<)
- Do better arg forwarding where applicable
- Swap EXPECT_ test ordering

Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
AMZN-koppersr 9bd487e3bd Minor fixes to the configurable stack based on provided feedback.
Signed-off-by: AMZN-koppersr <82230785+AMZN-koppersr@users.noreply.github.com>
4 years ago
Nicholas Van Sickle 0459aae295 Merge remote-tracking branch 'upstream/development' into nvsickle/DomPrefixTree 4 years ago
Chris Burel 377da0ed0c Ignore unused benchmark state variables
Signed-off-by: Chris Burel <burelc@amazon.com>
4 years ago
Chris Burel 0b317ee0f5
Merge pull request #7566 from aws-lumberyard-dev/fixClangWindowsBuild
Fix clang windows build
4 years ago
puvvadar 35406e27e1
Merge branch 'development' into math_string_converters 4 years ago
lumberyard-employee-dm 6f52fcb9f0
Various Benchmark Fixes for AzCore (#7611)
Fixed crash in Allocators Benchmark multithreaded test due to the HPHA schema not having proper multithread protection around the `mFreeTree` member in `tree_get_unused_memory` function.
The `mFreeTree intrusive set is able to modified on multiple threads.

Replaced the custom intrusive_list implementation n HPHA schema with AZStd::intrusive_list

Added a `ScopedAllocatorBenchmarkEnvironment` class to provide an RAI mechanism for initializing the SystemAllocator in Benchmark Test

Rermoved the `AzCoreBenchmarkEnvironment` in lieu of the `ScopedAllocatorBenchmarkEnvironment` class

Fixed assert when running Allocator Benchmarks in debug due to mismatch PauseTiming/ResumeTiming in Allocator Benchmark Fixtures

Added `ScopedRegisterBenchmarkEnvironment` RAII class to provide lifetime guarantees on BenchmarkEnvironments registered via the `AZ_UNIT_TEST_HOOK`

Initialized the intrusive_multiset_node members to nullptr in all build configurations instead of only debug as the cost negligible and it is useful for debugging.

fixes LYN-10210

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
puvvadar e481f6bfcf Fix math string unit test failures
Signed-off-by: puvvadar <puvvadar@amazon.com>
4 years ago
puvvadar 4e6bd3d25c Consolidate various to_string implementations for math classes
Signed-off-by: puvvadar <puvvadar@amazon.com>
4 years ago
lumberyard-employee-dm d7ee248df5
Range adaptor support (#7388)
* Updated the SFINAE checks in concepts.h and range.h

To use conjunction and disjunction for short-circuiting behavior.

Replaced AZStd::optional implementation with std::optional alias

Added range adaptor support and the following views: ref_view,
owning_view

Added bitwise or(|) overload for chaining range adaptor closures together

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding indirectly invocable concepts.

These concepts are used to determine whether a callable can be invoked
with a dereferenced iterator instance.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Add implementation of range relational function objects

Add implementation of range min max functions which uses the range
relation function objects(ranges::less, ranges::equal_to, etc...)

This is needed to implement ranges::zip_view

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding interface for zip_view which compiles successfully

The implementation for the zip view functions still need to be filled.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding function definitions for zip_view classes.

Adding empty header of subrange.h for the ranges::subrange class

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding additional view implementations.

The following range and view classes have been added: empty_view,
single_view and subrange.

Moved the AZ_NO_UNIQUE_ADDRESS macro to PlatformDef.h to allow other
code to specify the [[no_unique_address]] attribute.

Added additional test for view structures.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding missing includes for non-unity builds

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Workaround for NDK21 clang 9.0.9 compile issue.

The AZStd::ranges::zip_view::iterator::iter_swap friend function is in the
AZStd::ranges namespace, while the customization point object of
`AZStd::ranges::customization_point_object::iter_swap` is in the regular
namespace of `AZStd::ranges` and the inline namespace of
`customization_point`.

This issue is fixed in NDK23, but as Jenkins uses NDK21 at the time, the
entire zip_view implementation has moved to inline namespace of
`zip_view_internal`

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added iterator algorithm requiremetn concepts

Fixed the ambiguity in the ranges::iter_swap exchange overload to
exclude itself as a candidate if the iterator reference types are
swappable with each other.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding type alias for borrowed_subrange_t

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed convertible to ref_view check in the ranges::all
customization_point

Updated SFINAE detection of whether AZStd::to_address is invocable

Moved the

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed private variable access in ranges::subrange get specialization.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Removing ranges::view constraint from the ranges::views::single
customization_point.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding C++23 range overload for string_view.

It is detailed in the [C++draft strings](https://eel.is/c++draft/strings#lib:basic_string_view,constructor____) section

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding implementations of ranges, find, search, mismatch and equal
functions.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding implementation of ranges split_view along with test.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding const overloads to SceneAPI ProxyPointer container

The Proxy Pointer class operator* and operator-> was unable to be
invoked with a const instance before. Now it returns a const view of the
pointer it contains.
This allows it to be invoked in `AZStd::to_address` as part of an SINAE
context for the contiguous_iterator concept

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Refactored the to_address implementation to better work with SFINAE.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding general non-unity build fixes

This is unrelated to the RangeAdaptor changes.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Allow range algorithms to be used with rvalue ranges

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Workaround MSVC Internal Compiler erroy by removing enable_if
condition in the operator bool of the view_interface class.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Corrected the non_propagating_cache helper class to have public
functions

Fixed the order of creating the perfect forwarding call wrapper for an
outer closure around another closure.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Specialized the borrowed_range and view concepts

For the AZ PathView class, since it is a immutable view around a path.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Removed inline namespace around the zip_view class.

It was needed to workaround a clang 10 or below issue where a friend
function in a namespace and a variable within underneath an inline
namespace within the function namespace would cause an improper symbol
redefinition.

The workaround is to create a placeholder namespace containing the
inline namespace and then bring that placeholder namespace into the
parent scope.

https://bugs.llvm.org/show_bug.cgi?id=37556

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding implementation of the elemetns_view and join_view classes

It is up to date with the standard as of the current draft:
https://eel.is/c++draft/ranges.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Separated definitions of concepts out of concepts.h

This allows the ranges::iter_swap and ranges::swap customization point to be moved
outside of the concepts folder and into the ranges folder.

The concepts.h header previously had to define those objects to avoid
circular dependencies.

Added the work around for ranges::iter_swap and ranges::iter_move
customization_point causing an improper symbol redefinition in clang 10
or below: https://bugs.llvm.org/show_bug.cgi?id=37556

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Alias more std:: names into the AZStd namespace.

Removed our custom implementation of toaddress.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding more range view test.

The join_view and elements_view classes now have UnitTest.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Adding deduction guides for AZStd associative containers

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Moved zip_view::sentinel iterator accessor function to zip_view.inl

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed variable shadowing issues with clang 12+

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
Chris Burel d4eb310950 Mark unused variables as unused
Signed-off-by: Chris Burel <burelc@amazon.com>
4 years ago
Chris Burel b79d5faa16 Remove unused captures
Signed-off-by: Chris Burel <burelc@amazon.com>
4 years ago
Chris Burel ddb66786dc Remove unused variable
Signed-off-by: Chris Burel <burelc@amazon.com>
4 years ago
Chris Burel 664403c5de Mark benchmark state variables in for loops as unused in benchmarks
Signed-off-by: Chris Burel <burelc@amazon.com>
4 years ago
Nicholas Van Sickle 27c6388c3c Add DomPrefixTree, a DOM path => value lookup structure
This is Document Property Editor work I've pulled out as I needed it in a few places, and the API may be generally useful. Real-world performance measurements will need to be done, if we have path lookup based bottlenecks we can consider adopting a contiguous memory approach with a sorted vector.

Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
AMZN-koppersr d00436e26a Improved the way the Settings Registry can handle stacks/arrays.
The ConfigurableStack makes configuring stacks and arrays through the Settings Registry easier than using direct serialization to a container like AZStd::vector. It does this by using JSON Objects rather than JSON arrays, although arrays are supported for backwards compatibility. Two key words were added:
    - $stack_before : Insert the new entry before the referenced entry. Referencing is done by name.
    - $stack_after  : Insert the new entry after the referenced entry. Referencing is done by name.
to allow inserting new entries at specific locations. An example of a .setreg file at updates existing settings would be:
// Original settings
{
    "Settings in a stack":
    {
        "AnOriginalEntry":
        {
            "MyValue": "hello",
            "ExampleValue": 84
        },
        "TheSecondEntry":
        {
            "MyValue": "world"
        }
    }
}

// Customized settings.
{
    "Settings in a stack":
    {
        // Add a new entry before "AnOriginalEntry" in the original document.
        "NewEntry":
        {
            "$stack_before": "AnOriginalEntry",
            "MyValue": 42
        },
        // Add a second entry after "AnOriginalEntry" in the original document.
        "SecondNewEntry":
        {
            "$stack_after": "AnOriginalEntry",
            "MyValue": "FortyTwo".
        },
        // Update a value in "AnOriginalEntry".
        "AnOriginalEntry":
        {
            "ExampleValue": 42
        },
        // Delete the "TheSecondEntry" from the settings.
        "TheSecondEntry" : null,
    }
}

The ConfigurableStack uses an AZStd::shared_ptr to store the values. This supports settings up a base class and specifying derived classes in the settings, but requires that the base and derived classes all have a memory allocator associated with them (i.e. by using the "AZ_CLASS_ALLOCATOR" macro) and that the relation of the classes is reflected. Loading a ConfigurableStack can be done using the GetObject call on the SettingsRegistryInterface.

Signed-off-by: AMZN-koppersr <82230785+AMZN-koppersr@users.noreply.github.com>
4 years ago
Nicholas Van Sickle 42c2243eaa Fix benchmark non-unity build
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle d1bb5a0543 Move DOM delta comparison to its own file, enhance inverting moves
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle 5b8176e99b Address some review feedback
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle dec3def9eb Merge remote-tracking branch 'upstream/development' into nvsickle/DomPatch 4 years ago
Steve Pham 4d4f10beb8
Clang/GCC compiler settings update [SECURITY] (#7358)
- Add the following compilation flags for clang
  -fpie
  -fstack-protector-all
  -fstack-check (non-release)

- Add the following compilation flags for gcc
  -fpie
  -fstack-protector-all

- Fix -Wunused-result errors from above compilation flag updates

- Add _FORTIFY_SOURCE=2 to GCC DEFINES

Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
4 years ago
Steve Pham 71cc3a2568
Remove -Wno-comment warning suppression
Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
4 years ago
amzn-sj 112e310419
[Serialization] Add support for updating the values of existing keys in associative containers (#6832)
* Add support for updating the values of existing keys in associative containers

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Map/Unordered Map serialization updates values corresponding to existing keys by default. Multimaps always add a new entry for existing keys.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Fix unused parameter warning

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update comparison function for test case

Signed-off-by: amzn-sj <srikkant@amazon.com>
4 years ago
Nicholas Van Sickle 73f166241e Address review feedback
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
lumberyard-employee-dm b9824ed172
Updated all array_view uses with the C++20 span. (#7157)
* Updated all array_view uses with the C++20 span.

The updates were done in the following order
1. `AZStd::array_view<([^>].+)\* ?>`  -> `AZStd::span<\1 const>`
2. `AZStd::array_view<(?:const )(.+)>` -> `AZStd::span<const \1>`
3. `AZStd::array_view` -> `AZStd::span`

Removed the implementation of array_view.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added missing whitespace between `const` and the typename for spans.

Updated the ShaderTest comparison of the ShaderResourceGroupLayout span
to compare the sizes as well

Updated comments on some of the methods that stated that they return "an
array" to mention they return "a span".

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
Esteban Papp d605b5636d
Merge pull request #5532 from aws-lumberyard-dev/optimization/unused_files
Optimization: remove unused files
4 years ago
Esteban Papp 75f511d851
Merge pull request #6390 from aws-lumberyard-dev/memory/overrideshim_removal
Memory/overrideshim removal
4 years ago
Esteban Papp 6fad254b59 Merge branch 'development' into optimization/unused_files
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Editor/IEditorImpl.cpp
#	Code/Editor/IEditorImpl.h
#	Gems/LmbrCentral/Code/Tests/lmbrcentral_editor_tests_files.cmake
4 years ago
Scott Romero 56e7e70735
[development] properly pal-ify Android utilities in AzCore (#7147)
Signed-off-by: AMZN-ScottR 24445312+AMZN-ScottR@users.noreply.github.com
4 years ago
amzn-mike 956a1e59bb
[LYN-9039] Object stream write response change (#7085)
* Updated the ObjectStreamWriteOverride Callback to return a
ObjectStreamWriteOverrideResponse.

The ObjectStreamWriteOverrideResponse allows the callback to indicate
that the default ObjectStream::WriteElement behavior should occur if the
callback hasn't implemented the write itself.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed forward declaration not matching actual enum class name

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add unit tests

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Remove unused member

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Add virtual destructor for test class

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

* Change string literal to not have tabs in it

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>

Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
lumberyard-employee-dm f3e9e41f4f
Adding partial implementation of C++20 concepts and range functions for AZStd::span (#7102)
* Adding partial implementation of C++20 concepts and range functions for AZStd::span

The new concepts to discovered existing issues with the PathIterator and deque::iterator classes
PathIterator wasn't properly an input_iterator and therefore the Path classes weren't a range due to an incorrect const_iterator alias
The deque::iterator classes was missing the operator+ friend function that accepted a (ptrdiff_t, deque::iterator) to fulfill the random_access_iterator concepts

The AZStd implementations of (uninitialized_)copy(_n), (uninitialized_)move(_n) and (uninitialized_)file(_n) have been optimized to use memcpy and memset based on fulfilling the contiguous_iterator concept

Fixed invalid AZStd::vector inserts in FrameGraphExecuter.cpp and SliceditorEntityOwnershipService.cpp
The code was trying to copy the underlying addresses for vector<unique_ptr> to a vector<raw pointer> using insert, which it was doing by using memcpy.

relates to #6749

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed the `fixed_vector` emplace function to not move initialized
elements using uninitialized_move.

This was causing initialized elements of the fixed_vector to be
overwritten with the element at the emplace position.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed clang warnings about variables that are set, but never read

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated the `az_has_builtin_is_constant_evaluated` define to not have
"()" as is not a macro.

This helps prevent users from using `az_has_builtin_is_constant_evaluated`
define in a situation where they want to know if the function is being
evaluated in a compile time context.
In that case they need to use the `az_builtin_is_constant_evaluated()`
macro (which of course looks quite similiar) but does not have the word
"has" in it..

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated the AZStd span class to be C++20 compliant.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Changed phrase "DoesNotCompiles" to be more grammatically correct.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added more unit test for AZStd span

Fixed an the the return type of the subspan template overload to account
for the source span having a dynamic extent.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Removed unused variable from span unit test.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
Chris Galvan 8d0dce2613
Merge pull request #7101 from siretty/fix_build_linux_clang_13
Fix Build on Linux with Clang 13 with Debug, Profile and Release Configuration
4 years ago
Chris Galvan 71640c1c82
Merge pull request #6376 from nemerle/compiletime_filerequest_code2
Compile time reduction - FileRequest & related changes
4 years ago
Daniel Edwards 0a5f472f43 Clang 13: Fix build errors ...
... due to local variables only being written to (but never read).

Signed-off-by: Daniel Edwards <dev@danieledwards.de>
4 years ago
Nicholas Van Sickle e06b8782cc Add AZ::Dom::Patch, a Generic DOM analog to JSON patch
- Currently supports JSON patch operations (add/remove/replace/copy/move/test)
- `GenerateHierarchicalDeltaPatch` provides a patch generation mechanism that produces forward and inverse patches
- Patch application comes with a `PatchApplicationStrategy` functor that allows customizing behavior for patch failure that may be useful for the prefab system
- Serialization to/from JSON patch by way of `AZ::Dom::Value` is supported

Benchmarks provided, split into three categories on the Dom value benchmark payload (payloads with up to 10k entries populated with strings up to 100 characters in length):
- Patch generation based on a deep copy of the affected data
```
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_DeepCopy/10/5            0.024 ms        0.024 ms        29867 items_per_second=41.5541k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_DeepCopy/10/500          0.024 ms        0.024 ms        29867 items_per_second=41.5541k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_DeepCopy/100/5           0.346 ms        0.345 ms         2036 items_per_second=2.89564k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_DeepCopy/100/500         0.375 ms        0.377 ms         1867 items_per_second=2.65529k/s
DomPatchBenchmark/AzDomPatch_Generate_TopLevelReplace/10/5                   0.003 ms        0.003 ms       203636 items_per_second=289.616k/s
DomPatchBenchmark/AzDomPatch_Generate_TopLevelReplace/10/500                 0.004 ms        0.004 ms       194783 items_per_second=283.321k/s
DomPatchBenchmark/AzDomPatch_Generate_TopLevelReplace/100/5                  0.003 ms        0.003 ms       203636 items_per_second=289.616k/s
DomPatchBenchmark/AzDomPatch_Generate_TopLevelReplace/100/500                0.004 ms        0.004 ms       194783 items_per_second=271.002k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_DeepCopy/10/5                0.023 ms        0.024 ms        29867 items_per_second=42.4775k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_DeepCopy/10/500              0.023 ms        0.023 ms        28000 items_per_second=42.6667k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_DeepCopy/100/5               0.341 ms        0.337 ms         2133 items_per_second=2.96765k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_DeepCopy/100/500             0.365 ms        0.361 ms         1948 items_per_second=2.77049k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_DeepCopy/10/5              0.023 ms        0.023 ms        29867 items_per_second=43.4429k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_DeepCopy/10/500            0.023 ms        0.024 ms        29867 items_per_second=42.4775k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_DeepCopy/100/5             0.330 ms        0.330 ms         2133 items_per_second=3.0336k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_DeepCopy/100/500           0.359 ms        0.360 ms         1867 items_per_second=2.77879k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_DeepCopy/10/5             0.023 ms        0.022 ms        29867 items_per_second=44.4532k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_DeepCopy/10/500           0.023 ms        0.023 ms        32000 items_per_second=43.5745k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_DeepCopy/100/5            0.329 ms        0.330 ms         2133 items_per_second=3.0336k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_DeepCopy/100/500          0.357 ms        0.361 ms         1948 items_per_second=2.77049k/s
```
- Patch generation based on a shallow copy of the affected data (this is faster because when using Dom::Value to copy and mutate, we can bypass expensive array and object comparisons for identical values)
```
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_ShallowCopy/10/5         0.010 ms        0.010 ms        74667 items_per_second=99.556k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_ShallowCopy/10/500       0.010 ms        0.010 ms        74667 items_per_second=97.5242k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_ShallowCopy/100/5        0.079 ms        0.078 ms         8960 items_per_second=12.7431k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_ShallowCopy/100/500      0.087 ms        0.087 ms         8960 items_per_second=11.4688k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_ShallowCopy/10/5             0.009 ms        0.009 ms        74667 items_per_second=116.553k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_ShallowCopy/10/500           0.009 ms        0.009 ms        74667 items_per_second=113.778k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_ShallowCopy/100/5            0.072 ms        0.071 ms         8960 items_per_second=13.9863k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_ShallowCopy/100/500          0.087 ms        0.088 ms         7467 items_per_second=11.3783k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_ShallowCopy/10/5           0.014 ms        0.014 ms        49778 items_per_second=72.4044k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_ShallowCopy/10/500         0.014 ms        0.014 ms        56000 items_per_second=70.2745k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_ShallowCopy/100/5          0.118 ms        0.117 ms         5600 items_per_second=8.53333k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_ShallowCopy/100/500        0.140 ms        0.141 ms         4978 items_per_second=7.07982k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_ShallowCopy/10/5          0.009 ms        0.009 ms        89600 items_per_second=108.196k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_ShallowCopy/10/500        0.009 ms        0.009 ms        74667 items_per_second=108.607k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_ShallowCopy/100/5         0.068 ms        0.068 ms        11200 items_per_second=14.6286k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_ShallowCopy/100/500       0.082 ms        0.082 ms         8960 items_per_second=12.2009k/s
```
- Patch application
```
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_ShallowCopy/10/5            0.001 ms        0.001 ms       560000 items_per_second=874.146k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_ShallowCopy/10/500          0.001 ms        0.001 ms       560000 items_per_second=874.146k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_ShallowCopy/100/5           0.004 ms        0.004 ms       172308 items_per_second=250.63k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_ShallowCopy/100/500         0.004 ms        0.004 ms       179200 items_per_second=260.655k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_DeepCopy/10/5               0.005 ms        0.005 ms       112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_DeepCopy/10/500             0.005 ms        0.005 ms       112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_DeepCopy/100/5              0.052 ms        0.052 ms        10000 items_per_second=19.3939k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_DeepCopy/100/500            0.052 ms        0.052 ms        11200 items_per_second=19.373k/s
DomPatchBenchmark/AzDomPatch_Apply_TopLevelReplace/10/5                      0.001 ms        0.001 ms       640000 items_per_second=910.222k/s
DomPatchBenchmark/AzDomPatch_Apply_TopLevelReplace/10/500                    0.001 ms        0.001 ms       640000 items_per_second=910.222k/s
DomPatchBenchmark/AzDomPatch_Apply_TopLevelReplace/100/5                     0.001 ms        0.001 ms       640000 items_per_second=910.222k/s
DomPatchBenchmark/AzDomPatch_Apply_TopLevelReplace/100/500                   0.001 ms        0.001 ms       640000 items_per_second=910.222k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_ShallowCopy/10/5                0.001 ms        0.001 ms       560000 items_per_second=896k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_ShallowCopy/10/500              0.001 ms        0.001 ms       640000 items_per_second=871.489k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_ShallowCopy/100/5               0.004 ms        0.004 ms       160000 items_per_second=232.727k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_ShallowCopy/100/500             0.004 ms        0.004 ms       165926 items_per_second=235.984k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_DeepCopy/10/5                   0.005 ms        0.005 ms       112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_DeepCopy/10/500                 0.005 ms        0.005 ms       112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_DeepCopy/100/5                  0.053 ms        0.053 ms        10000 items_per_second=18.8235k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_DeepCopy/100/500                0.051 ms        0.052 ms        10000 items_per_second=19.3939k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_ShallowCopy/10/5              0.001 ms        0.001 ms       497778 items_per_second=692.561k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_ShallowCopy/10/500            0.001 ms        0.001 ms       497778 items_per_second=692.561k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_ShallowCopy/100/5             0.006 ms        0.006 ms       112000 items_per_second=174.829k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_ShallowCopy/100/500           0.006 ms        0.006 ms       100000 items_per_second=177.778k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_DeepCopy/10/5                 0.005 ms        0.005 ms       112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_DeepCopy/10/500               0.005 ms        0.005 ms       100000 items_per_second=188.235k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_DeepCopy/100/5                0.053 ms        0.052 ms        11200 items_per_second=19.373k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_DeepCopy/100/500              0.052 ms        0.053 ms        11200 items_per_second=18.8632k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_ShallowCopy/10/5             0.001 ms        0.001 ms       560000 items_per_second=874.146k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_ShallowCopy/10/500           0.001 ms        0.001 ms       560000 items_per_second=874.146k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_ShallowCopy/100/5            0.004 ms        0.004 ms       179200 items_per_second=260.655k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_ShallowCopy/100/500          0.004 ms        0.004 ms       179200 items_per_second=260.655k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_DeepCopy/10/5                0.005 ms        0.005 ms       100000 items_per_second=193.939k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_DeepCopy/10/500              0.005 ms        0.005 ms       100000 items_per_second=193.939k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_DeepCopy/100/5               0.052 ms        0.052 ms        11200 items_per_second=19.373k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_DeepCopy/100/500             0.053 ms        0.053 ms        10000 items_per_second=18.8235k/s
```

At a glance, patch generation using `GenerateHierarchicalDeltaPatch` is slower than applying its created patches, but not prohibitively so. Ideally patches shouldn't be recreated unnecessarily, but especially when diffing `Value`s that have been copied and then mutated, a generate + apply operation similar to what prefabs currently do is reasonably fast.

Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle 32e2ba754b
Add Dom::Path class for representing positions in a Dom (#7008)
* Add Dom::Path class for representing positions in a Dom

This also adds Value support for doing a path-based lookup.

The serialized representation is presently compliant with the JSON-pointer spec but the implementation supports Node types and may be later expanded if we require additional functionality (e.g. XPath style conditional querying).

Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Esteban Papp 507a305f67 Cleanup before merge
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Esteban Papp c978e12efc Merge branch 'development' into memory/overrideshim_removal
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Steve Pham 59e43813f0
GCC Support for Linux
Updates and fixes to support GCC for Linux

Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>

Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
Nicholas Van Sickle cfd721bce1
A bit of Generic DOM tidying/fixup (#6914)
* A bit of Generic DOM tidying/fixup

- Refactor out a test fixture for all DOM tests / benchmarks
- Optimize `GetType` implementation to not use `AZStd::variant::visit` (benchmark included to A/B the implementations)
- Tag a few more mutating Value functions with "Mutable" to avoid astonishing copy-on-writes

Benchmark results for GetType implementation:
```
DomValueBenchmark/AzDomValueGetType_UsingVariantIndex              18.2 ns         18.0 ns     40727273 items_per_second=443.667M/s
DomValueBenchmark/AzDomValueGetType_UsingVariantVisit              32.2 ns         32.2 ns     21333333 items_per_second=248.242M/s
```

Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle f026e543cc
Merge pull request #6395 from aws-lumberyard-dev/nvsickle/GenericDomDocument
Add a generic Value type to the Generic DOM
4 years ago
nemerle 3cac520280 Fix non-unity windows build
Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
4 years ago